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

Swagger UI not able to handle URI's with the @ symbol #956

Closed
banichols opened this issue Feb 24, 2015 · 7 comments
Closed

Swagger UI not able to handle URI's with the @ symbol #956

banichols opened this issue Feb 24, 2015 · 7 comments
Assignees
Milestone

Comments

@banichols
Copy link

I'm working on a JAX-RS suite with endpoints that have an @ symbol in their URI. It appears that swagger is able to generate valid JSON to represent these endpoints, but swagger-ui fails when attempting to read them.

Example swagger JSON output that fails in swagger-ui:

http://localhost:8585/v1/api/api-docs/people/@me
{
    "apiVersion": "1.0.0",
    "swaggerVersion": "1.2",
    "basePath": "http://localhost:8585/v1/api",
    "resourcePath": "/people/@me",
    "produces": [
        "application/xml",
        "application/json"
    ],
    "consumes": [
        "application/xml",
        "application/json"
    ],
    "apis": [
        {
            "path": "/people/@me/profile",
            "operations": [
                {
                    "method": "GET",
                    "summary": "Get profile for a person.",
                    "type": "void",
                    "nickname": "getSlimProfile",
                    "produces": [
                        "application/xml",
                        "application/json"
                    ],
                    "parameters": [
                        {
                            "name": "X-Person-ID",
                            "required": false,
                            "type": "integer",
                            "format": "int64",
                            "paramType": "header",
                            "allowMultiple": false
                        }
                    ]
                }
            ]
        }
    ]
}

The error displayed in the UI is: "Unable to read api '@me' from path http://localhost:8585/v1/api/api-docs/people/@me (server returned undefined)"

Note: Swagger-UI works for my suite as long as any endpoints with an @ sign are left out of the generated swagger JSON.

@fehguy
Copy link
Contributor

fehguy commented Feb 25, 2015

Hi, can you please show a screenshot of the network panel?

@banichols
Copy link
Author

From Chrome's javascript panel:

swagger-ui-error

Note that I am running swagger-ui 2.0.24

@fehguy
Copy link
Contributor

fehguy commented Feb 25, 2015

This has been fixed in swagger-ui 2.1.x-M1. Can you please upgrade and report back?

@banichols
Copy link
Author

I pulled the latest from master, and am still seeing the same behavior:

swagger-ui-2 1 x-m1-error

@fehguy
Copy link
Contributor

fehguy commented Feb 26, 2015

Hi, you are correct, it is actually not fixed for paths. It is fixed for parameters though.

The underlying issue is in the parseUri function that is being used in the underlying shred library. Until that is fixed (it's the world's ugliest regex ), you can work around it by using jQuery when initializing swagger ui:

window.swaggerUi = new SwaggerUi({
  url: url,
  useJQuery: true,

@fehguy fehguy added this to the v2.1-M2 milestone Feb 26, 2015
@banichols
Copy link
Author

I've confirmed that the "useJQuery: true" workaround does remedy the issue

@mohsen1
Copy link
Contributor

mohsen1 commented Mar 3, 2015

It's a bug in SwaggerJS. swagger-api/swagger-js#267. Please look for resolution there.

@mohsen1 mohsen1 closed this as completed Mar 3, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants