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

Validating query arguments of type array #182

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

tyamahori
Copy link

@tyamahori tyamahori commented Dec 17, 2022

ref #181

Hi.

this pr makes it possible to accept query arguments of an array.

For example.

https://example.com?someKey[]=value1&someKey[]=value2

We will be able to validate someKey[].

@tyamahori tyamahori changed the title acce Accepting query parameter of array. Dec 17, 2022
@tyamahori tyamahori changed the title Accepting query parameter of array. Validating query arguments of type array Dec 17, 2022
@tyamahori tyamahori marked this pull request as ready for review December 17, 2022 14:16
Copy link

@katsumi-kato-LITALICO katsumi-kato-LITALICO left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I approve by mistake!

@scaytrase
Copy link
Member

@tyamahori Hi, same question as here #162 (comment)

Isn't this notation valid only in deepObject serialization form ? I think we need to check this explicitly here

@tyamahori
Copy link
Author

@scaytrase
Hi, thank you for your comment.

This notation is valid if a query string is paramName[]=value1&paramName[]=value2&....

deepObject – simple non-nested objects are serialized as paramName[prop1]=value1&paramName[prop2]=value2&.... The behavior for nested objects and arrays is undefined.

Do you mean, you think paramName[prop1]=value1&paramName[prop2]=value2&.... should be checked ?

@scaytrase
Copy link
Member

scaytrase commented Jan 28, 2023

Do you mean, you think paramName[prop1]=value1&paramName[prop2]=value2&.... should be checked ?

no, I mean that deafult serealization method is form + explode which clearly shows the example for array values

image

/users?id=3&id=4&id=5

So if you want to provide query args in another format - you should specify another serialization style in your schema. From given styles I see deepObject as the most suitable one here

https://swagger.io/docs/specification/serialization/

They specify n\a for array example for deepObject, but I think prop[]=val1&prop[]=val2 notation is OK here

Copy link
Member

@scaytrase scaytrase left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spec for test doesn't match test data

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants