Skip to content

[OpenAPI] Header in OpenAPI spec's parameters is not sent on fetch #2701

@krzkz94

Description

@krzkz94

To Reproduce

  1. Use schema attached
  2. Generate docs
  3. Open generated page in Fumadocs OpenAPI
  4. On fetch (Send request to URL), header is not set
openapi: 3.0.3
info:
  title: Header Parameter Bug Reproduction
  description: |
    Reproduction case for fumadocs-openapi issue: Header parameters with `example` values are not sent in playground requests.
    
    **Issue:** The `Accept: application/json` header parameter is defined with an example value, but the playground sends `accept: */*` instead.
  version: 1.0.0
servers:
  - url: 'https://api.mysite.dev'
paths:
  /api/v2/tags:
    get:
      summary: 'Get tags'
      operationId: getTags
      description: 'Get all the tags for a given type'
      parameters:
        - in: query
          name: types
          description: ''
          example: null
          required: false
          schema:
            type: object
            description: ''
            example: null
            nullable: false
            properties: {}
        - in: header
          name: Accept
          required: false
          schema:
            type: string
            default: application/json
          example: application/json
      responses:
        200:
          description: ''
          content:
            application/json:
              schema:
                type: object
                example:
                  data:
                    - id: 35
                      name: aut
                      type: stream
                    - id: 36
                      name: adipisci
                      type: stream
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                          example: 35
                        name:
                          type: string
                          example: aut
                        type:
                          type: string
                          example: stream
      tags:
        - 'Tags V2'
tags:
  - name: 'Tags V2'
    description: 'API Endpoint for tags'

Current vs. Expected behavior

Current behavior

  • Specified headers in parameters are not sent

Expected behavior

  • If a header is specified in the parameters OpenAPI spec, it should be included in the request automatically.
  • This works fine in Swagger https://editor.swagger.io/ (paste the attached schema, check headers)

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.1.0: Mon Oct 20 19:34:05 PDT 2025; root:xnu-12377.41.6~2/RELEASE_ARM64_T6041
  Available memory (MB): 65536
  Available CPU cores: 16
Binaries:
  Node: 24.11.1
  npm: 11.6.2
  Yarn: N/A
  pnpm: 8.15.9
Relevant Packages:
  next: 16.0.7 // Latest available version is detected (16.0.7).
  eslint-config-next: N/A
  react: 19.2.0
  react-dom: 19.2.0
  typescript: 5.6.3
Next.js Config:
  output: standalone

Which area(s) are affected? (Select all that apply)

Integrations (e.g OpenAPI, Typescript DocsGen)

Additional context

This feature would be extremely valuable since APIs can respond in different formats and laravel is known to be quite annoying when swapping between accept/html & accept/json (unless you specify or force this header by default, it will use accept/html) - but it's a per-route thing. Some routes need JSON, some might return XML or even files/blobs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions