-
Notifications
You must be signed in to change notification settings - Fork 533
Add TOML document endpoint support #3743
Description
Is there an existing issue that is already proposing this?
- I have searched the existing issues
Is your feature request related to a problem? Please describe it
The Swagger module only supports serving API definitions in JSON and YAML formats. There is no way to serve the OpenAPI document in TOML format, limiting interoperability with tools and workflows that prefer or require TOML.
Describe the solution you'd like
Add a option to SwaggerCustomOptions and support 'toml' as a value in the raw array. When enabled, the module serves the OpenAPI document at {path}-toml (or a custom URL) with content type application/toml, serialized using the smol-toml library. The option follows the exact same behavior as jsonDocumentUrl and yamlDocumentUrl, including support for patchDocumentOnRequest and useGlobalPrefix.
Teachability, documentation, adoption, migration strategy
No breaking changes fully backward compatible. Existing behavior is unchanged; raw: true now additionally serves TOML.
Documentation update needed for SwaggerCustomOptions:
Add tomlDocumentUrl?: string — default: {path}-toml
Update raw type to boolean | Array<'json' | 'yaml' | 'toml'>
New dependency: smol-toml (small, zero-dependency TOML serializer).
What is the motivation / use case for changing the behavior?
TOML is increasingly adopted as a configuration and data format. Exposing the OpenAPI spec in TOML allows developers to consume it directly in pipelines, config-driven tools, or generate TOML-native SDKs without a separate conversion step.