json-schema-to-typescript
json-schema-to-typescript copied to clipboard
description in oneOf
I have something like this:
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "QueryMsg",
"oneOf": [
{
"description": "This is variant 1",
"type": "object",
"required": [
"kind"
],
"properties": {
"kind": {
"type": "string",
"enum": [
"variant_1"
]
}
}
},
{
"description": "This is variant 2",
"type": "object",
"required": [
"kind"
],
"properties": {
"kind": {
"type": "string",
"enum": [
"variant_2"
]
}
}
}
]
}
and it turns it into the following:
export type QueryMsg =
| {
kind: "variant 1";
[k: string]: unknown;
}
| {
kind: "variant 0";
[k: string]: unknown;
};
Which is cool - but the descriptions are lost, i.e. no comments are generated for the variants
is there a way to make it preserve the comments somehow?
This would be very nice if it was fixed.
It is also problem with arrays.
test: {
type: 'object',
properties: {
testArr: {
type: 'array',
items: {
description: 'some very important description',
type: 'string',
}
}
}
}
Turns into:
test?: {
testArr?: string[];
[k: string]: unknown;
};
Description on string item inside testArr is lost.