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

Incorrect schema output when using Record #547

Open bdarcus opened 1 year ago

bdarcus commented 1 year ago

EDIT: maybe a dup of #476 and #337?


As I mentioned here, I tried to switch to the other converter, but ran into a showstopper of a bug.

So far, the only little issue I have here is this, which I'd like to resolve.

The code:

/** A global template that can be referenced by unique key. */
export type NamedTemplate = Record<TemplateKey, InlineTemplate>;

/** Template property definition in the Style. */
export interface TopLevelTemplate {
  templates: NamedTemplate;
}

Here's what it currently generates:

        "NamedTemplate": {
            "description": "A global template that can be referenced by unique key.",
            "type": "object"
        },

Here's what it should (I think?):

        "NamedTemplate": {
            "description": "A global template that can be referenced by unique key.",
            "type": "object",
            "$ref": "#/definitions/InlineTemplate"
        },

Edit: actually, output needs to use a patternProperty.

So why is the ref not added?

Is there anything I can do on my end to get this to work correctly?

dht commented 1 year ago

https://github.com/YousefED/typescript-json-schema/issues/337