philosowaffle / vs-openapi-designer

OpenApi Designer Extension for VS Code
https://marketplace.visualstudio.com/items?itemName=philosowaffle.openapi-designer
GNU General Public License v3.0
15 stars 2 forks source link

Add compatibility for Path templating #25

Closed NathanHuisman closed 5 years ago

NathanHuisman commented 5 years ago

The official specification describes:

There are There are four possible parameter locations specified by the in field:

  • path - Used together with Path Templating, where the parameter value is actually part of the operation's URL. This does not include the host or base path of the API. For example, in /items/{itemId}, the path parameter is itemId.
  • query - Parameters that are appended to the URL. For example, in /items?id=###, the query parameter is id.
  • header - Custom headers that are expected as part of the request. Note that RFC7230 states header names are case insensitive.
  • cookie - Used to pass a specific cookie value to the API.

(here)

while I get an error:

Schema error at paths['/auth/{endpoint}'].get.parameters[0].in should be equal to one of the allowed values allowedValues: query, header, cookie Jump to line 117

So this implementation only supports the query, header, and cookie values, and not the path parameter type I use this a lot, so it would be nice if it would be added.

philosowaffle commented 5 years ago

Schema validation is provided by the official swagger-editor-dist and is not managed by this project.

Without an example schema provided it is difficult to try and recreate what you may be encountering. However, I did find this open issue on the swagger-editor-dist that seems related to what you are seeing. Specifically you may find this comment helpful.

As per the docs:

required - Determines whether this parameter is mandatory. If the parameter location is "path", this property is REQUIRED and its value MUST be true. Otherwise, the property MAY be included and its default value is false.

When I set required to FALSE, I get the error you described, but if I set it to TRUE, then the error message goes away.

Ultimately, this misleading error message will need to be resolved by the swagger-editor-dist project.

NathanHuisman commented 5 years ago

It appears this was the problem, I didn't know the schema validation was provided by swagger-editor-dist. I couldn't find where this error message was from, so I assumed it was an issue of this implementation. My apologies for not understanding this correctly