zalando / intellij-swagger

A plugin to help you easily edit Swagger and OpenAPI specification files inside IntelliJ IDEA

Home Page:https://plugins.jetbrains.com/plugin/8347

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot parse Swagger JSON containing special characters

radarsh opened this issue · comments

We use JSON based Swagger files in our project and it's quite common to have lines such as:

"url": {
    "type": "string",
    "pattern": "^:https?:\/\/[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]$",
    "description": "A URL"
}

Unfortunately such properties are not parsed by the plugin and throws the below error:

Could not generate Swagger UI
YAML decoding problem: while scanning a double-quoted scalar
in 'reader', line 853, column 32:
"pattern": "^:https?:\/\/[-A-Za-z0-9+&@#/%? ... 
^
found unknown escape character /(47)
in 'reader', line 853, column 43:
...           "pattern": "^:https?:\/\/[-A-Za-z0-9+&@#/%?=~_|!:,.;]+ ... 
^

The same Swagger files have worked previously until a certain update to the plugin broke it.

Just to add, the same Swagger file works fine on editor.swagger.io when I choose the "Don't convert to YAML" option.