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

Spectral Spotlight Issue: Inconsistent allOf Validation in Parameters vs Responses #2674

Open
Krzysztof-Kolodziejczyk opened this issue Aug 29, 2024 · 0 comments

Comments

@Krzysztof-Kolodziejczyk
Copy link

Krzysztof-Kolodziejczyk commented Aug 29, 2024

Spectral Spotlight Issue: Inconsistent allOf Validation in Parameters vs Responses
Version: 6.11.1
Node.js Version: 20.17.0

There is an inconsistency in how Spectral validates allOf elements within parameters versus responses in an OpenAPI document. When using allOf in parameters, all elements are validated correctly. However, in the responses section, if one of the allOf elements contains a $ref to a definition that has already been validated, Spectral does not validate any remaining elements within the allOf structure.

== To Reproduce

  1. Given this OpenAPI document:

    paths:
      /somepath:
        post:
          parameters:
            - in: body
              schema:
                allOf:
                  - $ref: '#/definitions/SomeElement'
                    example: {}
                  - properties:
                      name:
                        description: User's name.
                        type: string
                        example: John
                      id:
                        description: User's identifier.
                        example: 1
          responses:
            '200':
              description: 'Successful response.'
              schema:
                allOf:
                  - $ref: '#/definitions/SomeElement'
                    example: {}
                  - properties:
                      name:
                        description: User's name.
                        type: string
                        example: John
                      id:
                        description: User's identifier.
                        example: 1
    
  2. Observe the behavior:

    • In the parameters section, Spectral correctly validates all elements under the allOf.

    • In the responses section, if an allOf element contains a $ref to a definition that was previously validated (e.g., - $ref: '#/definitions/SomeRequest'), Spectral skips validation for the remaining elements within the allOf structure.

== Expected behavior

Spectral should validate all elements in the allOf structure within both parameters and responses, regardless of whether an element is a $ref to a previously validated definition. Consistent behavior is expected across all sections of the OpenApi document

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant