YousefED / typescript-json-schema

Generate json-schema from your Typescript sources
BSD 3-Clause "New" or "Revised" License
3.08k stars 318 forks source link

Bug in enum type processing #578

Open fbaligand opened 9 months ago

fbaligand commented 9 months ago

Hi,

Given that I have Entity.ts:

export enum Entity {
    firstValue,
    secondValue
}

Then I execute:

typescript-json-schema Entity.ts *

Expected Result:

{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "definitions": {
        "Entity": {
            "enum": [
                "firstValue",
                "secondValue"
            ],
            "type": "string"
        }
    }
}

Actual Result:

{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "definitions": {
        "Entity": {
            "enum": [
                0,
                1
            ],
            "type": "number"
        }
    }
}