-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
[typescript-axios] handle uniqueItems in query and header parameters #8965
[typescript-axios] handle uniqueItems in query and header parameters #8965
Conversation
👍 Thanks for opening this issue! The team will review the labels and make any necessary changes. |
@@ -117,7 +127,12 @@ export const {{classname}}AxiosParamCreator = function (configuration?: Configur | |||
{{#headerParams}} | |||
{{#isArray}} | |||
if ({{paramName}}) { | |||
{{#uniqueItems}} | |||
let mapped = Array.from({{paramName}}).map(value => (<any>"{{{dataType}}}" !== "Set<string>") ? JSON.stringify(value) : (value || "")); |
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'm not 100% sure about the comparison here <any>"{{{dataType}}}" !== "Set<string>"
as I'm not sure what the comparison in the Array
case is supposed to do. If someone can verify that this is correct or let me know what the correct version is supposed to be, I would be grateful 😃
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 looks correct, I think the idea is to serialize the items of a non-string array/set
The commit appears bigger than it actually is due to the generated code from the additional typescript-axios config |
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.
LGTM
@@ -117,7 +127,12 @@ export const {{classname}}AxiosParamCreator = function (configuration?: Configur | |||
{{#headerParams}} | |||
{{#isArray}} | |||
if ({{paramName}}) { | |||
{{#uniqueItems}} | |||
let mapped = Array.from({{paramName}}).map(value => (<any>"{{{dataType}}}" !== "Set<string>") ? JSON.stringify(value) : (value || "")); |
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 looks correct, I think the idea is to serialize the items of a non-string array/set
@t-h-e thanks for your contribution. please re-generate the samples |
note: this PR is similar to #8695 |
add endpoint /fake/test-unique-paramters to petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml for demonstration
9aa72a5
to
ac11813
Compare
Fixes #6904
uniqueItems
for query and header parameter have not been handled correctlyadd endpoint /fake/test-unique-paramters to petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml and typescript-axios config for demonstration
@TiFu @taxpon @sebastianhaas @kenisteward @Vrolijkx @macjohnny @topce @akehir @petejohansonxo @amakhrov