File tree Expand file tree Collapse file tree 4 files changed +23
-22
lines changed Expand file tree Collapse file tree 4 files changed +23
-22
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " openapi-typescript-codegen" ,
3
- "version" : " 0.26.1 " ,
3
+ "version" : " 0.26.2 " ,
4
4
"description" : " Library that generates Typescript clients based on the OpenAPI specification." ,
5
5
"author" : " Ferdi Koomen" ,
6
6
"homepage" : " https://github.com/ferdikoomen/openapi-typescript-codegen" ,
Original file line number Diff line number Diff line change @@ -179,6 +179,15 @@ export const getModel = (
179
179
}
180
180
}
181
181
182
+ if ( definition . const !== undefined ) {
183
+ model . export = 'const' ;
184
+ const definitionConst = definition . const ;
185
+ const modelConst = typeof definitionConst === 'string' ? `"${ definitionConst } "` : `${ definitionConst } ` ;
186
+ model . type = modelConst ;
187
+ model . base = modelConst ;
188
+ return model ;
189
+ }
190
+
182
191
// If the schema has a type than it can be a basic or generic type.
183
192
if ( definition . type ) {
184
193
const definitionType = getType ( definition . type , definition . format ) ;
@@ -192,14 +201,5 @@ export const getModel = (
192
201
return model ;
193
202
}
194
203
195
- if ( definition . const !== undefined ) {
196
- model . export = 'const' ;
197
- const definitionConst = definition . const ;
198
- const modelConst = typeof definitionConst === 'string' ? `"${ definitionConst } "` : `${ definitionConst } ` ;
199
- model . type = modelConst ;
200
- model . base = modelConst ;
201
- return model ;
202
- }
203
-
204
204
return model ;
205
205
} ;
Original file line number Diff line number Diff line change @@ -4567,10 +4567,10 @@ exports[`v3 should generate: test/generated/v3/models/ModelWithConst.ts 1`] = `
4567
4567
/* tslint:disable */
4568
4568
/* eslint-disable */
4569
4569
export type ModelWithConst = {
4570
- string ?: "string ";
4570
+ String ?: "String ";
4571
4571
number?: 0;
4572
- boolean?: false;
4573
4572
null?: null;
4573
+ withType?: "Some string";
4574
4574
};
4575
4575
4576
4576
"
@@ -5894,18 +5894,18 @@ exports[`v3 should generate: test/generated/v3/schemas/$ModelWithConst.ts 1`] =
5894
5894
/* eslint-disable */
5895
5895
export const $ModelWithConst = {
5896
5896
properties: {
5897
- string : {
5898
- type: '"string "',
5897
+ String : {
5898
+ type: '"String "',
5899
5899
},
5900
5900
number: {
5901
5901
type: '0',
5902
5902
},
5903
- boolean: {
5904
- type: 'false',
5905
- },
5906
5903
null: {
5907
5904
type: 'null',
5908
5905
},
5906
+ withType: {
5907
+ type: '"Some string"',
5908
+ },
5909
5909
},
5910
5910
} as const;
5911
5911
"
Original file line number Diff line number Diff line change 2557
2557
"ModelWithConst" : {
2558
2558
"type" : " object" ,
2559
2559
"properties" : {
2560
- "string " : {
2561
- "const" : " string "
2560
+ "String " : {
2561
+ "const" : " String "
2562
2562
},
2563
2563
"number" : {
2564
2564
"const" : 0
2565
2565
},
2566
- "boolean" : {
2567
- "const" : false
2568
- },
2569
2566
"null" : {
2570
2567
"const" : null
2568
+ },
2569
+ "withType" : {
2570
+ "type" : " string" ,
2571
+ "const" : " Some string"
2571
2572
}
2572
2573
}
2573
2574
}
You can’t perform that action at this time.
0 commit comments