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

feat: Add OpenAPI Specification 3.1.0 support #230

Merged
merged 7 commits into from
Mar 22, 2024
Merged

feat: Add OpenAPI Specification 3.1.0 support #230

merged 7 commits into from
Mar 22, 2024

Conversation

miketheman
Copy link
Collaborator

Updates library to OAS3.1.0

  • Update to default Swagger UI to latest release
  • Update pyramid_openapi3/tests/test_contenttypes.py to express the new binary format

OAS 3.1.0 support introduced in 5.0.0

Signed-off-by: Mike Fiedler <[email protected]>
Adapt to new JSONSchema style.
Update test to remove `decode()` since it's cast to a string from binary
for us.

Signed-off-by: Mike Fiedler <[email protected]>
@miketheman miketheman linked an issue Mar 20, 2024 that may be closed by this pull request
@miketheman miketheman requested a review from zupo March 20, 2024 22:07
@miketheman miketheman added the enhancement New feature or request label Mar 20, 2024
@zupo
Copy link
Collaborator

zupo commented Mar 21, 2024

The diff doesn't look too complex, which makes me wonder if we should keep support for OpenAPI v3.0. Can you give it a try to see how doable it is?

@miketheman
Copy link
Collaborator Author

In my tests, I couldn't get the current code to fail with an openapi 3.0.0 spec, so it's possible that the openapi-core handles that for us transparently?

@zupo
Copy link
Collaborator

zupo commented Mar 21, 2024

I imagine our specs are so simple that they are compatible with both v3.0 and v3.1. We'd need to add a test spec that includes some v3.1-only feature.

Additionally, openapi-core seems to be smart enough to use the correct version of the unmarshaller: https://github.com/python-openapi/openapi-core/blob/32ce65739531eea90220aeabbee72096818b9d05/docs/customizations/request_unmarshaller_cls.rst.

So I guess we could do the same, use _get_version() to get the version from spec and then load the correct unmarshaller: https://github.com/python-openapi/openapi-core/blob/32ce65739531eea90220aeabbee72096818b9d05/openapi_core/app.py#L144

@miketheman
Copy link
Collaborator Author

I had previously added a test for an OAS3.1-specific feature (the binary format change).

I added another test case and app to show the breakage, and then made a dispatch based on the detected spec versions.

It's not super beautiful, but it works!

Fresh coat of paint. Addresses minor inconsistencies, as surfaced by
markdownlint and my own observations.

Signed-off-by: Mike Fiedler <[email protected]>
Copy link
Collaborator

@zupo zupo left a comment

Choose a reason for hiding this comment

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

Looks great!

@miketheman miketheman changed the title feat: update to OpenAPI Specification 3.1.0 feat: Add OpenAPI Specification 3.1.0 support Mar 22, 2024
@miketheman miketheman merged commit ef0df8d into main Mar 22, 2024
3 checks passed
@miketheman miketheman deleted the openapi_310 branch March 22, 2024 13:18
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

Successfully merging this pull request may close these issues.

OpenAPI 3.1 Support
2 participants