-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OpenAPI 2.0/3.x.y - validation of Path Templating #3517
Comments
|
We need to attach the metadat to Then in linting function we can do following:
And that basically is what we want, to be able to access contextual This applies to OpenAPI 2.0/3.0.x/3.1.0 Addressed by #3532 |
This linting rule that validates if the template expressions defined within the path template are all present in the appropriate Parameter Objects. Refs #3517 Co-authored-by: Vladimír Gorej <vladimir.gorej@gmail.com>
No matches are now registered for template expressions defined inside query parameters. URLs with fragments are now supported, but no matches are registered for template expressiones defined inside fragments. Refs #3517
No matches are now registered for template expressions defined inside query parameters. URLs with fragments are now supported, but no matches are registered for template expressiones defined inside fragments. Refs #3517
We are currently not able to validate and resolve
Path Templating
. I have created low level parser, validator and resolver library for OpenAPI Path Templating here: https://github.com/char0n/openapi-path-templatingopenapi-path-templating
is applicable for: OpenAPI 2.0 and 3.x.y.We want to use it for every case related to
Path Templating
.Warning
openapi-path-templating
library doesn't handle computing appropriateParameter Object
s to be resolved against the template expression.I actually see two different linting rules here and I do understand and approach them differently (correct me if I'm wrong).
Rule 1
We want a linting rule that validates if the template expressions defined within the URL are all present in the appropriate
Parameter Objects
.Rule 2
We want a linting rule that validates that user did not forget to define template expressions for all the appropriate
Parameter Objects
.For the purpose of this implementation I will assume we're talking about Rule 1.
There are multiple layers that we need to implement to achieve the final goal described in Rule 1.
Low level
Path Templating
handlingI've already had a code for this on my local dev computer. I've consolidated the code and pushed with (along with the documentation) to https://github.com/char0n/openapi-path-templating. The library is not yet released, I will release it probably during today. The library handles all the low level complexities and corner cases of parsing, validating and resolving the Path Templating.
The library can distinguish if the URL contains Path Templating or not.
High level
Path Templating
handlingCollecting
Parameter Objects
So, what we need to do it to collect all
Parameter Objects
fromPath Item Object
directly mapped to URL withPath Templating
and allParameter Objects
from everyOperation Object
mapped fromPath Item Object
under theHTTP verb
. (I'll help you with querying those out from ApiDOM later).When we have all the
Parameter Objects
we have to apply following algorithms defined by OpenAPI:Applies to both
PathItem.paramters
andOperation.parameters
Applies to
Operation.parameters
So basically we'll have to create a
unique
function specific to list ofParameter Objects
or reuse the already implemented logic of normalize-parameters refractor plugin which already does this.Matching Path Templating with
Parameter Objects
Now we need to use https://github.com/char0n/openapi-path-templating to parse the relative URI Reference (with possible Path Templating) and match the parsed
template-expression
tokens against the collectedParameter Object
.And we must not forget the exception described in the OpenAPI excerpt, already mentioned above. If the
Path Item Object
is empty, the the Path Templating doesn't need to be matched with path template expressions. We'll just skip it. Emptiness of thePath Item Object
is defined by lack of all fixed fields (Specification Extensions MAY be present).OpenAPI excerpt
The text was updated successfully, but these errors were encountered: