-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
[BUG] [RUST] Enum Varients Merging Incorrectly, breaking change #17869
Labels
Comments
6 tasks
DDtKey
added a commit
to DDtKey/openapi-generator
that referenced
this issue
Feb 20, 2024
Partially solves OpenAPITools#17869 There is a downside - variants names doesn't reflect model name of reference It also doesn't solve issue of import, will be solved separately
DDtKey
added a commit
to DDtKey/openapi-generator
that referenced
this issue
Feb 20, 2024
Partially solves OpenAPITools#17869 There is a downside - variants names doesn't reflect model name of reference It also doesn't solve issue of import, will be solved separately
5 tasks
DDtKey
added a commit
to DDtKey/openapi-generator
that referenced
this issue
Feb 21, 2024
Solves OpenAPITools#17869 and OpenAPITools#17896 and also includes unmerged $17898 Unfortunately it affects quite a lot of code, but we can see that only client-side models were affected by re-generation. I tried to split this PR to several, but they're really coupled and hard to create a chain of PRs.
5 tasks
wing328
pushed a commit
that referenced
this issue
Feb 24, 2024
* fix(rust): discriminator mapping to serde rename Discriminator mapping has been ignored in some cases. Even existing samples had wrong definition in some cases This PR addresses this * fix(rust): `oneOf` generation for client Solves #17869 and #17896 and also includes unmerged $17898 Unfortunately it affects quite a lot of code, but we can see that only client-side models were affected by re-generation. I tried to split this PR to several, but they're really coupled and hard to create a chain of PRs. * fix: indentation in `impl Default` * missing fixes * fix: correct typeDeclaration with unaliased schema * style: improve indentation for models * fix: user toModelName for aliases of oneOf * refactor: unify `getTypeDeclaration` for rust * cover the case when `mapping` has the same `ref` for different mapping names * test: add test for previous change * style: remove extra qualified path to models * add some comments * fix(build): use method of `List` instead of specific for `LinkedList`
oscarr-reyes
pushed a commit
to oscarr-reyes/openapi-generator
that referenced
this issue
Feb 25, 2024
* fix(rust): discriminator mapping to serde rename Discriminator mapping has been ignored in some cases. Even existing samples had wrong definition in some cases This PR addresses this * fix(rust): `oneOf` generation for client Solves OpenAPITools#17869 and OpenAPITools#17896 and also includes unmerged $17898 Unfortunately it affects quite a lot of code, but we can see that only client-side models were affected by re-generation. I tried to split this PR to several, but they're really coupled and hard to create a chain of PRs. * fix: indentation in `impl Default` * missing fixes * fix: correct typeDeclaration with unaliased schema * style: improve indentation for models * fix: user toModelName for aliases of oneOf * refactor: unify `getTypeDeclaration` for rust * cover the case when `mapping` has the same `ref` for different mapping names * test: add test for previous change * style: remove extra qualified path to models * add some comments * fix(build): use method of `List` instead of specific for `LinkedList`
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bug Report Checklist
Description
I'm receiving a new compilation error when using an email with two tuple variants that reduce to the same type. Unfortunately, I suspect the error is related to #13970 .
I'm using the newtype pattern to validate the string with RAII. I have two types
Because I want my API route to access either an email or an account name using login, I have a third type:
(These enum varients may look identical but they're actually mutually exclusive and disambiguated during serde::deserialize via a
TryFrom
impl.)I'm using Utoipa to generate an
openapi.json
file for my Rust server, and I generate my client using the Docker image for openapi-generator.Using the Docker image tagged at
v7.2.0
, theAccountOrEmail
type would generate as...This type is completely useless, but it did compile. #13970 sought to make the generated code actually useful (and I really benefit from the PR!). However, using the
latest
docker image, which I confirmed was published after the PR landed, the following code is generated:Note the spurious import of
use super::String
; no such file exists, and the name conspicuously conflicts withstd::string::String
in the default namespace. This code no longer compiles. Here's the console output:openapi-generator version
I'm using the
latest
Docker image (accessed on 2/14/24). This appears to be a regression; using thev7.2.0
image, the code will compile (but it won't be useful without #13790).OpenAPI declaration file content or url
I paired down the generated specification to be the smaller possible valid spec that reproduces the issue:
Generation Details
Steps to reproduce
openapi.json
file I included above into $PWD/openapi.json.Related issues/PRs
#13970
I really hope this bug can be patched without reversing the above PR, because it's a much needed addition to the project 😅
Suggest a fix
It looks like the two newtypes are getting incorrectly merged; instead, I believe the models for
AccountName
andEmail
should be generated and referenced in the enum.The text was updated successfully, but these errors were encountered: