-
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: linting rule for checking if parameter is defined within the path template #3546
Comments
All right, so our first order of business if to determine if the Path Item Object parametersWe're specifically talking about 1. Determining Path Item relationshipWe first need to determine if Predicate will look like this: const isInPathItemElement = isArrayElement(paramerElement.parent) && includesClasses(['path-item-parameters'], parameterElement.parent)
const pathItemElement = parameterElement.parent.parent.parent Tip We can avoid step 1. and all the following steps by immediately looking into 2. Determining if Path Item is part of path templatingTo determine if the found Predicate will look like this: const isPathItemPartOfPathTemplating = isStringElement(pathItemElement.meta.get('path');
const pathTemplate = toValue(pathItemElement.meta.get('path')); 3. Determining if Parameter Object is matched with path templatingThis is a bit tricky. We'll have to use openapi-path-templating to parse the path template into the AST: This path template
If the Only after we have the above implementation, it makes sense to focus on |
Operation Object parametersWe're specifically talking about 1. Determining Operation Object relationshipWe first need to determine if Predicate will look like this: const isInOperationElement = isArrayElement(paramerElement.parent) && includesClasses(['operation-parameters'], parameterElement.parent)
const pathItemElement = parameterElement.parent.parent.parent.parent.parent // needs to be verified by you We're already have Tip We can avoid step 1. and all the following steps by immediately looking into 2. Determining if Path Item is part of path templatingTo determine if the found Predicate will look like this: const isPathItemPartOfPathTemplating = isStringElement(pathItemElement.meta.get('path');
const pathTemplate = toValue(pathItemElement.meta.get('path')); 3. Determining if Parameter Object is matched with path templatingThis is a bit tricky. We'll have to use openapi-path-templating to parse the path template into the AST: This path template
If the |
Closed by #3629 |
Originally defined as Rule 2 in #3517
We want a linting rule that validates that user did not forget to define template expressions for all the appropriate Parameter Objects.
This linting rule is going to be attached to
Parameter Object
and not topath-template
meta class so that theParameter Objects
gets highlighted in red if linting rule fails.This is going to be a bit tricky as
Parameter Object
first needs to establish if it has been defined forPath Item Object
orOperation Object
that is attached toPath Item Object
viahttp-verb
.Next it needs to check if it
location
is withinpath
orquery
.Next is needs to check if the
path template
attached to it'sPath Item Object
contains the template expression matchingParameter.name
.The text was updated successfully, but these errors were encountered: