Skip to content

Commit bdfd27b

Browse files
committed
Default branded options update
1 parent 68fe011 commit bdfd27b

File tree

4 files changed

+9
-14
lines changed

4 files changed

+9
-14
lines changed

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: true)
48+
--branded Apply branded types to ambiguous Zod schemas (default: false)
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.5",
3+
"version": "0.14.6",
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: true,
46+
branded: false,
4747
replaceOptionalWithNullish: false,
4848
// Endpoints options
4949
restClientImportPath: TEMPLATE_IMPORTS.appRestClient.template,

src/generators/templates/zod-utils.hbs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,13 @@ export namespace {{zodUtilsNamespace}} {
4242
}
4343
});
4444

45-
export class ZodBranded<T extends z.ZodTypeAny, B extends string | number | symbol> extends z.ZodType<
46-
T["_output"],
47-
z.ZodTypeDef,
48-
T["_input"]
49-
> {
45+
{{#if branded}}
46+
export class ZodBranded<T extends z.ZodTypeAny> extends z.ZodType<T["_output"], z.ZodTypeDef, T["_input"]> {
5047
readonly _schema: T;
5148

52-
readonly _brand: B;
49+
readonly _brand: string;
5350

54-
constructor(_schema: T, _brand: B) {
51+
constructor(_schema: T, _brand: string) {
5552
super(_schema._def);
5653
this._schema = _schema;
5754
this._brand = _brand;
@@ -66,10 +63,8 @@ export namespace {{zodUtilsNamespace}} {
6663
}
6764
}
6865

69-
export function {{brand}}<T extends z.ZodTypeAny, B extends string | number | symbol>(
70-
schema: T,
71-
_brand: B,
72-
): ZodBranded<T, B> {
66+
export function {{brand}}<T extends z.ZodTypeAny>(schema: T, _brand: string): ZodBranded<T> {
7367
return new ZodBranded(schema, _brand);
7468
}
69+
{{/if}}
7570
}

0 commit comments

Comments
 (0)