@@ -11,26 +11,27 @@ const HELP = `Usage
11
11
$ openapi-typescript [input] [options]
12
12
13
13
Options
14
- --help Display this
15
- --version Display the version
16
- --redocly [path], -c Specify path to Redocly config (default: redocly.yaml)
17
- --output, -o Specify output file (if not specified in redocly.yaml)
18
- --enum Export true TS enums instead of unions
19
- --enum-values Export enum values as arrays
20
- --dedupe-enums Dedupe enum types when \`--enum=true\` is set
21
- --check Check that the generated types are up-to-date. (default: false)
22
- --export-type, -t Export top-level \`type\` instead of \`interface\`
23
- --immutable Generate readonly types
24
- --additional-properties Treat schema objects as if \`additionalProperties: true\` is set
25
- --empty-objects-unknown Generate \`unknown\` instead of \`Record<string, never>\` for empty objects
26
- --default-non-nullable Set to \`false\` to ignore default values when generating non-nullable types
14
+ --help Display this
15
+ --version Display the version
16
+ --redocly [path], -c Specify path to Redocly config (default: redocly.yaml)
17
+ --output, -o Specify output file (if not specified in redocly.yaml)
18
+ --enum Export true TS enums instead of unions
19
+ --enum-values Export enum values as arrays
20
+ --dedupe-enums Dedupe enum types when \`--enum=true\` is set
21
+ --check Check that the generated types are up-to-date. (default: false)
22
+ --export-type, -t Export top-level \`type\` instead of \`interface\`
23
+ --immutable Generate readonly types
24
+ --additional-properties Treat schema objects as if \`additionalProperties: true\` is set
25
+ --empty-objects-unknown Generate \`unknown\` instead of \`Record<string, never>\` for empty objects
26
+ --default-non-nullable Set to \`false\` to ignore default values when generating non-nullable types
27
27
--properties-required-by-default
28
- Treat schema objects as if \`required\` is set to all properties by default
29
- --array-length Generate tuples using array minItems / maxItems
30
- --path-params-as-types Convert paths to template literal types
31
- --alphabetize Sort object keys alphabetically
32
- --exclude-deprecated Exclude deprecated types
33
- --root-types (optional) Export schemas types at root level
28
+ Treat schema objects as if \`required\` is set to all properties by default
29
+ --array-length Generate tuples using array minItems / maxItems
30
+ --path-params-as-types Convert paths to template literal types
31
+ --alphabetize Sort object keys alphabetically
32
+ --exclude-deprecated Exclude deprecated types
33
+ --root-types (optional) Export schemas types at root level
34
+ --root-types-no-schema-prefix (optional) Do not add "Schema" prefix to types at the root level (should be used with --root-types)
34
35
` ;
35
36
36
37
const OUTPUT_FILE = "FILE" ;
@@ -56,6 +57,9 @@ if (args.includes("-it")) {
56
57
if ( args . includes ( "--redoc" ) ) {
57
58
errorAndExit ( `The --redoc config flag has been renamed to "--redocly" (or -c as shorthand).` ) ;
58
59
}
60
+ if ( args . includes ( "--root-types-no-schema-prefix" ) && ! args . includes ( "--root-types" ) ) {
61
+ console . warn ( "--root-types-no-schema-prefix has no effect without --root-types flag" ) ;
62
+ }
59
63
60
64
const flags = parser ( args , {
61
65
boolean : [
@@ -76,6 +80,7 @@ const flags = parser(args, {
76
80
"immutable" ,
77
81
"pathParamsAsTypes" ,
78
82
"rootTypes" ,
83
+ "rootTypesNoSchemaPrefix" ,
79
84
] ,
80
85
string : [ "output" , "redocly" ] ,
81
86
alias : {
@@ -136,6 +141,7 @@ async function generateSchema(schema, { redocly, silent = false }) {
136
141
immutable : flags . immutable ,
137
142
pathParamsAsTypes : flags . pathParamsAsTypes ,
138
143
rootTypes : flags . rootTypes ,
144
+ rootTypesNoSchemaPrefix : flags . rootTypesNoSchemaPrefix ,
139
145
redocly,
140
146
silent,
141
147
} ) ,
0 commit comments