Skip to content

Commit f8c5c29

Browse files
workaround for oazapfts#491 (#3791)
* add temporary workaround for oazapfts/oazapfts#491 --------- Co-authored-by: codesandbox-bot <[email protected]>
1 parent f40687c commit f8c5c29

File tree

4 files changed

+21
-13
lines changed

4 files changed

+21
-13
lines changed

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,7 @@
6363
"docs/react-dom": "npm:17.0.2",
6464
"docs/@types/react-dom": "npm:17.0.11",
6565
"docs/@types/react": "npm:17.0.11",
66-
"type-fest": "2.19.0",
67-
"oazapfts": "4.8.0"
66+
"type-fest": "2.19.0"
6867
},
6968
"scripts": {
7069
"build": "yarn build:packages",

packages/rtk-query-codegen-openapi/src/generate.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ export async function generateApi(
103103
useEnumType,
104104
});
105105

106+
// temporary workaround for https://github.com/oazapfts/oazapfts/issues/491
107+
if (apiGen.spec.components?.schemas) {
108+
apiGen.preprocessComponents(apiGen.spec.components.schemas);
109+
}
110+
106111
const operationDefinitions = getOperationDefinitions(v3Doc).filter(operationMatches(filterEndpoints));
107112

108113
const resultFile = ts.createSourceFile(

packages/rtk-query-codegen-openapi/test/__snapshots__/generateEndpoints.test.ts.snap

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -773,17 +773,21 @@ export type GetApiV1AnimalsApiArg = {
773773
type?: AnimalType;
774774
};
775775
export type AnimalType = 'All' | 'Cats' | 'Dogs';
776-
export type Animal = {
776+
export type AnimalBase = {
777777
type: AnimalType;
778778
id?: number;
779779
name?: string | null;
780780
};
781-
export type Dog = Animal & {
782-
dogUniqueProp?: string | null;
783-
};
784-
export type Cat = Animal & {
785-
catUniqueProp?: string | null;
786-
};
781+
export type Dog = {
782+
type: 'Dog';
783+
} & AnimalBase & {
784+
dogUniqueProp?: string | null;
785+
};
786+
export type Cat = {
787+
type: 'Cat';
788+
} & AnimalBase & {
789+
catUniqueProp?: string | null;
790+
};
787791
export const { useGetApiV1AnimalsQuery } = injectedRtkApi;
788792

789793
`;

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20493,9 +20493,9 @@ fsevents@^1.2.7:
2049320493
languageName: node
2049420494
linkType: hard
2049520495

20496-
"oazapfts@npm:4.8.0":
20497-
version: 4.8.0
20498-
resolution: "oazapfts@npm:4.8.0"
20496+
"oazapfts@npm:^4.8.0":
20497+
version: 4.10.0
20498+
resolution: "oazapfts@npm:4.10.0"
2049920499
dependencies:
2050020500
"@apidevtools/swagger-parser": ^10.1.0
2050120501
lodash: ^4.17.21
@@ -20504,7 +20504,7 @@ fsevents@^1.2.7:
2050420504
typescript: ^5.2.2
2050520505
bin:
2050620506
oazapfts: lib/codegen/cli.js
20507-
checksum: 0f3850767a1c18c02a2c002981f3d89304643ecd425d4723f0d73efebddaa3a13d9e7436a070cdd211b24a5fecd270e03686de91d316b3361de64413d2c2a7ee
20507+
checksum: dbed3d73ba2c3a758b3e5a9ffb62486c628f020232ad513bceb0562a437a45350cc5262689191c664423980421d9f2690b9574a56f75bdaf1375772d179b1210
2050820508
languageName: node
2050920509
linkType: hard
2051020510

0 commit comments

Comments
 (0)