muonsoft/openapi-mock

url in spec can't be parsed

martinreber opened this issue · 1 comments

Hi, first I would like to thanks for this easy to use mock server for the openAPI spec.
I use the version based on the docker image.

Im facing the following issue when I start the mock server with docker-compose up:

docker-compose up                                                                                                                  
Docker Compose is now in the Docker CLI, try `docker compose up`

Starting openapi_mock ... done
Attaching to openapi_mock
openapi_mock    | time="2021-06-17T12:11:08Z" level=info msg="OpenAPI specification was successfully loaded from 'https://artifactory.swisscom.com/artifactory/fren-generic-local/panda-v2-dev.yaml'"
openapi_mock    | panic: Validating Swagger failed: Error when validating Servers: Variable 'URL' must be a non-empty JSON string
openapi_mock    | 
openapi_mock    | goroutine 1 [running]:
openapi_mock    | github.com/getkin/kin-openapi/openapi3filter.(*Router).WithSwagger(...)
openapi_mock    |       /go/pkg/mod/github.com/getkin/kin-openapi@v0.9.0/openapi3filter/router.go:83
openapi_mock    | github.com/muonsoft/openapi-mock/internal/application/container.(*serviceContainer).CreateHTTPServer(0xc000291ec0, 0xa28de0, 0xc000291ec0)
openapi_mock    |       /project/internal/application/container/serviceContainer.go:105 +0xd41
openapi_mock    | github.com/muonsoft/openapi-mock/internal/application/console.createConsoleCommand(0x93c062, 0x5, 0xc000322400, 0x0, 0x0)
openapi_mock    |       /project/internal/application/console/CreateCommand.go:74 +0x7d
openapi_mock    | github.com/muonsoft/openapi-mock/internal/application/console.CreateCommand(0xc00000c0b0, 0x1, 0x1, 0x7, 0xc00031ff18, 0x441f97, 0xd8f560)
openapi_mock    |       /project/internal/application/console/CreateCommand.go:29 +0x1c7
openapi_mock    | main.main()
openapi_mock    |       /project/cmd/openapi-mock/main.go:22 +0x1a2
openapi_mock exited with code 2

docker-compose.yaml

version: '3.0'

services:
  openapi_mock:
    container_name: openapi_mock
    image: muonsoft/openapi-mock
    environment:
      OPENAPI_MOCK_SPECIFICATION_URL: 'https://repository/spec.yaml'
      OPENAPI_MOCK_CORS_ENABLED: "1"
      OPENAPI_MOCK_DEBUG: "1"
      OPENAPI_MOCK_USE_EXAMPLES: "if_present"

    ports:
      - "8888:8080"

openAPI spec, server section:

servers:
  - url: 'http://localhost:8888'
    description: Application mock server (must be started locally)

It tried to use single, double or none quotes at all for the url, but nothing is working.

@martinreber thanks for the report! The issue is fixed in v0.3.1.