Add support for enums of integers in rust-server generator. #22915
Open
dsteeley wants to merge 3 commits intoOpenAPITools:masterfrom
Open
Add support for enums of integers in rust-server generator. #22915dsteeley wants to merge 3 commits intoOpenAPITools:masterfrom
dsteeley wants to merge 3 commits intoOpenAPITools:masterfrom
Conversation
Contributor
There was a problem hiding this comment.
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
Contributor
Author
|
@wing328 This PR is ready for attention. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.