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

Quotation marks in example values of the field filter cause a syntax error in Swagger UI #111

Closed
bonaparten opened this issue Feb 4, 2021 · 5 comments · Fixed by #112
Closed
Assignees
Labels
bug Something isn't working documentation Improvements or additions to documentation
Milestone

Comments

@bonaparten
Copy link
Contributor

bonaparten commented Feb 4, 2021

In Swagger UI, in the endpoint /elements/count/ratio quotation marks in the example value of the field filter2 cause a syntax error.

We should also take a look at the example values in other endpoints.

@bonaparten bonaparten added this to the 1.4 milestone Feb 4, 2021
@FabiKo117
Copy link
Contributor

FabiKo117 commented Feb 4, 2021

@bonaparten please also give an example of the request or a link to the position where you found it :)

I checked it now and indeed, the escaping of the double quotes is missing in this swagger example (you'd have to open up then the 'count' tab to get to the correct endpoint..).

But is also seems like now even with escaping, the request does not run through, e.g. look at this example:
https://api.ohsome.org/v1/elements/count/ratio?bboxes=8.625,49.3711,8.7334,49.4397&time=2014-01-01/2017-01-01/P1Y&filter=type:node and \"addr:housenumber=*\"&filter2=type:way&showMetadata=yes

Am I doing something wrong here @tyrasd?

@FabiKo117 FabiKo117 added the bug Something isn't working label Feb 4, 2021
@tyrasd
Copy link
Member

tyrasd commented Feb 4, 2021

I think the quote marks should not be there in the first place. this would be the correct filter: type:node and addr:housenumber=*, or if you really want to quote it, then like this: type:node and "addr:housenumber"=*

@tyrasd tyrasd added the documentation Improvements or additions to documentation label Feb 4, 2021
@FabiKo117
Copy link
Contributor

Ok yes I am blind.. the marks would just be around the key, not the whole tag. And true, they would not be necessary for this example.

Still, in the docs it's recommended to escape the quotes, but e.g. the following request is not working for me:
https://api.ohsome.org/v1/elements/count/ratio?bboxes=8.625,49.3711,8.7334,49.4397&time=2014-01-01/2017-01-01/P1Y&filter=\"addr:housenumber\"=*&filter2=type:way&showMetadata=yes
It works though if I use it without the escape sign. So are quotes now escaped automatically?

@tyrasd
Copy link
Member

tyrasd commented Feb 4, 2021

Still, in the docs it's recommended to escape the quotes

Do you mean here: https://docs.ohsome.org/ohsome-api/v1/filter.html#special-characters-whitespace?

Escape sequences can be used to represent a literal double-quote character ", while a literal backslash is written as \.

This refers to when you want to search for tags which have a " character in their key or value. One would need to escape those " so that they are not mistaken with the quotation marks which are for example used to define strings with whitespaces:

  • name="Heidelberger Brückenaffe" -> " used as quote mark
  • name="Universität \"Ruperto Carola\" Heidelberg" -> literal " within a string needs to be escaped

//edit

the following [filter] is not working for me: \"addr:housenumber\"

escape sequences only work in strings with quote marks. See the documentation:

Allowed characters are: the letters a-z and A-Z, digits, underscore,dashes and colons. When filtering by tags with any other characters in their key or value, these strings need to be supplied as double-quoted strings […]. Escape sequences can be used to represent a literal double-quote character \", while a literal backslash is written as \\.

So, if you want to filter by the tag key "addr:housenumber" (including the "), your filter needs to be written like this:

  • "\"addr:housenumber\""=*

//edit2:

It works though if I use it without the escape sign. So are quotes now escaped automatically?

No, everything works as documented. Let me repeat: "addr:housenumber"=* does something quite different from "\"addr:housenumber\""=*: in the first case you query for everything with a tag with the key addr:housenumber, while in the second case you filter everything with a tag with the key "addr:housenumber" (including the quote marks).

@FabiKo117
Copy link
Contributor

I see.. yes that makes sense, sorry for the missunderstanding. So we would only have to fix then the suggested filter value in the swagger example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants