oapi-codegen icon indicating copy to clipboard operation
oapi-codegen copied to clipboard

Panic invalid port with Server Variable Object

Open PlusMinus0 opened this issue 3 years ago • 1 comments

According to this the following should be a legal spec:

servers:
  - url: http://localhost:{port}/v1
    description: The local test server
    variables:
      port:
        default: '8080'

however, the oapi validate middleware throws an error:

panic: parse "http://localhost:--------------------------------------------------port__________________________________________________/v1": invalid port ":--------------------------------------------------port__________________________________________________" after host

github.com/deepmap/oapi-codegen/pkg/middleware.OapiRequestValidatorWithOptions(0xaf7600?, 0x0)
	/home/matthias/go/pkg/mod/github.com/deepmap/[email protected]/pkg/middleware/oapi_validate.go:72 +0xf9
github.com/deepmap/oapi-codegen/pkg/middleware.OapiRequestValidator(...)
	/home/matthias/go/pkg/mod/github.com/deepmap/[email protected]/pkg/middleware/oapi_validate.go:56

PlusMinus0 avatar May 17 '22 13:05 PlusMinus0

This is an error from a dependency of ours, here: https://github.com/deepmap/oapi-codegen/blob/master/pkg/middleware/oapi_validate.go#L76

We use: https://github.com/getkin/kin-openapi/tree/master/routers/gorillamux

Please open an issue with the kin-openapi project.

deepmap-marcinr avatar May 18 '22 23:05 deepmap-marcinr