Skip to content
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

Path Parameter Definitions Not Required Across Operations #1076

Closed
dillonredding opened this issue Apr 9, 2020 · 3 comments · Fixed by #1077
Closed

Path Parameter Definitions Not Required Across Operations #1076

dillonredding opened this issue Apr 9, 2020 · 3 comments · Fixed by #1077
Assignees
Labels
t/bug Something isn't working

Comments

@dillonredding
Copy link

Describe the bug
The path-params rule is not triggered when a path parameter is defined under one operation but not in another, both of which are under the same path item.

To Reproduce
Given the following OpenAPI document:

openapi: 3.0.3
info:
  title: API Title
  version: '1.0'
paths:
  /test/{foo}:
    get:
      parameters:
        - name: foo
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: OK
    put:
      responses:
        '200':
          description: OK

I get this when linting:

$ spectral lint .\openapi.yaml
OpenAPI 3.x detected

c:/dev/openapi.yaml
  1:1  warning  oas3-api-servers       OpenAPI `servers` must be present and non-empty array.
  1:1  warning  openapi-tags           OpenAPI object should have non-empty `tags` array.
  2:6  warning  info-contact           Info object should contain `contact` object.
  2:6  warning  info-description       OpenAPI object info `description` must be present and non-empty string.
  7:9  warning  operation-description  Operation `description` must be present and non-empty string.
  7:9  warning  operation-operationId  Operation should have an `operationId`.
  7:9  warning  operation-tags         Operation should have non-empty `tags` array.
 17:9  warning  operation-description  Operation `description` must be present and non-empty string.
 17:9  warning  operation-operationId  Operation should have an `operationId`.
 17:9  warning  operation-tags         Operation should have non-empty `tags` array.

✖ 10 problems (0 errors, 10 warnings, 0 infos, 0 hints)

Expected behavior
This should have triggered the path-params rule for the put, which is what I get without the parameter definition in the get.

6:15    error  path-params            The path `/test/{foo}` uses a parameter `{foo}` that does not have a corresponding definition.

Environment:

  • Library version: 5.3.0
  • OS: Windows 10
@dillonredding dillonredding added the t/bug Something isn't working label Apr 9, 2020
@nulltoken
Copy link
Contributor

@dillonredding Good catch! On it.

@nulltoken
Copy link
Contributor

@dillonredding #1077 should fix that.

@dillonredding
Copy link
Author

You're awesome! Thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants