Skip to content

OpenAPI 3.1.x supports const, @fastify/swagger converts consts to enums #876

@TastyPi

Description

@TastyPi

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Fastify version

5.3.3

Plugin version

9.5.1

Node.js version

22.15.0

Operating system

Linux

Operating system version (i.e. 20.04, 11.3, 10)

Ubuntu 24.04

Description

The OpenAPI spec supports the type of parameters as const as of 3.1.0. However, this library converts const definitions to single-value enums, right here

openapiSchema.enum = [openapiSchema.const]

It should only do that for OpenAPI 3.0.x

Link to code that reproduces the bug

https://github.com/TastyPi/fastify-issue

Expected Behavior

The printed OpenAPI spec should have "const": "1" for the header, instead it has "enum": ["1"].

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions