widdershins icon indicating copy to clipboard operation
widdershins copied to clipboard

Does widdershins support Open API Extensions, like Amazon AWS API Gateway?

Open shrirambalaji opened this issue 4 years ago • 7 comments

I'm currently using widdershins to convert an openapi-3.0 spec, into a slate/shin compatible markdown file. The cli throws the following error:

Invalid Variable Name "any+" in "{any+}"
Error: Invalid Variable Name "any+" in "{any+}"

It looks to me that the Error is being thrown because of using AWS API Gateway OpenAPI Extensions - https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-swagger-extensions.html like these in the spec.

Is it somehow possible for widdershins to either omit those routes in the spec, or specify how to handle them? I was trying to understand if it's possible, but I couldnt clearly identify that from the docs. It'd be great if you could point me in the right direction.

shrirambalaji avatar May 06 '20 19:05 shrirambalaji

Widdershins supports specification (aka vendor) extensions fine (in that it will ignore them). What seems to be happening here is that you may have a character in your in:path parameter (+) which is confusing the urijs library which is trying to construct an RFC6570 URL template.

However, I've tried and I can't reproduce your error message without your input definition and the command-line or options you're using. Please could you supply a gist showing what you're working with?

MikeRalphson avatar May 07 '20 08:05 MikeRalphson

@MikeRalphson Here's a Gist, the any+ seems to be the problem. The OpenAPI Spec is auto generated from AWS API Gateway.

shrirambalaji avatar May 14 '20 15:05 shrirambalaji

@MikeRalphson fwiw, https://editor.swagger.io also shows an error for the above Gist, but the routes do show up in the UI. I'm not entirely sure, if this is of any use for you to debug, but just wanted to mention it here.

image

shrirambalaji avatar May 14 '20 15:05 shrirambalaji

Do you know what the + in the {any+} URL template is supposed to mean? According to RFC6570 the + "operator" can only appear at the start of a template, not at the end.

It is a combination of the fact that this {any+} template exists in the path, but a corresponding any+ in:path parameter does not exist which is causing the code to fail.

MikeRalphson avatar May 15 '20 10:05 MikeRalphson

@MikeRalphson In this case, the {any+} captures undeclared path variables that are passed to the subresource chain, and are used to handle 404s. I believe there's also {proxy+}, wherein:

{proxy+} is a greedy path in which the entire sub-resource chain is passed to your backend as path variables.

(https://example.com/{proxy+} captures all of these sub-resources as path variables)

shrirambalaji avatar May 17 '20 06:05 shrirambalaji

@MikeRalphson somewhat related to this: What would be the ideal way of defining how widdershins handles custom extensions, without ignoring them? A simple use case I have is defining an end-of-availability extension say like "x-deprecated-by", for a GET /endpoint and show it in the markdown generated by widdershins. AFAIK OpenAPI doesnt support this now as per https://github.com/OAI/OpenAPI-Specification/issues/782

shrirambalaji avatar Jul 16 '20 17:07 shrirambalaji

Extensions should be accessible in the templates (i.e. if you modify or override them) as the objects passed to them in the data object are usually just decorated versions of what's in the input document. E.g. data.operation (see the template README), and the way the x-code-samples extension is referenced in operation.dot

{{? data.options.codeSamples || data.operation["x-code-samples"] }}

MikeRalphson avatar Jul 16 '20 17:07 MikeRalphson