You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I run into the error below, when I tried to generate schema for the given class.
Env:
node: v18.20.3
ts-json-schema-generator: 2.3.0
Error:
TypeError: Cannot read properties of undefined (reading 'length')
at strip (C:\...\node_modules\ts-json-schema-generator\dist\src\Utils\String.js:6:26)
at ObjectProperty.getName (C:\...\node_modules\ts-json-schema-generator\dist\src\Type\ObjectType.js:16:38)
at C:\...\ts-json-schema-generator\dist\src\TypeFormatter\ObjectTypeFormatter.js:57:41
at Array.map (<anonymous>)
at ObjectTypeFormatter.getObjectDefinition (C:\...\node_modules\ts-json-schema-generator\dist\src\TypeFormatter\ObjectTypeFormatter.js:57:14)
at ObjectTypeFormatter.getDefinition (C:\...\node_modules\ts-json-schema-generator\dist\src\TypeFormatter\ObjectTypeFormatter.js:27:25)
at ChainTypeFormatter.getDefinition (C:\...\node_modules\ts-json-schema-generator\dist\src\ChainTypeFormatter.js:18:44)
at CircularReferenceTypeFormatter.getDefinition (C:\...\node_modules\ts-json-schema-generator\dist\src\CircularReferenceTypeFormatter.js:21:59)
at C:\...\node_modules\ts-json-schema-generator\dist\src\TypeFormatter\ObjectTypeFormatter.js:59:66
at Array.reduce (<anonymous>)
Reproduce:
// test-class.ts
export class TestClass {
CHILD = {
PROP_1: '',
"PROP_2": '', // This is OK
"PROP.3": '', // This causes ERROR
"{PROP_4}": '', // This causes ERROR
"400": '' // This causes ERROR
};
PROP_5 = '';
"PROP_6" = ''; // This is OK
"PROP.7" = ''; // This is OK
"{PROP_8}" = ''; // This is OK
"400" = ''; // This is OK
}
The text was updated successfully, but these errors were encountered:
baloghbence0915
changed the title
Schema generator fails when nested property is StringLiteral (kind 11)
Schema generator fails when nested property name is StringLiteral (kind 11)
Jul 9, 2024
Hey @baloghbence0915 thanks in advance for this super detailed pull request! Would you want to start a PR? I could help you with it. Remember to add unit tests :)
Hi folks,
I run into the error below, when I tried to generate schema for the given class.
Env:
Error:
Reproduce:
Run:
Probably this method is missing the handling of such a usecase:
https://github.com/vega/ts-json-schema-generator/blob/v2.3.0/src/NodeParser/TypeLiteralNodeParser.ts#L82
NodeObject has no
escapedText
prop:Thanks in advance for checking!
The text was updated successfully, but these errors were encountered: