You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
constensureAllDefinedPathParamsAreUsedInPath=(path,params,expected,results)=>{for(constpofObject.keys(params)){if(!params[p]){continue;}if(!expected.includes(p)){constresPath=params[p];results.push(generateResult(`Parameter "${p}" must be used in path "${path}".`,resPath));}}};
In the function above the expected argument is empty for the endpoint in question. The function is called by oasPathParams(path) function here
functionoasPathParam(paths){/* ... */constpathElements=[];letmatch;while((match=pathRegex.exec(path))){constp=match[0].replace(/[{}?*;]/g,'');if(pathElements.includes(p)){results.push(generateResult(`Path "${path}" must not use parameter "{${p}}" multiple times.`,['paths',path]));}else{pathElements.push(p);}}/* ... */ensureAllExpectedParamsInPathAreDefined(path,definedParams,pathElements,operationPath,results);}
When running the endpoint path in question isn't validated against the regex and isn't added to the pathElements array, which is then passed through as the 'expected' path params object which raises the error.
The regex defined here doesn't allow for the {*} to be defined. It is only looking for alphanumber characters and -.
Proof that this endpoint does not pass the regex can be found here
This can be fixed by adding * to the regex.
Additional context
This error relates to fastify-swagger generating the documentation/static/{} endpoint for some other people this may be /docs/static/{}
Any one dealing with this error can modify their .spectral.yaml file to be.
The text was updated successfully, but these errors were encountered:
DanCRichards
changed the title
OpenAPI Spec Rules wildcard / {*} not accepted as a path param
OpenAPI Spec Rules wildcard "*" is not accepted as a path param.
Jun 27, 2024
There are two pieces.
One, Path Templates are a little vague, but wildcards that greedily capture whole paths aren't supported.
Two is that names of parameters, within the curlies {}have to be percent encoded. I don't think this ticket is about naming the path segment * but if it were, then it would need to be... /documentation/static/{%2A} and have a parameter named %2A :D
Going to close this out as expected behaviour.
If folks are interested in weighing in on the Path Template, feel free to head over to https://github.com/OAI/OpenAPI-Specification
Describe the bug
The spectral:oas ruleset does not allow for {*} to be included within the path params.
To Reproduce
npx spectral lint openapi.yml -D
error path-params Parameter "*" must be used in path "/documentation/static/{*}". paths./documentation/something/{*}.head.parameters[0]
Expected behavior
I would expect that {*} is an accepted path param
Screenshots
Problematic Code
All of this code is in oasPathParam.js
Code raising error. here
In the function above the expected argument is empty for the endpoint in question. The function is called by oasPathParams(path) function here
When running the endpoint path in question isn't validated against the regex and isn't added to the
pathElements
array, which is then passed through as the 'expected' path params object which raises the error.The regex defined here doesn't allow for the {*} to be defined. It is only looking for alphanumber characters and -.
Proof that this endpoint does not pass the regex can be found here
This can be fixed by adding * to the regex.
Additional context
This error relates to fastify-swagger generating the documentation/static/{} endpoint for some other people this may be /docs/static/{}
Any one dealing with this error can modify their .spectral.yaml file to be.
The text was updated successfully, but these errors were encountered: