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

Allow empty host #86

Closed
rmpestano opened this issue Dec 21, 2016 · 2 comments
Closed

Allow empty host #86

rmpestano opened this issue Dec 21, 2016 · 2 comments

Comments

@rmpestano
Copy link
Contributor

rmpestano commented Dec 21, 2016

Using empty host in swagger backend ( "host":"") helps when using Swagger UI because it automatically resolves the host URL (via window.location) and it makes it easier to use swagger across multiple hosts/environments

@rmpestano
Copy link
Contributor Author

rmpestano commented Dec 21, 2016

Also, to make it working on multiple hosts without bothering with deployedDomain I had to change swagger backend to append application root here: https://github.com/sdaschner/jaxrs-analyzer/blob/master/src/main/java/com/sebastian_daschner/jaxrs_analyzer/backend/swagger/SwaggerBackend.java#L100

Changed to:

.add("host", options.getDomain())
.add("basePath", '/'+projectName+"/" + resources.getBasePath())

It is needed because host is empty so swaggerUI will resolve it based on url and append basePath to make requests.

Here is my swagger.json:

    "swagger":"2.0",
    "info":{
        "version":"1.0.0-SNAPSHOT",
        "title":"apm-arq4"
    },
    "host":"",
    "basePath":"/apm-arq4/rest",
    "schemes":[
        "http",
        "https"
    ],
    "tags":[
        "files",
        "gci",
        "turmas"
    ],
    "paths":{
        "/files":{
            "get":{
                "consumes":[
                ],
...
...

In my opinion this is the simplest way to handle multiple hosts in swaggerUI.

WDYT?

@rmpestano
Copy link
Contributor Author

closing as it duplicates #42

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant