Skip to content

include $schema version declaration in json schema exports#1359

Closed
gwennlbh wants to merge 1 commit intoarktypeio:mainfrom
gwennlbh:jsonschemaversion
Closed

include $schema version declaration in json schema exports#1359
gwennlbh wants to merge 1 commit intoarktypeio:mainfrom
gwennlbh:jsonschemaversion

Conversation

@gwennlbh
Copy link

@gwennlbh gwennlbh commented Mar 9, 2025

Hi!

I noticed that the exported JSON Schema object does not include the $schema key, which declares the meta schema (and thus declares which version of JSON schema this is intended to be used with)

I used the latest version and hardcoded the string, it might be worth factoring out

In order to only add the $schema key at the top-level, I added a new .toJsonSchemaNoVersion method that does what .toJsonSchema did before

I wonder if the usages of .toJsonSchema could be replaced with .innerToJsonSchema so we don't have to add a new method?

I also tried putting the version inclusion as an optional argument to .toJsonSchema, but it seems like my typescript powers are not strong enough yet, I get a type error at the Object.assign call when doing

toJsonSchema<IncludeVersion extends boolean | undefined>(includeVersion?: IncludeVersion): IncludeVersion extends true ? FinalJsonSchema : JsonSchema

Thanks a lot for this project, it's really impressive and the DX is great :3

@gwennlbh gwennlbh force-pushed the jsonschemaversion branch from 9357e30 to 6eec177 Compare March 9, 2025 14:12
gwennlbh added a commit to cigaleapp/cigale that referenced this pull request Mar 9, 2025
@gwennlbh
Copy link
Author

gwennlbh commented Mar 9, 2025

It might be worth using draft-07 instead, VS Code warns me on unsupported features (namely "$dynamicRef" i believe) for newer versions

@ssalbdivad ssalbdivad moved this from To do to Planned in arktypeio Mar 11, 2025
@ssalbdivad ssalbdivad moved this from Planned to In progress in arktypeio Mar 11, 2025
@ssalbdivad ssalbdivad moved this from In progress to Planned in arktypeio Mar 13, 2025
@ssalbdivad
Copy link
Member

Hey thanks so much for this PR it was very useful!

I'm updating the toJsonSchema API to be more flexible. The approach will be a bit different so I'm going to close this, but I referred it throughout the process and it was useful ❤️

@ssalbdivad ssalbdivad closed this Apr 7, 2025
@github-project-automation github-project-automation bot moved this from Planned to Done (merged or closed) in arktypeio Apr 7, 2025
gwennlbh added a commit to cigaleapp/cigale that referenced this pull request Jun 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done (merged or closed)

Development

Successfully merging this pull request may close these issues.

2 participants