-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
[RUST-AXUM] fix generator not handling application/x-www-form-urlencoded request content #18061
Conversation
if (requestBody != null) { | ||
String contentType = getContentType(requestBody); | ||
if (contentType != null) { | ||
contentType = contentType.toLowerCase(Locale.ROOT); | ||
} | ||
if (contentType != null && | ||
if (!handleFormContent && contentType != null && |
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.
can you please elaborate more on this change?
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.
this is a new flag to disable the logic on how the form params are being handled, currently the body is being consumed and all identified form params extracted, in this branch bodyParam
is not being set which is required by the axum template:
openapi-generator/modules/openapi-generator/src/main/resources/rust-axum/server-operation.mustache
{{#bodyParam}}
{{#vendorExtensions}}
{{#x-consumes-json}}
Json(body): Json<{{^required}}Option<{{/required}}{{{dataType}}}{{^required}}>{{/required}}>,
{{/x-consumes-json}}
{{#x-consumes-form-urlencoded}}
Form(body): Form<{{^required}}Option<{{/required}}{{{dataType}}}{{^required}}>{{/required}}>,
{{/x-consumes-form-urlencoded}}
axum can deserialize form params from the body
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.
I prefer using !(this instanceof RustAxumServerCodegen)
to make it much easier to understand this logic is tailor-made for the RustAxumServerCodegen instead of adding another option/flag
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.
it does work, however this to me looks that we create a dependency to more specialized class inside the generic one (since we have to import RustAxumServerCodegen
)
but I see that similar was done before.
import org.openapitools.codegen.languages.PhpNextgenClientCodegen;
import org.openapitools.codegen.languages.RustAxumServerCodegen; // new import
import org.openapitools.codegen.languages.RustServerCodegen;
cc @linxGnu |
that's fixed in the latest master so it can be ignored |
@linxGnu are you happy with this change? |
@wing328 LGTM for the changes |
to fix #18060
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
(upcoming 7.1.0 minor release - breaking changes with fallbacks),8.0.x
(breaking changes without fallbacks)