Skip to content
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

Merged

Conversation

t-h-e
Copy link
Contributor

@t-h-e t-h-e commented Mar 12, 2021

Fixes #6904
uniqueItems for query and header parameter have not been handled correctly

add 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

@auto-labeler
Copy link

auto-labeler bot commented Mar 12, 2021

👍 Thanks for opening this issue!
🏷 I have applied any labels matching special text in your 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 || ""));
Copy link
Contributor Author

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 😃

Copy link
Member

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
Copy link
Contributor Author

t-h-e commented Mar 12, 2021

The commit appears bigger than it actually is due to the generated code from the additional typescript-axios config

Copy link
Member

@macjohnny macjohnny left a 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 || ""));
Copy link
Member

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

@macjohnny
Copy link
Member

@t-h-e thanks for your contribution. please re-generate the samples

@macjohnny
Copy link
Member

note: this PR is similar to #8695

@wing328 wing328 added this to the 5.1.1 milestone Mar 22, 2021
t-h-e and others added 3 commits March 22, 2021 12:36
add endpoint /fake/test-unique-paramters to petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml for demonstration
@t-h-e t-h-e force-pushed the fix_typescript-axios-uniqueitems-parameters branch from 9aa72a5 to ac11813 Compare March 22, 2021 15:31
@wing328 wing328 merged commit 7bf792a into OpenAPITools:master Apr 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] [Typescript-Axios] Sets are treated like Arrays
3 participants