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

Why is a propertyName with suffix [] added to search filter when match type is exact? #1985

Closed
Bouwdie opened this issue May 30, 2018 · 5 comments
Labels

Comments

@Bouwdie
Copy link

Bouwdie commented May 30, 2018

if (self::STRATEGY_EXACT === $strategy) {

Can anyone explain me why a new property-name with suffix [] is added to the list of property descriptions when the match-type is exact (or when matching an association? Probably i am missing something very obvious here, but i could not deduct this from the existing documentation 🔢

@teohhanhui
Copy link
Contributor

teohhanhui commented May 30, 2018

I think the documentation about the support for multiple values was lost somewhere along the way... But basically, you could do for example:

/books?author[]=/authors/1&author[]=/authors/2

The effect is equivalent to the SQL IN operator.

@teohhanhui
Copy link
Contributor

teohhanhui commented May 30, 2018

Or perhaps it was never properly documented? But it's been around for a long time: #500 (comment) 😆

@Bouwdie
Copy link
Author

Bouwdie commented Jun 5, 2018

@teohhanhui Thanks for your answer (and sorry for my late reply 😋 ), it does make sense to be able to send in multiple values 👍 .

The swagger definition now contains the two definitions for the same parameter as well, where they are both the same scalar type. If a client is generated this give a pretty weird method signature (i.m.o). Your example would become getBooks(String author1, String author2); i would expect a signature getBooks(String author, List authors), but if multiple values are allowed why not just use the list getBooks(List authors) since they are filtering the same field it would make sense.

  • Shouldn't the generated swagger type for the multi-value scalar be an array?
  • Is it an idea to make the behavior of the generation of the two parameters configurable (like list-only, single-only or both)?

@dunglas
Copy link
Member

dunglas commented Jun 5, 2018

Shouldn't the generated swagger type for the multi-value scalar be an array?

We must fix our Swagger generator to use collectionFormat: multi: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#parameterCollectionFormat

We'll need to document both parameter foo and foo[] because the brackets notation is PHP-specific. Swagger considers both parameters as different ones.

Is it an idea to make the behavior of the generation of the two parameters configurable (like list-only, single-only or both)?

Would be nice.

@alanpoulain
Copy link
Member

Closed in favor of: api-platform/docs#601

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

No branches or pull requests

4 participants