Skip to content

Commit 34fa15d

Browse files
committed
fix: pascal case
1 parent 685029f commit 34fa15d

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

src/openApi/v3/parser/getType.spec.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,28 +57,28 @@ describe('getType', () => {
5757

5858
it('should support dot', () => {
5959
const type = getType('#/components/schemas/model.000');
60-
expect(type.type).toEqual('model_000');
61-
expect(type.base).toEqual('model_000');
60+
expect(type.type).toEqual('Model000');
61+
expect(type.base).toEqual('Model000');
6262
expect(type.template).toEqual(null);
63-
expect(type.imports).toEqual(['model_000']);
63+
expect(type.imports).toEqual(['Model000']);
6464
expect(type.isNullable).toEqual(false);
6565
});
6666

6767
it('should support dashes', () => {
6868
const type = getType('#/components/schemas/some_special-schema');
69-
expect(type.type).toEqual('some_special_schema');
70-
expect(type.base).toEqual('some_special_schema');
69+
expect(type.type).toEqual('SomeSpecialSchema');
70+
expect(type.base).toEqual('SomeSpecialSchema');
7171
expect(type.template).toEqual(null);
72-
expect(type.imports).toEqual(['some_special_schema']);
72+
expect(type.imports).toEqual(['SomeSpecialSchema']);
7373
expect(type.isNullable).toEqual(false);
7474
});
7575

7676
it('should support dollar sign', () => {
7777
const type = getType('#/components/schemas/$some+special+schema');
78-
expect(type.type).toEqual('$some_special_schema');
79-
expect(type.base).toEqual('$some_special_schema');
78+
expect(type.type).toEqual('$SomeSpecialSchema');
79+
expect(type.base).toEqual('$SomeSpecialSchema');
8080
expect(type.template).toEqual(null);
81-
expect(type.imports).toEqual(['$some_special_schema']);
81+
expect(type.imports).toEqual(['$SomeSpecialSchema']);
8282
expect(type.isNullable).toEqual(false);
8383
});
8484

src/openApi/v3/parser/getType.ts

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

@@ -71,7 +72,7 @@ export const getType = (type: string | string[] = 'any', format?: string): Type
7172
}
7273

7374
if (typeWithoutNamespace) {
74-
const type = encode(typeWithoutNamespace);
75+
const type = toPascalCase(encode(typeWithoutNamespace));
7576
result.type = type;
7677
result.base = type;
7778
result.imports.push(type);

0 commit comments

Comments
 (0)