redocly-cli
redocly-cli copied to clipboard
Path parameter isn't defined
Describe the bug If a path has a named placeholder but doesn't have a path parameter, then we should show the problem.
Each template expression in the path MUST correspond to a path parameter that is included in the Path Item itself and/or in each of the Path Item's Operations.
To Reproduce Steps to reproduce the behavior:
- Given this
.redocly.yamlfile (just therecommendedrules) - Contact Adam or see a sample below.
- Run this command with these arguments...
openapi lint - See no error
Expected behavior I expect to see this error: https://redoc.ly/docs/cli/built-in-rules/#path-parameters-defined
Logs
validating /home/adam/Downloads/2020-09-23-13-03-openapi-od_3p8p9x.yaml...
/home/adam/Downloads/2020-09-23-13-03-openapi-od_3p8p9x.yaml: validated in in 86ms
Woohoo! Your OpenAPI definition is valid. 🎉
OpenAPI definition
This is an excerpt.
The one with the path template was defined first:
paths:
/something/{id}:
parameters:
- name: foo
in: header
required: true
schema:
type: string
/something:
# ...
openapi-cli Version(s)
1.0.0-beta.14
Node.js Version(s)
v12.6.0
Additional context
Contact Adam if you need a full OpenAPI definition.
As it turned out the parameter actually was defined on the path item level.
But that wasn't noticed when submitting the issue as the parameters block was under the methods definitions.
Hi Redocly team!
I was just about to create a new ticket, but I think it makes sense to report under this one. Basically, the path-params-defined is not flagging an error in a scenario when a templated path has two (or more) operations assigned, and only one of them defines the path parameter.
A minimal example of a failing openapi schema looks like this:
openapi: 3.0.0
info:
title: Test
version: 0.0.1
servers:
- url: https://localhost:8080
paths:
/items/{itemId}:
get:
summary: Get Items
parameters:
- name: itemId
in: path
required: true
schema:
type: string
responses:
'200':
description: OK
options:
summary: CORS support
responses:
'200':
description: OK
Redocly CLI linting does not report any errors, however, it's violating the spec in terms of
Each template expression in the path MUST correspond to a path parameter that is included in the Path Item itself and/or in each of the Path Item's Operations.
Hi @mkucharek!
Thank you for noticing this.