-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
[Rust-Axum] Allow use of array query params #20861
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| generatorName: rust-axum | ||
| outputDir: samples/server/petstore/rust-axum/output/rust-axum-array-params-test | ||
| inputSpec: modules/openapi-generator/src/test/resources/3_0/rust/rust-axum-array-params-test.yaml | ||
| templateDir: modules/openapi-generator/src/main/resources/rust-axum | ||
| generateAliasAsModel: true | ||
| additionalProperties: | ||
| hideGenerationTimestamp: "true" | ||
| packageName: rust-axum-array-params-test | ||
| globalProperties: | ||
| skipFormModel: false | ||
| enablePostProcessFile: true |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -207,7 +207,6 @@ use crate::{models, types::*}; | |
| #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] | ||
| pub struct {{{operationIdCamelCase}}}QueryParams { | ||
| {{#queryParams}} | ||
| {{#vendorExtensions}} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @tanadeau could you please explain why we need to remove
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This created the wrong context, and within it, the template couldn't get the correct values for |
||
| {{#description}} | ||
| /// {{{.}}} | ||
| {{/description}} | ||
|
|
@@ -266,6 +265,16 @@ use crate::{models, types::*}; | |
| {{/maxItems}} | ||
| )] | ||
| {{/hasValidation}} | ||
| {{#isArray}} | ||
| {{#isNullable}} | ||
| // Nullable array query parameters are not fully supported. | ||
| {{/isNullable}} | ||
| {{^required}} | ||
| #[serde(default)] | ||
| {{/required}} | ||
| pub {{{paramName}}}: {{{dataType}}}, | ||
| {{/isArray}} | ||
| {{^isArray}} | ||
| {{#required}} | ||
| pub {{{paramName}}}: {{#isNullable}}Nullable<{{/isNullable}}{{{dataType}}}{{#isNullable}}>{{/isNullable}}, | ||
| {{/required}} | ||
|
|
@@ -277,7 +286,7 @@ use crate::{models, types::*}; | |
| #[serde(skip_serializing_if="Option::is_none")] | ||
| pub {{{paramName}}}: Option<{{#isNullable}}Nullable<{{/isNullable}}{{{dataType}}}{{#isNullable}}>{{/isNullable}}>, | ||
| {{/required}} | ||
| {{/vendorExtensions}} | ||
| {{/isArray}} | ||
| {{/queryParams}} | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| openapi: 3.0.1 | ||
| info: | ||
| title: Test to check that array query params are rendered correctly. | ||
| version: 0.0.1 | ||
| paths: | ||
| /endpoint: | ||
| get: | ||
| description: Some endpoint. | ||
| parameters: | ||
| - name: numbers | ||
| in: query | ||
| description: Some numbers. | ||
| schema: | ||
| type: array | ||
| items: | ||
| type: number | ||
| - name: multiplier | ||
| in: query | ||
| description: Multipler for sum. | ||
| schema: | ||
| type: number | ||
| responses: | ||
| '200': | ||
| description: OK. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| 7.12.0-SNAPSHOT | ||
| 7.13.0-SNAPSHOT |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| 7.12.0-SNAPSHOT | ||
| 7.13.0-SNAPSHOT |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| 7.12.0-SNAPSHOT | ||
| 7.13.0-SNAPSHOT |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| 7.12.0-SNAPSHOT | ||
| 7.13.0-SNAPSHOT |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| 7.12.0-SNAPSHOT | ||
| 7.13.0-SNAPSHOT |
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.
could you please also explain why we need to replace
serde_urlencodedwithserde_html_form?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.
serde_urlencodedexplicitly doesn't support array query params and will never do so. See nox/serde_urlencoded#52 for example.serde_html_formis a fork with that in mind. See item 2 in the PR description.