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

Support "nullable" (OpenApi 3.0 only) #32

Closed
ahx opened this issue Jul 6, 2019 · 9 comments · Fixed by #101
Closed

Support "nullable" (OpenApi 3.0 only) #32

ahx opened this issue Jul 6, 2019 · 9 comments · Fixed by #101
Milestone

Comments

@ahx
Copy link
Owner

ahx commented Jul 6, 2019

Currently OpenapiFirst does not support "nullable" of the OpenApi flavoured JSON Schema.

See davishmcclurg/json_schemer#22

@ahx
Copy link
Owner Author

ahx commented Oct 21, 2019

json_schemer is currently not a good place to impement something like that.
Here's an idea for a new rubygem:

require 'openapi-json-schema-converter'
OpenapiJsonSchemaConverter.new(openapi_json_schema).call(data) # => standard_json_schema

@ahx ahx added this to the 0.7 milestone Oct 30, 2019
@ahx ahx changed the title Support using OpenApi flavoured JSON Schema for request/response validation Support "nullable" (OpenApi flavoured JSON Schema) Dec 2, 2019
@tristandruyen
Copy link

@ahx
FYI this is a workaround we found:

some_thing:
  oneOf:
    - type: 'null'   # Note the quotes around 'null'
    - type: string

which could be improved once OpenAPI 3.1 (#46) is supported to:

some_thing:
  type: ['null',string]

so does this even need to stay open?

@ahx
Copy link
Owner Author

ahx commented Apr 20, 2020

type: ['null',string] should work, even though it is not officially supported by OAS 3.0.

I think supporting nullable would be useful, because we could use standard OAS linters that would fail when using type: ['null',string]. OAS 3.1 solves all this, but unfortunately it has not reached RC status, yet.

@ahx
Copy link
Owner Author

ahx commented Jun 3, 2020

This should be obsolete with OAS 3.1, since nullable will be removed from OpenAPI 3.1 and type arrays will be valid type: ['null', string ] 👍.
I think we can close this.

@ahx ahx closed this as completed Jun 3, 2020
@ahx
Copy link
Owner Author

ahx commented Oct 19, 2020

Reopening, because I want to support OpenAPI 3.0.x

@ahx ahx reopened this Oct 19, 2020
@ahx ahx removed this from the 0.7 milestone Oct 19, 2020
@ahx ahx closed this as completed in #101 Oct 20, 2020
@ahx
Copy link
Owner Author

ahx commented Nov 3, 2020

Reopening, because current implementation does not work with allOf, oneOf :|

@ahx
Copy link
Owner Author

ahx commented Mar 4, 2023

@JF-Lalonde nullable has been removed from OAS since 3.1. Is updating your spec to 3.1 an option for you/your team?

@JF-Lalonde
Copy link
Contributor

@ahx Good to know! We've actually adopted the type: ['null',string] already even though it's not officially supported. But we'll probably be upgrading to 3.1 soon.

@ahx ahx changed the title Support "nullable" (OpenApi flavoured JSON Schema) Support "nullable" (OpenApi 3.0 only) Apr 28, 2023
@ahx
Copy link
Owner Author

ahx commented Oct 27, 2023

FYI this will be solved in 1.0, because json_schemer supports it with it's OpenAPI 3.0 / 3.1 metaschema

@ahx ahx added this to the 1.0.0 milestone Nov 14, 2023
@ahx ahx closed this as completed Jan 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants