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

Validation error on object as Header Parameter #2559

Open
felixwoestmann opened this issue Jul 8, 2024 · 2 comments
Open

Validation error on object as Header Parameter #2559

felixwoestmann opened this issue Jul 8, 2024 · 2 comments

Comments

@felixwoestmann
Copy link

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
@tesanchez
Copy link

Hello, it doesnt seem like prism support this. Can you help me understand how often you are seeing objects in headers and how it will benefit you?

@felixwoestmann
Copy link
Author

Hello, I have never encountered it in the wild. I am developing an OpenAPI Code generator and am using prism to validate my implementation. I was implementing header parameters when I encountered the issue.

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

No branches or pull requests

3 participants