-
-
Notifications
You must be signed in to change notification settings - Fork 233
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
bundle() incorrectly escapes certain characters in JSON pointers in $ref's #44
Comments
The short answer is that this is the correct behavior. There are actually three different specs at play here: JSON Pointer (RFC 6901), JSON Reference (Draft 3), and URI (RFC 3986). Whenever you create a JSON Reference ( |
Interesting -- thanks for the detailed response. Do you suppose there is a bug in the online swagger editor in that it's not decoding the strings correctly? |
Yeah, it looks like it. It appears that they aren't URL-decoding the A workaround would be to move your external file reference to the {
"paths": {
"/api/menus/{id}" : {
"get": {
"responses": {
"200": {
"schema": {
"$ref": "#/definitions/menu"
}
}
}
}
},
"/api/menus/{id}/tree": {
"get": {
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/menu"
}
}
}
}
}
},
"definitions": {
"menu": {
"$ref": "menu.json"
}
}
} That should cause the |
Thanks! I only ran into this problem when I started automating the building of the bundled swagger file -- for now I can manually define it as you described. FYI, I opened a bug on the Swagger Editor repo: swagger-api/swagger-editor#1430 |
This package is awesome, so thank you! However, I believe I have discovered a bug with the bundle() method when it creates a pointer to a location that contains special characters.
When I bundle my schema, I end up with something like this (reduced for simplicity):
The problematic line is this:
When I paste the bundled Swagger data into the online Swagger editor, it cannot resolve that reference (the error shows the line number). However, if I change
%7B
to{
and%7D
to}
, the reference works and the error goes away.The spec for JSON pointers is at https://tools.ietf.org/html/rfc6901 -- it's pretty heady, but I'm wondering if maybe things are in the weeds with the %x00-2E / %x30-7D / %x7F-10FFFF et al characters?
Is this a bug? Should
{
and}
remain unescaped?The text was updated successfully, but these errors were encountered: