Skip to content

Commit

Permalink
[RUST-AXUM] fix generator not handling application/x-www-form-urlenc…
Browse files Browse the repository at this point in the history
…oded request content, update for initial fix OpenAPITools#18061  (OpenAPITools#18362)

* fix OpenAPITools#18060

* isolate the option as separate flag

* apply modification suggested by @wing328

* remove added newlines

* do not change the handle of multipart body, keep the change only for x-www-form-urlencoded
  • Loading branch information
denisbog authored Apr 18, 2024
1 parent 807250a commit 514c0d6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ additionalProperties:
hideGenerationTimestamp: "true"
packageName: petstore-with-fake-endpoints-models-for-testing
publishRustRegistry: crates-io
enablePostProcessFile: true
globalProperties:
skipFormModel: false
enablePostProcessFile: true
2 changes: 2 additions & 0 deletions bin/configs/manual/rust-axum-petstore.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ generateAliasAsModel: true
additionalProperties:
hideGenerationTimestamp: "true"
packageName: petstore
globalProperties:
skipFormModel: false
enablePostProcessFile: true
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import org.openapitools.codegen.config.GlobalSettings;
import org.openapitools.codegen.examples.ExampleGenerator;
import org.openapitools.codegen.languages.PhpNextgenClientCodegen;
import org.openapitools.codegen.languages.RustAxumServerCodegen;
import org.openapitools.codegen.languages.RustServerCodegen;
import org.openapitools.codegen.meta.FeatureSet;
import org.openapitools.codegen.meta.GeneratorMetadata;
Expand Down Expand Up @@ -4742,7 +4743,7 @@ public CodegenOperation fromOperation(String path,
contentType = contentType.toLowerCase(Locale.ROOT);
}
if (contentType != null &&
(contentType.startsWith("application/x-www-form-urlencoded") ||
((!(this instanceof RustAxumServerCodegen) && contentType.startsWith("application/x-www-form-urlencoded")) ||
contentType.startsWith("multipart"))) {
// process form parameters
formParams = fromRequestBodyToFormParameters(requestBody, imports);
Expand Down

0 comments on commit 514c0d6

Please sign in to comment.