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

investigate improving number schema generation #51

Open
mnahkies opened this issue Apr 22, 2023 · 0 comments
Open

investigate improving number schema generation #51

mnahkies opened this issue Apr 22, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@mnahkies
Copy link
Owner

@mnahkies mnahkies added the enhancement New feature or request label Apr 22, 2023
mnahkies added a commit that referenced this issue Nov 12, 2023
this adds basic support for openapi 3.1 definitions, based on the
mgiration blog post from openapis.org.

the primary change is allowing `null` as a `type`, and that `type`
can be an array.

the other changes listed relating to file uploads, and
`exclusiveMinimum` aren't applicable as these aren't really supported at
all yet (#51,
#53)

there's probably a bunch of other gaps in general JSON schema support,
such as the `if` / `else` things mentioned, but there's relatively few
examples of complex `3.1.0` definitions to test against.

I stumbled across https://github.com/APIs-guru/openapi-directory looking
for samples and I've tested these changes against these definitions:
- https://github.com/APIs-guru/openapi-directory/blob/dec74da7a6785d5d5b83bc6a4cebc07336d67ec9/APIs/vercel.com/0.0.1/openapi.yaml
- https://github.com/APIs-guru/openapi-directory/blob/dec74da7a6785d5d5b83bc6a4cebc07336d67ec9/APIs/discourse.local/latest/openapi.yaml
- https://github.com/APIs-guru/openapi-directory/blob/dec74da7a6785d5d5b83bc6a4cebc07336d67ec9/APIs/adyen.com/CheckoutService/70/openapi.yaml

It appears to be giving reasonable output - no compile errors at
least, and nothing obviously wrong doing a quick scan of output.

ref: https://www.openapis.org/blog/2021/02/16/migrating-from-openapi-3-0-to-3-1-0
mnahkies added a commit that referenced this issue Nov 12, 2023
this adds basic support for openapi 3.1 definitions, based on the
mgiration blog post from openapis.org.

the primary change is allowing `null` as a `type`, and that `type`
can be an array.

the other changes listed relating to file uploads, and
`exclusiveMinimum` aren't applicable as these aren't really supported at
all yet (#51,
#53)

there's probably a bunch of other gaps in general JSON schema support,
such as the `if` / `else` things mentioned, but there's relatively few
examples of complex `3.1.0` definitions to test against.

I stumbled across https://github.com/APIs-guru/openapi-directory looking
for samples and I've tested these changes against these definitions:
- https://github.com/APIs-guru/openapi-directory/blob/dec74da7a6785d5d5b83bc6a4cebc07336d67ec9/APIs/vercel.com/0.0.1/openapi.yaml
- https://github.com/APIs-guru/openapi-directory/blob/dec74da7a6785d5d5b83bc6a4cebc07336d67ec9/APIs/discourse.local/latest/openapi.yaml
- https://github.com/APIs-guru/openapi-directory/blob/dec74da7a6785d5d5b83bc6a4cebc07336d67ec9/APIs/adyen.com/CheckoutService/70/openapi.yaml

It appears to be giving reasonable output - no compile errors at
least, and nothing obviously wrong doing a quick scan of output.

ref: https://www.openapis.org/blog/2021/02/16/migrating-from-openapi-3-0-to-3-1-0
mnahkies added a commit that referenced this issue Nov 12, 2023
this adds basic support for openapi 3.1 definitions, based on the
mgiration blog post from openapis.org.

the primary change is allowing `null` as a `type`, and that `type`
can be an array.

the other changes listed relating to file uploads, and
`exclusiveMinimum` aren't applicable as these aren't really supported at
all yet (#51,
#53)

there's probably a bunch of other gaps in general JSON schema support,
such as the `if` / `else` things mentioned, but there's relatively few
examples of complex `3.1.0` definitions to test against.

I stumbled across https://github.com/APIs-guru/openapi-directory looking
for samples and I've tested these changes against these definitions:
- https://github.com/APIs-guru/openapi-directory/blob/dec74da7a6785d5d5b83bc6a4cebc07336d67ec9/APIs/vercel.com/0.0.1/openapi.yaml
- https://github.com/APIs-guru/openapi-directory/blob/dec74da7a6785d5d5b83bc6a4cebc07336d67ec9/APIs/discourse.local/latest/openapi.yaml
- https://github.com/APIs-guru/openapi-directory/blob/dec74da7a6785d5d5b83bc6a4cebc07336d67ec9/APIs/adyen.com/CheckoutService/70/openapi.yaml

It appears to be giving reasonable output - no compile errors at
least, and nothing obviously wrong doing a quick scan of output.

ref: https://www.openapis.org/blog/2021/02/16/migrating-from-openapi-3-0-to-3-1-0
mnahkies added a commit that referenced this issue Nov 12, 2023
this adds basic support for openapi 3.1 definitions, based on the
migration blog post from openapis.org.

the primary change is allowing `null` as a `type`, and that `type` can
be an array.

the other changes listed relating to file uploads, and
`exclusiveMinimum` aren't applicable as these aren't really supported at
all yet (#51,
#53)

there's probably a bunch of other gaps in general JSON schema support,
such as the `if` / `else` things mentioned, but there's relatively few
examples of complex `3.1.0` definitions to test against.

I stumbled across https://github.com/APIs-guru/openapi-directory looking
for samples and I've tested these changes against these definitions:
-
https://github.com/APIs-guru/openapi-directory/blob/dec74da7a6785d5d5b83bc6a4cebc07336d67ec9/APIs/vercel.com/0.0.1/openapi.yaml
-
https://github.com/APIs-guru/openapi-directory/blob/dec74da7a6785d5d5b83bc6a4cebc07336d67ec9/APIs/discourse.local/latest/openapi.yaml
-
https://github.com/APIs-guru/openapi-directory/blob/dec74da7a6785d5d5b83bc6a4cebc07336d67ec9/APIs/adyen.com/CheckoutService/70/openapi.yaml

It appears to be giving reasonable output - no compile errors at least,
and nothing obviously wrong doing a quick scan of output.

ref:
https://www.openapis.org/blog/2021/02/16/migrating-from-openapi-3-0-to-3-1-0
mnahkies added a commit that referenced this issue Apr 6, 2024
- includes `minimum` / `maximum` on the numeric ir model
- uses these to add validations with `zod`
- add `prettier` to fix bad inline-snapshot indentation (see
jestjs/jest#15014)
- memorize openapi validator in unit tests, speeding them up
considerably (`~6s` -> `~1s` for the zod spec file)
- improve test harness for zod to support directly providing `IRModel`
objects, and also execute the resulting schemas to parse a value
- this makes it easier to write a broader range of tests, and should
also prevent misunderstandings of the zod API

Partially addresses #51
mnahkies added a commit that referenced this issue Apr 6, 2024
adds support for the rest of the number validation keywords defined by
JSON schema validation.

also fixes a bug in #140 / #143 where `0` would be treated as
`undefined`

relates #51 

ref:
https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-validation-00#section-6.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant