Skip to content

Commit 0f11d02

Browse files
committed
Add CLI support for new option
1 parent 84294f8 commit 0f11d02

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

docs/cli.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,3 +234,12 @@ export enum ApiPaths {
234234
This option is useful for generating path params optimistically when the schema has flaky path parameter definitions.
235235
Checks the path for opening and closing brackets and extracts them as path parameters.
236236
Does not override already defined by schema path parameters.
237+
238+
### makeParametersWithDefaultNotUndefined
239+
240+
Enabling `--make-parameters-with-default-not-undefined` will result in generated types where operation parameters that
241+
have default values defined are non-optional.
242+
243+
This allows generating types for certain server implementation use cases where the default value is injected
244+
automatically by the framework for the handling function to consume and the signature on the handler should
245+
indicate that the value can not be undefined.

packages/openapi-typescript/bin/cli.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ Options
3434
--root-types-no-schema-prefix (optional)
3535
Do not add "Schema" prefix to types at the root level (should only be used with --root-types)
3636
--make-paths-enum Generate ApiPaths enum for all paths
37+
--make-parameters-with-default-not-undefined
38+
Generate non-optional parameter types if the parameter has a default
3739
`;
3840

3941
const OUTPUT_FILE = "FILE";
@@ -86,6 +88,7 @@ const flags = parser(args, {
8688
"rootTypesNoSchemaPrefix",
8789
"makePathsEnum",
8890
"generatePathParams",
91+
"makeParametersWithDefaultNotUndefined",
8992
],
9093
string: ["output", "redocly"],
9194
alias: {
@@ -149,6 +152,7 @@ async function generateSchema(schema, { redocly, silent = false }) {
149152
rootTypesNoSchemaPrefix: flags.rootTypesNoSchemaPrefix,
150153
makePathsEnum: flags.makePathsEnum,
151154
generatePathParams: flags.generatePathParams,
155+
makeParametersWithDefaultNotUndefined: flags.makeParametersWithDefaultNotUndefined,
152156
redocly,
153157
silent,
154158
}),

0 commit comments

Comments
 (0)