-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Add support for enums of integers in rust-server generator. #22915
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No issues found across 3 files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
6 issues found across 15 files
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="samples/server/petstore/rust-server/output/multipart-v3/src/models.rs">
<violation number="1" location="samples/server/petstore/rust-server/output/multipart-v3/src/models.rs:169">
P2: List header parsing now requires a comma+space delimiter, which rejects valid list headers without whitespace (e.g., "a,b") and can cause parsing failures. HTTP list headers allow optional whitespace around commas, so the split should accept commas regardless of spaces.</violation>
</file>
<file name="samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/models.rs">
<violation number="1" location="samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/models.rs:158">
P2: Header Vec parsing now splits only on the exact ", " delimiter, so valid comma-separated header values like "a,b" or "a, b" are not parsed into elements. This is a regression from the previous `.split(',')` behavior and can cause deserialization errors for standard header formats.</violation>
</file>
<file name="samples/server/petstore/rust-server/output/rust-server-test/src/models.rs">
<violation number="1" location="samples/server/petstore/rust-server/output/rust-server-test/src/models.rs:165">
P2: Header list parsing now requires a comma+space delimiter. Valid HTTP header lists can be comma-separated without spaces ("a,b"), so .split(", ") will treat them as a single entry and can break parsing. Use ',' as the delimiter and keep trimming each element to accept both forms.</violation>
</file>
<file name="modules/openapi-generator/src/main/resources/rust-server/models.mustache">
<violation number="1" location="modules/openapi-generator/src/main/resources/rust-server/models.mustache:686">
P2: Header list parsing now only splits on comma+space, rejecting valid header values like "a,b" (HTTP lists allow optional whitespace). This will cause enum list headers without spaces to fail parsing. Split on ',' and trim instead.</violation>
</file>
<file name="samples/server/petstore/rust-server/output/no-example-v3/src/models.rs">
<violation number="1" location="samples/server/petstore/rust-server/output/no-example-v3/src/models.rs:149">
P2: Header list parser now only splits on comma+space, rejecting valid comma-separated headers without spaces.</violation>
</file>
<file name="samples/server/petstore/rust-server/output/openapi-v3/src/models.rs">
<violation number="1" location="samples/server/petstore/rust-server/output/openapi-v3/src/models.rs:121">
P2: List header parsing now splits on ", " only, so valid header values without a space after the comma (e.g., "a,b") won't be split into multiple items and can be parsed incorrectly. Use a comma-only split and rely on trim() to handle optional whitespace.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
...er/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/models.rs
Outdated
Show resolved
Hide resolved
samples/server/petstore/rust-server/output/rust-server-test/src/models.rs
Show resolved
Hide resolved
modules/openapi-generator/src/main/resources/rust-server/models.mustache
Outdated
Show resolved
Hide resolved
samples/server/petstore/rust-server/output/no-example-v3/src/models.rs
Outdated
Show resolved
Hide resolved
samples/server/petstore/rust-server/output/openapi-v3/src/models.rs
Outdated
Show resolved
Hide resolved
27b2283 to
d0b3492
Compare
d0b3492 to
171d779
Compare
|
@wing328 This PR is ready for attention. |
Support enums of integers in rust-server generator. Previously we treated all enum values as strings which in some cases may be incorrect and result in being unable to deserialise an integer enum value.
Elements in an enum array can be any time according to 5.20 of the json schema which the openapi specification inherits for enum types. https://datatracker.ietf.org/doc/html/[draft-wright-json-schema-validation-00](https://datatracker.ietf.org/doc/html/draft-wright-json-schema-validation-00#section-5.20)#section-5.20.
PR checklist
Commit all changed files.
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
master(upcoming7.x.0minor release - breaking changes with fallbacks),8.0.x(breaking changes without fallbacks)"fixes #123"present in the PR description)Summary by cubic
Add support for integer enums in the rust-server generator using serde_repr so they serialize/deserialize as JSON numbers. Also fixes header conversion impls in deprecated templates to work in client builds.
Written for commit 171d779. Summary will update on new commits.