-
Notifications
You must be signed in to change notification settings - Fork 349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: simplify handling useJsonWireFormat=true and fix onlyTypes=true #583
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,7 +58,6 @@ export type Options = { | |
unrecognizedEnum: boolean; | ||
exportCommonSymbols: boolean; | ||
outputSchema: boolean; | ||
// An alias of !output | ||
onlyTypes: boolean; | ||
emitImportedFiles: boolean; | ||
useExactTypes: boolean; | ||
|
@@ -124,8 +123,18 @@ export function optionsFromParameter(parameter: string | undefined): Options { | |
} | ||
Object.assign(options, parsed); | ||
} | ||
// We should promote onlyTypes to its own documented flag, but just an alias for now | ||
if (!options.outputJsonMethods && !options.outputEncodeMethods && !options.outputClientImpl && !options.nestJs) { | ||
// onlyTypes=true implies outputJsonMethods=false,outputEncodeMethods=false,outputClientImpl=false,nestJs=false | ||
if (options.onlyTypes) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ...huh, yeah, not sure why we weren't doing this before. Great fix! If you want to add test cases to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should probably have been fixed when the option was documented. :) I'll add test cases! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tests added. |
||
options.outputJsonMethods = false; | ||
options.outputEncodeMethods = false; | ||
options.outputClientImpl = false; | ||
options.nestJs = false; | ||
} else if ( | ||
!options.outputJsonMethods && | ||
!options.outputEncodeMethods && | ||
!options.outputClientImpl && | ||
!options.nestJs | ||
) { | ||
options.onlyTypes = true; | ||
} | ||
|
||
|
@@ -164,6 +173,17 @@ export function optionsFromParameter(parameter: string | undefined): Options { | |
options.snakeToCamel = [options.snakeToCamel]; | ||
} | ||
|
||
if (options.useJsonWireFormat) { | ||
if (!options.onlyTypes) { | ||
// useJsonWireFormat requires onlyTypes=true | ||
options.useJsonWireFormat = false; | ||
} else { | ||
// useJsonWireFormat implies stringEnums=true and useDate=string | ||
options.stringEnums = true; | ||
options.useDate = DateOption.STRING; | ||
} | ||
} | ||
|
||
return options; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if
nestJs=false
should be included here, as it is false by default, but nestJs=true -> onlyTypes=false.