YousefED / typescript-json-schema

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

BUG: Js Doc titles are omitted if the type has a reference #533

Open FreaKnightKurtosys opened 1 year ago

FreaKnightKurtosys commented 1 year ago

After upgrading from v0.38.3 to 0.56.0, we noticed that the title is no longer included in definitions that contains a $ref.

Interface

export interface IAppConfiguration {
    /**
     * Card Configuration, broken up into static & dynamic props
     * @title Card Props
     */
    cardProps?: IPropQueries<ICardProps, ICardQueries>;
}

Example of generated json in v0.38.3

{
    "IAppConfiguration": {
        "properties": {
            "cardProps": {
                "$ref": "#/definitions/IPropQueries<ICardProps,ICardQueries>",
                "description": "Card Configuration, broken up into static & dynamic props",
                "title": "Card Props"
            }
        },
        "type": "object"
    }
}

Example of generated json in v0.56.0

{
    "IAppConfiguration": {
        "properties": {
            "cardProps": {
                "$ref": "#/definitions/IPropQueries<ICardProps,ICardQueries>",
                "description": "Card Configuration, broken up into static & dynamic props"
            }
        },
        "type": "object"
    }
}

I had a dig in the code base and saw that this is caused by title not included in the annotationKeywords

I tested the title being included along a $ref on AJV's runkit to see if this would cause issues here: https://runkit.com/embed/28p5p0jzn6jl

I did see the following issues, but I am not sure if the annotation update will fix them: https://github.com/YousefED/typescript-json-schema/issues/439 https://github.com/YousefED/typescript-json-schema/issues/357