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

alias types change on every generation #614

Open mdesousa opened 2 months ago

mdesousa commented 2 months ago

we have some dependencies to not-exported types in our json schema. these types get an "alias" name in the generated json schema that changes every time the types are re-generated. this results in a lot of unnecessary changes that make it hard to review changes in source control.

it would be nice if the alias could be generated with a hash that was the same on every generation. maybe a hash that takes the name of the type as an input?

here is an example:

type A = { a: string };
export type B = Partial<A>;

when the json schema is generated you get this:

...
"Partial<alias-117779449-275-301-117779449-0-826>": { "type": "object", "properties": { "a": { "type": "string" } } },
"B": { "$ref": "#/definitions/Partial<alias-117779449-275-301-117779449-0-826>" },
...

this is ok, but if you commit this to source control and regenerate (without changes) you get different alias values.