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

Can the docker container load the OpenAPI YAML specification from a local file #50

Open
dragonjuggler opened this issue Sep 18, 2020 · 4 comments

Comments

@dragonjuggler
Copy link

Hi.

It looks like the docker version of this requires specifying a URL to load the YAML specification. I know that the container will not have access to a local file on the host, but has any method been looked into that would allow that? For example, having a configuration service or admin service for the docker container which would allow "setting" the specification via a browser?

The docker version is more desirable, since nothing really needs to be installed, but serving up a YAML spec from a web service is not desirable (during development, the file will only be local).

Thanks.

-Mark

@strider2038
Copy link
Collaborator

Hello, @dragonjuggler !

You can use valid file path instead of web URL. To share your local config file with the running container you have to use docker volume. See example of docker-compose config below.

version: '3.0'

services:
  openapi_mock:
    container_name: openapi_mock
    image: muonsoft/openapi-mock
    environment:
      OPENAPI_MOCK_SPECIFICATION_URL: '/app/petstore.yaml'
    volumes:
      - ./examples/petstore.yaml:/app/petstore.yaml
    ports:
      - "8080:8080"

@dragonjuggler
Copy link
Author

I can give this a try. How can you supply other options to the container? For example, for the standalone executable, I had to set cors_enabled to true to get things to work in my environment. And how can you get debug/trace information from the container when something doesn't work?

I ran into a couple of different issues running the command line version. Would you like me to create a separate issue for those?

@dragonjuggler
Copy link
Author

Never mind about the configuration - I figured it out. All the configuration environment variables need to be supplied in the docker-compose file. This plus your earlier response would be useful to have in the documentation.

@dragonjuggler
Copy link
Author

Ok. I ran into a few wrinkles:

  1. In the servers definition, using a URL of "http://localhost:9090" caused an error. It required a trailing / character in the URL.
  2. Attempting to use https resulted in an SSL error from curl: curl: (35) error:1408F10B:SSL routines:ssl3_get_record:wrong version number
  3. Attempting to use server variables did not work.

For #3, I tried the following definition:
servers:

But trying to access that URL results in an HTTP 404 Not found.

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

2 participants