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

Bring back support for Open API v3.0 #206

Merged
merged 1 commit into from
Jun 21, 2024
Merged

Bring back support for Open API v3.0 #206

merged 1 commit into from
Jun 21, 2024

Conversation

adambrgmn
Copy link
Contributor

Hey and thank you for a very nice project! It helps us a lot.

As mentioned in issue #192 version 2.2.4 of @anatine/zod-openapi introduced support for OpenAPI v3.1. But by doing so it also dropped support for v3.0 it seems.
I should mention that I am not an expert in the OpenAPI spec, so I can't tell what broke other than that 3.0 only supports type as a string union, not an array,
which seems to be supported in 3.1 and implemented in this package.

I've seen the discussions around supporting 3.1 and acknowledge that it is needed. But the fact is that this change broke the integration with NestJS's swagger
implementation which is still emitting 3.0 schemas. And this was introduced as a patch release, and not a major.

My proposal is to support both of the specs together by introducing a new paramater to generateSchemaopenApiVersion which can be either '3.0' | '3.1'.
To not break anyone already relying on the 3.1 support of generateSchema I decided to set the default to 3.1.

But for patchNestSwagger I decided to set the default to 3.0 as to not break support for NestJS's swagger module.

Please let me know what you think about this change and if you see another solution that might be better suited. Also let me know if you want me to add more tests
to validate the 3.0 behaviour.

Fixes #192

Copy link

nx-cloud bot commented May 24, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 65fc3d3. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 2 targets

Sent with 💌 from NxCloud.

@RobbyUitbeijerse
Copy link

Hey there! We would love this PR to be merged. We're in the middle of migrating from the recently archived nestjs-zod to @anatine/zod-nestjs and @anatine/zod-openapi. The migration was simple and smooth - but due to certain tools and generators not supporting 3.1.0 yet, we're stuck with wrapping it up. We would love those tools to support it, but supporting 3.0 in anatine packages seems more reasonable.

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.

[zod-openapi] generateSchema creates incorrect schema type
3 participants