Don't output intermediate aliases
See original GitHub issueexport interface Parent {
a: A;
}
export type A = RealA;
export type RealA = { realA: string };
./node_modules/.bin/ts-json-schema-generator \
--path 'test.ts' \
--type 'Parent' \
--expose 'export' \
--jsDoc 'extended'
outputs
{
"$ref": "#/definitions/Parent",
"$schema": "http://json-schema.org/draft-06/schema#",
"definitions": {
"A": {
"$ref": "#/definitions/RealA"
},
"Parent": {
"additionalProperties": false,
"properties": {
"a": {
"$ref": "#/definitions/A"
}
},
"required": [
"a"
],
"type": "object"
},
"RealA": {
"additionalProperties": false,
"properties": {
"realA": {
"type": "string"
}
},
"required": [
"realA"
],
"type": "object"
}
}
}
However, if RealA
is not referred elsewhere, it’s better to output:
{
"$ref": "#/definitions/Parent",
"$schema": "http://json-schema.org/draft-06/schema#",
"definitions": {
"A": {
"additionalProperties": false,
"properties": {
"realA": {
"type": "string"
}
},
"required": [
"realA"
],
"type": "object"
},
"Parent": {
"additionalProperties": false,
"properties": {
"a": {
"$ref": "#/definitions/A"
}
},
"required": [
"a"
],
"type": "object"
}
}
}
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:10 (10 by maintainers)
Top Results From Across the Web
How do I create an alias where the arguments go in the middle?
The workaround is to pass the arguments that alias accepts only at the end to a wrapper that will insert them in the...
Read more >[Solved] Alias don't output with TAB and LF ? | Linux.org
The problem with your alias is that your quotes are mis-matched. Your double quote after printf= is NOT acting as an opening quote...
Read more >In Bash, when to alias, when to script, and when to write a ...
Aliases and functions are executed by the current shell, i.e. they run within and affect the shell's current environment.² No separate process ...
Read more >One weird trick for powerful Git aliases - Work Life by Atlassian
Normal aliases can't have parameters. You can't execute multiple git commands in a single alias. You can't use | (pipes) or ...
Read more >mastering-zsh/aliases.md at master - GitHub
A good place to start is to list all of your shell aliases with the alias command. When passed no parameters it will...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
So the idea is to never output something of the form
and replace all occurrences of XXXX with YYYY
Note that this is quite important to make the schema legible. (It will reduce number of stacks in JSON schema validation error.)