Tsoa: Static properties in class based models get included

Created on 25 Mar 2020  路  2Comments  路  Source: lukeautry/tsoa

Sorting

  • I'm submitting a ...

    • [x] bug report
    • [ ] feature request
    • [ ] support request
  • I confirm that I

    • [x] used the search to make sure that a similar issue hasn't already been submit

Expected Behavior

When declaring a class based model, only instance (non-static) properties are part of the objects of said type:

export class ClassBasedModelType {
    InstanceField: string;
    static StaticField: string;
}

Therefore, static properties are not part of the response, thus neither the swagger doc

"ClassBasedModelType": {
    "properties": {
        "InstanceField": {
            "type": "string"
        }
    },
    "required": [
        "InstanceField"
    ],
    "type": "object",
    "additionalProperties": true
}

Current Behavior

Currently static properties are included in the swagger doc nonetheless:

"ClassBasedModelType": {
    "properties": {
        "InstanceField": {
            "type": "string"
        },
        "StaticField": {
            "type": "string"
        }
    },
    "required": [
        "InstanceField",
        "StaticField"
    ],
    "type": "object",
    "additionalProperties": true
}

Context (Environment)

Version of the library: 3.0.4
Version of NodeJS: 13.11.0

  • Confirm you were using yarn not npm: [鈽筣

Detailed Description

Static properties in TypeScript are part of the class rather than the instances. Logically, a JSON response based on a type containing static properties does not include static properties of the type, because they are not part of the instance itself (which is used for the response).
Nonetheless currently tsoa includes static properties in the swagger doc exactly same as instance properties.

bug help wanted

Most helpful comment

@WoH I can try to help with this one also 馃榿

All 2 comments

Current workaround is to @ignore all static properties (ignore works normally despite the props being static).

@WoH I can try to help with this one also 馃榿

Was this page helpful?
0 / 5 - 0 ratings

Related issues

taicho picture taicho  路  5Comments

rdhelms picture rdhelms  路  4Comments

williamdes picture williamdes  路  5Comments

jfrconley picture jfrconley  路  3Comments

ancizararenas picture ancizararenas  路  3Comments