kin-openapi icon indicating copy to clipboard operation
kin-openapi copied to clipboard

Server port does not validate enum.

Open alsals126 opened this issue 3 years ago • 0 comments

FIndRoute Does Not Check enum server port. Ports are specified by Server Variable Object, enumeration values that were not declared as default cannot use.

I referred to the example of https://swagger.io/specification/#server-object.

request

https://demo.gigantic-server.com:443/v2 (port 443 is not the specified default value.)

result

no matching operation was found

JSON

{
  "servers": [
    {
      "url": "https://{username}.gigantic-server.com:{port}/{basePath}",
      "description": "The production API server",
      "variables": {
        "username": {
          "default": "demo",
          "description": "this value is assigned by the service provider, in this example `gigantic-server.com`"
        },
        "port": {
          "enum": [
            "8443",
            "443"
          ],
          "default": "8443"
        },
        "basePath": {
          "default": "v2"
        }
      }
    }
  ]
}

Go
router, err := gorillamux.NewRouter(doc)
if err != nil {
   panic(err)
}

route, pathParams, err := router.FindRoute(req)
if err != nil {
   fmt.Println(err)  // error message 
   return
}

alsals126 avatar Aug 12 '22 02:08 alsals126