Haufe-Lexware / api-style-guide

Haufe API Style Guide
https://haufe-lexware.gitbooks.io/haufe-api-styleguide/content/
Apache License 2.0
233 stars 79 forks source link

Update filtering-sorting-field-selection-and-paging.md #32

Closed jorgecara closed 7 years ago

jorgecara commented 7 years ago

Sometimes the same parameter must have a different behaviour. Without any % it does equality and surrounded by % it does a like comparison.

hlgr360 commented 7 years ago

Sorry, I disagree with this change proposal. The W3 standard is very explicit about the use of %

https://www.w3.org/Addressing/URL/4_URI_Recommentations.html

The percent sign The percent sign ("%", ASCII 25 hex) is used as the escape character in the encoding scheme and is never allowed for anything else.

I tried to find alternative schemes but even the use of '*' - while used by some - is not really spec conform:

Other reserved characters The asterisk ("*", ASCII 2A hex) and exclamation mark ("!" , ASCII 21 hex) are reserved for use as having special signifiance within specific schemes.

Here is the section on the RFC https://tools.ietf.org/html/rfc3986#page-12

There are some API's wich do allow the use of 'asterix' as wildcard even though strictly speaking '*' is a reserved sub_delim according to the RFC.

The most appropriate would be to URL encode the wildcard character as part of your search term. Would that work for you?

jorgecara commented 7 years ago

Sure it would. Actually we are already enconding it so the url would really look like: GET /cars?type=%25van%25

hlgr360 commented 7 years ago

Why not use a syntax everyone understands and encode asterix. GET /cars?type=%2Avan%2A

hlgr360 commented 7 years ago

IMHO %van% is less intuitive than *van*

jorgecara commented 7 years ago

It works for us as well. Should we then agree on using '*' as a wildcard GET /cars?type=%2Avan%2A