Skip to content

Commit 3afa595

Browse files
authored
feat: typescript-generator 에서 type 뿐만이 아닌 const 한 변수도 같이 생성되도록 수정합니다 (#11)
* feat: typescript-generator 에서 type 뿐만이 아닌 const 한 변수도 같이 생성되도록 수정합니다 * fix: 모델 데이터 구성 추가수정 * fix: as const 를 통한 모델 생성 업데이트
1 parent 0ed4755 commit 3afa595

File tree

9 files changed

+63
-9
lines changed

9 files changed

+63
-9
lines changed

modules/openapi-generator/src/main/resources/typescript/model/model.mustache

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,14 @@ export enum {{classname}}{{enumName}} {
100100
}
101101
{{/enum}}
102102
{{#stringUnion}}
103-
export type {{classname}}{{enumName}} ={{#allowableValues}}{{#values}} "{{.}}" {{^-last}}|{{/-last}}{{/values}}{{/allowableValues}};
103+
export type {{classname}}{{enumName}} = {{#allowableValues}}{{#values}} "{{.}}" {{^-last}}|{{/-last}}{{/values}}{{/allowableValues}};
104+
export const {{classname}}{{enumName}} = {
105+
{{#allowableValues}}
106+
{{#enumVars}}
107+
{{name}}: {{{value}}}{{^-last}},{{/-last}}
108+
{{/enumVars}}
109+
{{/allowableValues}}
110+
} as const;
104111
{{/stringUnion}}
105112
{{/enumTypes}}
106113
{{/isEnum}}
@@ -122,6 +129,13 @@ export enum {{classname}} {
122129
{{/enum}}
123130
{{#stringUnion}}
124131
export type {{classname}} ={{#allowableValues}}{{#values}} "{{.}}" {{^-last}}|{{/-last}}{{/values}}{{/allowableValues}};
132+
export const {{classname}}{{enumName}} = {
133+
{{#allowableValues}}
134+
{{#enumVars}}
135+
{{name}}: {{{value}}}{{^-last}},{{/-last}}
136+
{{/enumVars}}
137+
{{/allowableValues}}
138+
} as const;
125139
{{/stringUnion}}
126140
{{/enumTypes}}
127141
{{/isEnum}}

samples/openapi3/client/petstore/typescript/builds/browser/models/Order.ts

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

samples/openapi3/client/petstore/typescript/builds/browser/models/Pet.ts

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

samples/openapi3/client/petstore/typescript/builds/deno/models/Order.ts

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

samples/openapi3/client/petstore/typescript/builds/deno/models/Pet.ts

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

samples/openapi3/client/petstore/typescript/builds/jquery/models/Order.ts

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

samples/openapi3/client/petstore/typescript/builds/jquery/models/Pet.ts

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

samples/openapi3/client/petstore/typescript/builds/object_params/models/Order.ts

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

samples/openapi3/client/petstore/typescript/builds/object_params/models/Pet.ts

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)