Skip to content

No validation errors for when a header references a schema in components #1758

@ponelat

Description

@ponelat

The following definition is invalid..

openapi: 3.0.3

info: 
  title: Missing validation rule for schemas in Headers.
  version: 1.0.0
  
paths: 
  /foo:
    get:
      description: ok
      parameters:         
      - $ref: '#/components/schemas/xFoo'
      responses:
        default:
          description: ok
          headers:
            three:
              $ref: '#/components/schemas/xFoo'
           
components:
  schemas:
    xFoo:
      type: string
      description: This isn't validated correctly

In it the parameter (and header) are both referencing #/components/schemas/xFoo, and xFoo isn't a valid header/paramter. A valid would header/parameter needs the schema property, e.g.:

xFoo:
  schema:
    type: string
    description: This is a valid header

Tested with https://validator.swagger.io (in case there is a discrepency).

Is there a decision to not validate the fully resolved definition? Or a decision to validate against improper paths (i.e., referencing a JSON Pointer that looks fishy, even if technically it's allowed by the spec to reference any path).

cc @frantuma @gracekarina

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions