Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

definitions not updated to $defs #43

Open
chris-smith-zocdoc opened this issue Aug 9, 2022 · 4 comments
Open

definitions not updated to $defs #43

chris-smith-zocdoc opened this issue Aug 9, 2022 · 4 comments
Labels
bug Something isn't working

Comments

@chris-smith-zocdoc
Copy link

Using https://alterschema.sourcemeta.com/ to translate the open api v3 spec from Draft-04 to 2019-09 re: OAI/OpenAPI-Specification#2996

Mostly worked except the definitions references weren't updated to defs. The schema appears valid after making this replacement (according to https://www.jsonschemavalidator.net )

-              "$ref": "#/definitions/Schema"
+              "$ref": "#/$defs/Schema"
@gregsdennis
Copy link

I wonder if this is more of an issue around the schemas being embedded in an OpenAPI doc rather than being independent schemas. I'm not sure if the tool takes that into account.

@jviotti
Copy link
Member

jviotti commented Aug 10, 2022

This is a good point, and it is not related to being OpenAPI. Alterschema is doing a bunch of JSON-replacements to the given schema, but it is not amending JSON pointers touching those paths at all.

I'll send a PR to fix this for $defs in a bit, but I think this is a larger can of worms that we need to think about: if any keyword is modified as part of any Alterschema rule, then ANY JSON pointer going through that path has to be changed as well...

jviotti added a commit that referenced this issue Aug 10, 2022
While we currently upgrade "definitions" to "$defs" in the JSON Schema
definition, pointers going through "definitions" are currently left
intact.

See: #43
Signed-off-by: Juan Cruz Viotti <[email protected]>
jviotti added a commit that referenced this issue Aug 10, 2022
While we currently upgrade "definitions" to "$defs" in the JSON Schema
definition, pointers going through "definitions" are currently left
intact.

See: #43
Signed-off-by: Juan Cruz Viotti <[email protected]>
@jviotti
Copy link
Member

jviotti commented Aug 10, 2022

@chris-smith-zocdoc @gregsdennis The fix for the $defs case has been merged. I released v1.0.4 to NPM and the website is reflecting the changes.

However, let's keep this issue open until we figure out a more general way to deal with transformations within pointers.

@jviotti
Copy link
Member

jviotti commented Aug 10, 2022

I'm thinking about something along these lines: Alterschema has the concept of iterating through every subschema of any JSON Schema definition across specification versions.

Though that mechanism, Alterschema can accurately collect JSON Pointers to every subschema of a given schema. In turn, that information would allow us to break up a JSON Pointer, accurately know which fragments correspond to sub schemas, and try to re-apply some variant of the transformation rules we have WITHIN the pointers themselves.

I'll aim to book some time to hack on this tonight!

@jviotti jviotti added the bug Something isn't working label Aug 10, 2022
jviotti added a commit that referenced this issue Aug 24, 2022
jviotti added a commit that referenced this issue Aug 24, 2022
See: #43
Signed-off-by: Juan Cruz Viotti <[email protected]>
jviotti added a commit that referenced this issue Aug 24, 2022
See: #43
Signed-off-by: Juan Cruz Viotti <[email protected]>
jviotti added a commit that referenced this issue Aug 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants