Skip to content

Conversation

@waterkip
Copy link
Contributor

@waterkip waterkip commented Aug 25, 2019

This changeset uses the directory name of the SWAGGER_JSON file to use
as a root for all the files that have the following {json,yml,yaml}
extension.

By doing this one can use a docker-compose.yml like so:

environment:
- "SWAGGER_JSON=/openapi/foo.yaml"
volumes:
- "./openapi:/openapi"

or run docker like described in the installation.md file:

docker run -p 80:8080 \
-e SWAGGER_JSON=/foo/swagger.json -v /bar:/foo swaggerapi/swagger-ui

Everything from /bar is mounted in /foo and /foo is than used by nginx
to serve it's openapi specification files.

Fixes: #5318, #5496, #4915

How Has This Been Tested?

I manually tested my changes by running docker-compose with the configuration described above and manually by running docker run -p 8081:8080 -e "SWAGGER_JSON=/app/zd.yaml" -v $(pwd)/openapi:/app swaggerapi/swagger-ui

Checklist

My PR contains...

  • No code changes (src/ is unmodified: changes to documentation, CI, metadata, etc.)
  • Dependency changes (any modification to dependencies in package.json)
  • Bug fixes (non-breaking change which fixes an issue)
  • Improvements (misc. changes to existing features)
  • Features (non-breaking change which adds functionality)

My changes...

  • are breaking changes to a public API (config options, System API, major UI change, etc).
  • are breaking changes to a private API (Redux, component props, utility functions, etc.).
  • are breaking changes to a developer API (npm script behavior changes, new dev system dependencies, etc).
  • are not breaking changes.

Documentation

  • My changes do not require a change to the project documentation.
  • My changes require a change to the project documentation.
  • If yes to above: I have updated the documentation accordingly.

Automated tests

  • My changes can not or do not need to be tested.
  • My changes can and should be tested by unit and/or integration tests.
  • If yes to above: I have added tests to cover my changes.
  • If yes to above: I have taken care to cover edge cases in my tests.
  • All new and existing tests passed.

@btkelly
Copy link

btkelly commented Dec 3, 2019

Is there a timeframe for merging this change into master and deployed? I would like to leverage this from the main DockerHub image to allow me to break my Swagger spec up into multiple files.

@stickgrinder
Copy link

Guys, any news on this? I tried this myself and it works like a charm. It allows me to break my huge API specs to separated files.

This is such a no-brainer that I wonder why this is not yet in master.

@waterkip waterkip force-pushed the swagger-root branch 2 times, most recently from 4fc895c to 26f9ffb Compare May 9, 2020 16:55
waterkip added 2 commits May 16, 2020 13:12
This changeset uses the directory name of the SWAGGER_JSON file to use
as a root for all the files that have the following {json,yml,yaml}
extension.

By doing this one can use a docker-compose.yml like so:

```
environment:
  - "SWAGGER_JSON=/openapi/zd.yaml"
volumes:
  - "./openapi:/openapi"
```

or run docker like described in the installation.md file:
```
docker run -p 80:8080 \
  -e SWAGGER_JSON=/foo/swagger.json -v /bar:/foo swaggerapi/swagger-ui
```

Everything from /bar is mounted in /foo and /foo is than used by nginx
to serve it's openapi specification files.

Fixes: swagger-api#5318, swagger-api#5496, swagger-api#4915

Signed-off-by: Wesley Schwengle <[email protected]>
@waterkip
Copy link
Contributor Author

Leave me a comment when you want to merge this so I can rebase it again. Rebasing every week is getting old.

@tim-lai tim-lai merged commit f353974 into swagger-api:master Jun 10, 2020
@tim-lai
Copy link
Contributor

tim-lai commented Jun 10, 2020

@waterkip Merged, thanks for contribution!

@vanhove
Copy link

vanhove commented Jun 15, 2020

It looks like this change is causing a bug. When defining BASE_URL environment variable, the docker image is not able to find the json/yaml file.

@waterkip
Copy link
Contributor Author

@vanhove Oops :) I'll have a look later today to see if I can reproduce and fix it.

@waterkip
Copy link
Contributor Author

@vanhove could you see if this resolves the issue for you? #6147

mattyb678 pushed a commit to mattyb678/swagger-ui that referenced this pull request Jun 24, 2020
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

Successfully merging this pull request may close these issues.

Models sections are not rendered if YAML file uses externally $ref.

6 participants