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

Migrate to OpenAPI 3.1 #5400

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ai-oleynikov
Copy link
Contributor

This PR updates OpenAPI version from 3.0 to 3.1 in accordance with this guide: https://www.openapis.org/blog/2021/02/16/migrating-from-openapi-3-0-to-3-1-0

The only changes I made are:

  • deletion of "nullable": false as this keyword is now deprecated, and nulls are rejected by default anyway
  • replacement of "type": "<some-type>", "nullable": true with "type": ["<some-type>", "null"]
  • replacement of "minimum": 0, "exclusiveMinimum": true with "exclusiveMinimum": 0
  • replacement of "example" with "examples" keyword inside Schema Objects

Comment on lines -179 to +183
"summary": "Get crowdfund app data",
"description": "Returns crowdfund app data",
"summary": "Get crowdfunding app data",
"description": "Returns crowdfunding app data",
"responses": {
"200": {
"description": "Crowdfund app data",
"description": "Crowdfunding app data",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one change is unrelated to the migration to OpenAPI 3.1. I just couldn't ignore it. "Crowdfunding app" sounds more natural. Feel free to revert this change if you disagree though.

Copy link
Member

@dennisreimann dennisreimann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@Kukks Kukks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The swagger schema test fails. Please check CheckSwaggerIsConformToSchema

@dennisreimann
Copy link
Member

It looks like the Newtonsoft JSchema package has problems parsing th OpenAPI 3.1 spec. Updated the lib and tried various approaches, but it fails with Error when resolving schema reference '#/$defs/info'. Path 'properties.info', line 11, position 13, which one can also replicate with their JSON Schema Validator (select the openapi.json from the dropdown).

@dennisreimann
Copy link
Member

dennisreimann commented Nov 3, 2023

Rebased and tried to make the schema validation work by removing the $id attribute, which prevented that the references worked in general. But now there is still an error with nested $defs: Could not resolve schema reference '#/$defs/parameter/dependentSchemas/schema/$defs/styles-for-path'. Path '$defs.parameter.dependentSchemas.schema.allOf[1]'

@dennisreimann
Copy link
Member

@ai-oleynikov Any idea how we can resolve this?

@pavlenex
Copy link
Contributor

ping @ai-oleynikov still interested in helping with this one, if so can you check ^

@ai-oleynikov
Copy link
Contributor Author

Sorry for my disappearance! I'll work on fixing this today and report back if I have any issues I can't resolve.

@ai-oleynikov
Copy link
Contributor Author

The problem seems to be that JSchema doesn't support the current version of the JSON Schema spec.

https://www.jsonschemavalidator.net/ says the following

An online, interactive JSON Schema validator. Supports JSON Schema Draft 3, Draft 4, Draft 6, Draft 7 and Draft 2019-09.

Therefore. it can't parse JSON Schema 2020-12. The error messages @dennisreimann shared above indicate that JSchema is unable to resolve references containing $defs, likely due to the changes in the behavior of $defs introduced in JSON Schema 2020-12.

Unfortunately, the OpenAPI Initiative doesn't provide a JSON Schema for OpenAPI 3.1 using spec versions other than 2020-12. All their schema files are written using this version.

I'm not sure what can be done here, except replacing JSchema with another JSON Schema validator that supports the current version of the spec 🤔

@ai-oleynikov
Copy link
Contributor Author

ai-oleynikov commented Dec 27, 2023

This package seems to support JSON Schema draft 2020-12: https://www.nuget.org/packages/JsonSchema.Net

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 this pull request may close these issues.

None yet

4 participants