Skip to content

Commit b293edf

Browse files
committed
fix: pascal case
1 parent 62f6c5b commit b293edf

File tree

3 files changed

+12
-18
lines changed

3 files changed

+12
-18
lines changed

src/openApi/v2/parser/getModel.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import type { Model } from '../../../client/interfaces/Model';
22
import { getPattern } from '../../../utils/getPattern';
3-
import { toPascalCase } from '../../../utils/toPascalCase';
43
import type { OpenApi } from '../interfaces/OpenApi';
54
import type { OpenApiSchema } from '../interfaces/OpenApiSchema';
65
import { extendEnum } from './extendEnum';
@@ -50,10 +49,10 @@ export const getModel = (
5049
if (definition.$ref) {
5150
const definitionRef = getType(definition.$ref);
5251
model.export = 'reference';
53-
model.type = toPascalCase(definitionRef.type);
54-
model.base = toPascalCase(definitionRef.base);
52+
model.type = definitionRef.type;
53+
model.base = definitionRef.base;
5554
model.template = definitionRef.template;
56-
model.imports.push(...definitionRef.imports.map(toPascalCase));
55+
model.imports.push(...definitionRef.imports);
5756
return model;
5857
}
5958

@@ -73,10 +72,10 @@ export const getModel = (
7372
if (definition.items.$ref) {
7473
const arrayItems = getType(definition.items.$ref);
7574
model.export = 'array';
76-
model.type = toPascalCase(arrayItems.type);
77-
model.base = toPascalCase(arrayItems.base);
75+
model.type = arrayItems.type;
76+
model.base = arrayItems.base;
7877
model.template = arrayItems.template;
79-
model.imports.push(...arrayItems.imports.map(toPascalCase));
78+
model.imports.push(...arrayItems.imports);
8079
return model;
8180
} else {
8281
const arrayItems = getModel(openApi, definition.items);
@@ -94,10 +93,10 @@ export const getModel = (
9493
if (definition.additionalProperties.$ref) {
9594
const additionalProperties = getType(definition.additionalProperties.$ref);
9695
model.export = 'dictionary';
97-
model.type = toPascalCase(additionalProperties.type);
98-
model.base = toPascalCase(additionalProperties.base);
96+
model.type = additionalProperties.type;
97+
model.base = additionalProperties.base;
9998
model.template = additionalProperties.template;
100-
model.imports.push(...additionalProperties.imports.map(toPascalCase));
99+
model.imports.push(...additionalProperties.imports);
101100
return model;
102101
} else {
103102
const additionalProperties = getModel(openApi, definition.additionalProperties);

src/openApi/v2/parser/getModels.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import type { Model } from '../../../client/interfaces/Model';
22
import { reservedWords } from '../../../utils/reservedWords';
3-
import { toPascalCase } from '../../../utils/toPascalCase';
43
import type { OpenApi } from '../interfaces/OpenApi';
54
import { getModel } from './getModel';
65
import { getType } from './getType';
@@ -11,12 +10,7 @@ export const getModels = (openApi: OpenApi): Model[] => {
1110
if (openApi.definitions.hasOwnProperty(definitionName)) {
1211
const definition = openApi.definitions[definitionName];
1312
const definitionType = getType(definitionName);
14-
const model = getModel(
15-
openApi,
16-
definition,
17-
true,
18-
toPascalCase(definitionType.base.replace(reservedWords, '_$1'))
19-
);
13+
const model = getModel(openApi, definition, true, definitionType.base.replace(reservedWords, '_$1'));
2014
models.push(model);
2115
}
2216
}

src/openApi/v2/parser/getType.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { Type } from '../../../client/interfaces/Type';
2+
import { toPascalCase } from '../../../utils/toPascalCase';
23
import { getMappedType } from './getMappedType';
34
import { stripNamespace } from './stripNamespace';
45

@@ -56,7 +57,7 @@ export const getType = (type: string = 'any', format?: string): Type => {
5657
}
5758

5859
if (typeWithoutNamespace) {
59-
const type = encode(typeWithoutNamespace);
60+
const type = toPascalCase(encode(typeWithoutNamespace));
6061
result.type = type;
6162
result.base = type;
6263
result.imports.push(type);

0 commit comments

Comments
 (0)