Closed adambrgmn closed 2 weeks ago
CI is running/has finished running commands for commit 65fc3d351b9128010733a644d4a141f100e44b35. 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
Sent with 💌 from NxCloud.
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.
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 supportstype
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
generateSchema
–openApiVersion
which can be either'3.0' | '3.1'
. To not break anyone already relying on the 3.1 support ofgenerateSchema
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