lukeautry / tsoa

Build OpenAPI-compliant REST APIs using TypeScript and Node
MIT License
3.45k stars 494 forks source link

Query parameter default value not generated to spec file in case of custom types #1472

Closed ikkala closed 10 months ago

ikkala commented 1 year ago

Sorting

Expected Behavior

In case of custom type TimeFormat the following:

type TimeFormat = 'iso8601' | 'epoch_ms';

    @Query()
    timeFormat: TimeFormat = 'iso8601'

should generate open api spec parameter like:

    {
        "in": "query",
        "name": "timeFormat",
        "required": false,
        "schema": {
            "default": "iso8601",
            "type": "string",
            "enum": [
                "iso8601",
                "epoch_ms"
            ]
        }
    }

Current Behavior

Instead it generates:

    {
        "in": "query",
        "name": "timeFormat",
        "required": false,
        "schema": {
            "$ref": "#/components/schemas/TimeFormat"
        }
    }

Currently, if type is written open directly into query parameter definition (instead of using custom type):

    @Query()
    timeFormat: 'iso8601' | 'epoch_ms' = 'iso8601'

it works, default value is generated.

Context (Environment)

Version of the library: 5.1.1 and 6.0.0-rc.3 Version of NodeJS: v20.2.0

github-actions[bot] commented 1 year ago

Hello there ikkala 👋

Thank you for opening your very first issue in this project.

We will try to get back to you as soon as we can.👀

github-actions[bot] commented 11 months ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days

ikkala commented 11 months ago

Based on 6.0.0-rc.4 change log, this is still to be fixed.

github-actions[bot] commented 10 months ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days