kevinswiber / postman2openapi

Convert a Postman collection to an OpenAPI definition.
Apache License 2.0
334 stars 51 forks source link

[tests]: equivalent path templates are created #8

Open MikeRalphson opened 4 years ago

MikeRalphson commented 4 years ago

Not an easy one to solve. Shows up in the fastly fixture where pathItem keys end either {name} or {old_name}. If you replace each path template section with {0}, {1}, {2} etc and compare the resultant keys, duplicates are found.

A relative path to an individual endpoint. The field name MUST begin with a forward slash (/). The path is appended (no relative URL resolution) to the expanded URL from the Server Object's url field in order to construct the full URL. Path templating is allowed. When matching URLs, concrete (non-templated) paths would be matched before their templated counterparts. Templated paths with the same hierarchy but different templated names MUST NOT exist as they are identical

Some tools (cough) append a dummy fragment id to disambiguate equivalent pathItem keys.

kevinswiber commented 4 years ago

This is something we can actually detect while parsing. My initial thought was to emit a warning that it exists. Is it more surprising to have an auto-fix or to prompt for manual post-processing?

MikeRalphson commented 4 years ago

I think you're right, maybe a warning. In APIs.guru we have an extension x-hasEquivalentPaths (https://github.com/APIs-guru/openapi-directory/wiki/specification-extensions#x-hasequivalentpaths) which we use to tag the output of other converters (like Google discovery format) to indicate we can suppress the validation error if needed.