typescript-json-schema
typescript-json-schema copied to clipboard
Certain names (e.g. those shared by @types/node) are missing from generated schema
I have an interface that's just completely missing from my output schema, I've narrowed it down to the name. Here's an example:
export interface Cluster {
test: string;
}
This produces the schema:
{
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {}
}
Using any name other than Cluster
, say Cluster2
and I get the expected:
{
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"Cluster2": {
"type": "object",
"properties": {
"test": {
"type": "string"
}
},
"required": [
"test"
]
}
}
}
Are there any reserved words or something we can't use? Is this expected? Can I overwrite that behaviour?
So the issue is
if (isUserFile(sourceFile)) {
userSymbols[name] = symbol;
}
Hits the following symbols in ...node_modules/@types/node/cluster.d.ts
:
ClusterSettings
Address
Worker
Cluster
Which, given userSymbols
is a map, overwrite the userSymbols["Cluster"]
, and it's then filtered out by getMainFileSymbols
with files.indexOf(node.getSourceFile())