Use referenced string enum schema in requestBody if available#21410
Use referenced string enum schema in requestBody if available#21410WannabeSoftwareEngineer wants to merge 0 commit intoOpenAPITools:masterfrom
Conversation
|
Tagging some members of the Java committee I would appreciate a few moments of your time to share any feedback on the proposed changes. Thank you. |
|
Hello, could you please adjust the message so that it aligns with this? It would be helpful since it would make the issues page show that there already exists a suggested solution for the raised issue. |
|
thanks for the pr what about considering this as a bug fix without the option to start with as we want to avoid option overload (too many options)? if later users need ways to fallback, of course one way is to update the spec to remove enum from the string body definition. |
|
I also prefer to keep the number of options minimal, but I initially introduced the flag to avoid a breaking change for existing users. Since you're okay with treating this as a bug fix and going ahead without the flag, I'll update the MR to remove the option accordingly. |
f371a91 to
42af4f9
Compare


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)Description
This PR fixes #21407.
The core of this change is to treat a referenced string enum schema as a model rather than a primitive.
To achieve this, the
updateRequestBodyForStringmethod has been updated to accept the schema's component name. When this name is present, we delegate processing toaddBodyModelSchema. This mirrors the existing logic that is already present inupdateRequestBodyForObject, resulting in the proper enum type in the generated API.The behavior for primitive or inline strings remains unchanged.
Breaking change
Since this modifies the generated method signatures, the new behavior is introduced behind a feature flag named
useStringEnumSchemaRefForRequestBodyto ensure back compatibility with existing clients.