Add support for specifying JSON schema dialects (fixes #202)#401
Add support for specifying JSON schema dialects (fixes #202)#401ayushshrivastv wants to merge 2 commits intomattpolzin:mainfrom
Conversation
Add support for specifying JSON Schema dialects at both document root and schema levels. This allows OpenAPI documents to declare which JSON Schema dialect they use via the keyword. Add jsonSchemaDialect property to Document struct Add schemaDialect property to JSONSchema.CoreContext Add coding key for encoding/decoding Resolves mattpolzin#202
|
There might be a few minor flaws or edge cases that could arise while running it, I’d be happy to dig deeper and help improve it further! |
|
In the meantime, while I’m familiarizing myself with the codebase, I’ve discovered a more efficient way to add the JSON schema dialect. I plan to submit another commit for this improvement. Additionally, I’m seeking a more efficient way to structure and write the code. Thank you! |
|
This PR is going to need a bit of attention. I see you've added OpenAPI.Document to the root openapi namespace file instead of modifying the existing Document struct. I also see tons of preferential changes (including whitespace changes in the schema file. Please undo those changes leaving only the changes necessary to implement new functionality. |
Yes, I’ve reopened this issue and am currently working on incorporating support for specifying JSON schema dialects into the existing codebase in a new commit. Currently, there are some linter errors. Once the implementation is fully functional, I’ll commit this pull request. The previous commit is a month old. I’ve just merged the commit to be synchronised with the main branch. Thank You! |
|
I'm going to close this PR for now but please feel free to open it again if you want to pick this work up. Thanks! |
This pull request adds support for specifying JSON Schema dialects in OpenAPI documents, as per issue #202. Now, OpenAPI documents can declare JSON Schema dialects at both the document root and individual schema levels. You can use the jsonSchemaDialect and $schema keywords, respectively.
The root document level changes in OpenAPI.swift
The schema level changes in JSONSchema.swift
The changes accurately implement the ability to specify JSON schema dialects at both
Document level (via jsonSchemaDialect)
Individual schema level (via schemaDialect)
Both implementations use
URL type for storing the dialect.
Optionally, include additional properties.
Use “$schema” as the coding key.
Ensure support for these properties in the corresponding initializers.