Skip to content

Commit 12fa41d

Browse files
committed
Revert branded default option
1 parent bdfd27b commit 12fa41d

5 files changed

Lines changed: 8 additions & 7 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ yarn openapi-codegen generate --input http://localhost:3001/docs-json --standalo
4545
--importPath Module import style for generated files (default: 'ts'; options: 'ts' | 'relative' | 'absolute')
4646
--removeOperationPrefixEndingWith Remove operation name prefixes that end with the specified string (Default: 'Controller_')
4747
--extractEnums Extract enums into separate Zod schemas (default: true)
48-
--branded Apply branded types to ambiguous Zod schemas (default: false)
48+
--branded Apply branded types to ambiguous Zod schemas (default: true)
4949
--replaceOptionalWithNullish Replace `.optional()` chains with `.nullish()` in generated Zod schemas (default: false)
5050
5151
--axiosRequestConfig Include Axios request config parameters in query hooks (default: false)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@povio/openapi-codegen-cli",
3-
"version": "0.14.6",
3+
"version": "0.14.7",
44
"main": "./dist/index.js",
55
"bin": {
66
"openapi-codegen": "./dist/sh.js"

src/generators/const/options.const.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export const DEFAULT_GENERATE_OPTIONS: GenerateOptions = {
4343
enumSuffix: ENUM_SUFFIX,
4444
withDefaultValues: true,
4545
extractEnums: true,
46-
branded: false,
46+
branded: true,
4747
replaceOptionalWithNullish: false,
4848
// Endpoints options
4949
restClientImportPath: TEMPLATE_IMPORTS.appRestClient.template,

src/generators/generate/generateZodUtils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export function generateZodUtils(resolver: SchemaResolver) {
1212
parse: ZOD_UTILS.exports.parse,
1313
sortExp: ZOD_UTILS.exports.sortExp,
1414
brand: ZOD_UTILS.exports.brand,
15+
branded: resolver.options.branded,
1516
errorHandler: ERROR_HANDLERS.ErrorHandler,
1617
sharedErrorHandler: ERROR_HANDLERS.SharedErrorHandler,
1718
errorHandlingImport: {

src/generators/templates/zod-utils.hbs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ export namespace {{zodUtilsNamespace}} {
4343
});
4444

4545
{{#if branded}}
46-
export class ZodBranded<T extends z.ZodTypeAny> extends z.ZodType<T["_output"], z.ZodTypeDef, T["_input"]> {
46+
export class ZodBranded<T extends z.ZodTypeAny, B extends string> extends z.ZodType<T["_output"], z.ZodTypeDef, T["_input"]> {
4747
readonly _schema: T;
4848

49-
readonly _brand: string;
49+
readonly _brand: B;
5050

51-
constructor(_schema: T, _brand: string) {
51+
constructor(_schema: T, _brand: B) {
5252
super(_schema._def);
5353
this._schema = _schema;
5454
this._brand = _brand;
@@ -63,7 +63,7 @@ export namespace {{zodUtilsNamespace}} {
6363
}
6464
}
6565

66-
export function {{brand}}<T extends z.ZodTypeAny>(schema: T, _brand: string): ZodBranded<T> {
66+
export function {{brand}}<T extends z.ZodTypeAny, B extends string>(schema: T, _brand: B): ZodBranded<T, B> {
6767
return new ZodBranded(schema, _brand);
6868
}
6969
{{/if}}

0 commit comments

Comments
 (0)