prism icon indicating copy to clipboard operation
prism copied to clipboard

Validation error on object as Header Parameter

Open felixwoestmann opened this issue 7 months ago • 2 comments

For an endpoint which has an object as a header parameter I receive an validation error, even though my spec is consistent with the OpenAPI 3 standard.

Current Behavior

The server errors saying:

Request did not pass the validation rules
[12:27:04 PM] ›     [VALIDATOR] ✖  error     Request header parameter exclude must have required property 'name'

Expected Behavior

The server answers with a mock response.

Steps to Reproduce

Here is the OpenAPI definition used and the corresponding cURL with the object serialization as described in https://swagger.io/docs/specification/serialization/#header

curl -X GET 'http://localhost:4010/pets/header' -H 'Prefer: code=200' -H 'exclude: id, 10, name, Fido, tag, tag1'

openapi: "3.0.0"
info:
  version: 1.0.0
  title: Swagger Petstore
  license:
    name: MIT
servers:
  - url: http://petstore.swagger.io/v1
paths:
  /pets/header:
    get:
      summary: List all pets with header params
      operationId: listPetsHeader
      tags:
        - pets
      parameters:
        - name: exclude
          in:  header
          description: tags to exclude
          required: true
          schema:
            $ref: "#/components/schemas/Pet"
      responses:
        '200':
          description: A paged array of pets
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Pets"
components:
  schemas:
    Pet:
      type: object
      required:
        - id
        - name
      properties:
        id:
          type: integer
          format: int64
        name:
          type: string
        tag:
          type: string
    Pets:
      type: array
      maxItems: 100
      items:
        $ref: "#/components/schemas/Pet"

Environment

  • macOS
  • prism v5.7.0
  • node v22.2.0

felixwoestmann avatar Jul 08 '24 10:07 felixwoestmann