Json schema typings for typescript?

Hello, im reading the documentation and i am quite interested about the json config structure

I see online that its quite documented and i was wondering if there is any way to get type information for the json structure in example typescript etc.

So that if we read the schema as a object we know the types etc and structure the json is in. Something to make it typesafe.

I know plugins etc does add onto the json and extends it so i guess not all parts can be schemified automatically?

Is it possible generate typescript types etc (d.ts) for the json schema structure for the base caddy json structure?

I’m not sure about Typescript specifically but would this plugin be of any help? It generates a JSON schema for your editor:

What format would the json schema be in, do you have any sample generated json on hand?
Perhaps i could generate some typings from that json schema

It’s in “JSON Schema” format. https://json-schema.org/

TS types aren’t really the same, but you could use this project (fork it) to produce what you need.

1 Like

Thank you, i managed to solve it by grabbing the generated schema and using the library: json-schema-to-typescript
In mt typescript to generate types from the schema json file and use that in my project.

2 Likes

This topic was automatically closed after 60 days. New replies are no longer allowed.