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

OpenAPI - Single Query Param Key With Multiple Value #367

Closed
ghost opened this issue Aug 15, 2022 · 6 comments
Closed

OpenAPI - Single Query Param Key With Multiple Value #367

ghost opened this issue Aug 15, 2022 · 6 comments
Labels
question Further information is requested

Comments

@ghost
Copy link

ghost commented Aug 15, 2022

Hi,

Firstly thank you for this amazing project. It works really well and makes performant OpenAPI possible which is awesome. I'm trying to implement sorting. Something along the lines of https://specs.openstack.org/openstack/api-wg/guidelines/pagination_filter_sort.html#sorting

Using param::Query<Vec<String>> does allow multiple values through swagger ui however they conflict by creating a key for each value as explode is set to true by default and I only get access to the last entry of this vec. How would I set explode to false? https://stackoverflow.com/questions/62527254/how-does-open-api-3-0-support-a-single-query-param-key-with-multiple-values

I can set the query param as a string and manually split the comma separated value entered but would rather it is properly documented in swagger ui as an array.

@ghost ghost added the question Further information is requested label Aug 15, 2022
@sunli829
Copy link
Collaborator

This is not supported yet, I will add it later.

@ghost
Copy link
Author

ghost commented Aug 15, 2022

OK thanks will use a string for now then and update it when it's added.

@banool
Copy link
Contributor

banool commented Aug 15, 2022

Adding this feature would probably also make this easier: #342

@sunli829
Copy link
Collaborator

Released in v2.0.9

async fn test(&self, #[oai(explode = false)] v: Query<Vec<i32>>) {

@ghost
Copy link
Author

ghost commented Aug 16, 2022

Wow that was quick. Tested it out. Works perfectly. This project never ceases to amaze me. Thank you very much!

@mathiversen
Copy link

mathiversen commented Aug 22, 2022

I tried to copy paste this but i get the following error when i run it locally:
curl "http://localhost:3000?v=1,2,3" => invalid type: sequence, expected i32
Not sure what I'm doing wrong? 🤔

Edit: I was using the wrong Query import.

@sunli829 sunli829 closed this as completed Sep 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants