Skip to content

support true numerical enums #26

@jon49

Description

@jon49

I can do the following in TypeScript:

enum HttpStatusCode
{
    OK = 200,
    Unauthorized = 401
    ...
}

It would be nice if typson treated these enumeration as actual enumerations. I was thinking it could look for @type signature above the enum, e.g.,

/**
* @type integer
*/
enum HttpStatusCode
{
    OK = 200,
    Unauthorized = 401
    ...
}

and produce (per http://spacetelescope.github.io/understanding-json-schema/reference/generic.html):

{
type: 'integer'
enum: [200, 401]
}

Otherwise default to string enum

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions