Skip to content

Commit 204d4bd

Browse files
authored
Merge pull request #2009 from hey-api/fix/types-identifier-case-preserve
fix: avoid including underscore for appended types (e.g. data, error, response) when preserving identifier case
2 parents 0144c5f + f45ba8e commit 204d4bd

File tree

16 files changed

+92
-43
lines changed

16 files changed

+92
-43
lines changed

.changeset/eighty-rivers-enjoy.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
"@hey-api/openapi-ts": patch
33
---
44

5-
fix: make descriminator field required when used with `oneOf` keyword
5+
fix: make discriminator field required when used with `oneOf` keyword

.changeset/nervous-months-brake.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@hey-api/openapi-ts': patch
3+
---
4+
5+
fix: avoid including underscore for appended types (e.g. data, error, response) when preserving identifier case

packages/openapi-ts-tests/test/3.0.x.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@ describe(`OpenAPI ${version}`, () => {
8989
{
9090
config: createConfig({
9191
input: 'case.json',
92-
output: 'case',
92+
output: 'case-preserve',
9393
plugins: [
9494
{
95-
identifierCase: undefined,
95+
identifierCase: 'preserve',
9696
name: '@hey-api/typescript',
9797
},
9898
],

packages/openapi-ts-tests/test/3.1.x.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@ describe(`OpenAPI ${version}`, () => {
8989
{
9090
config: createConfig({
9191
input: 'case.json',
92-
output: 'case',
92+
output: 'case-preserve',
9393
plugins: [
9494
{
95-
identifierCase: undefined,
95+
identifierCase: 'preserve',
9696
name: '@hey-api/typescript',
9797
},
9898
],

packages/openapi-ts-tests/test/__snapshots__/3.0.x/case/types.gen.ts renamed to packages/openapi-ts-tests/test/__snapshots__/3.0.x/case-preserve/types.gen.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export type fooBar = number;
5151
*/
5252
export type FooBar = string;
5353

54-
export type GetFoo_Data = {
54+
export type GetFooData = {
5555
body: Foo;
5656
path?: never;
5757
query: {
@@ -71,7 +71,7 @@ export type GetFoo_Data = {
7171
url: '/foo';
7272
};
7373

74-
export type GetFoo_Responses = {
74+
export type GetFooResponses = {
7575
/**
7676
* OK
7777
*/
@@ -82,7 +82,7 @@ export type GetFoo_Responses = {
8282
201: _201;
8383
};
8484

85-
export type GetFoo_Response = GetFoo_Responses[keyof GetFoo_Responses];
85+
export type GetFooResponse = GetFooResponses[keyof GetFooResponses];
8686

8787
export type ClientOptions = {
8888
baseUrl: `${string}://${string}` | (string & {});

packages/openapi-ts-tests/test/__snapshots__/3.1.x/case/types.gen.ts renamed to packages/openapi-ts-tests/test/__snapshots__/3.1.x/case-preserve/types.gen.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export type fooBar = number;
5151
*/
5252
export type FooBar = string;
5353

54-
export type GetFoo_Data = {
54+
export type GetFooData = {
5555
body: Foo;
5656
path?: never;
5757
query: {
@@ -71,7 +71,7 @@ export type GetFoo_Data = {
7171
url: '/foo';
7272
};
7373

74-
export type GetFoo_Responses = {
74+
export type GetFooResponses = {
7575
/**
7676
* OK
7777
*/
@@ -82,7 +82,7 @@ export type GetFoo_Responses = {
8282
201: _201;
8383
};
8484

85-
export type GetFoo_Response = GetFoo_Responses[keyof GetFoo_Responses];
85+
export type GetFooResponse = GetFooResponses[keyof GetFooResponses];
8686

8787
export type ClientOptions = {
8888
baseUrl: `${string}://${string}` | (string & {});

packages/openapi-ts-tests/test/openapi-ts.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export default defineConfig(() => {
103103
// enums: 'javascript',
104104
// enumsCase: 'camelCase',
105105
// exportInlineEnums: true,
106-
// identifierCase: 'preserve',
106+
identifierCase: 'preserve',
107107
name: '@hey-api/typescript',
108108
// readOnlyWriteOnlyBehavior: 'off',
109109
// readableNameBuilder: 'Readable{{name}}',

packages/openapi-ts/src/plugins/@hey-api/sdk/plugin.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,7 @@ const operationStatements = ({
398398
const identifierSchema = context.file({ id: zodId })!.identifier({
399399
$ref: operationIrRef({
400400
case: 'camelCase',
401+
config: context.config,
401402
id: operation.id,
402403
type: 'response',
403404
}),

0 commit comments

Comments
 (0)