Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/rtk-query-codegen-openapi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@
},
"dependencies": {
"@apidevtools/swagger-parser": "^10.0.2",
"@rtk-query/oazapfts-patched": "^3.6.0-2",
"commander": "^6.2.0",
"oazapfts": "^4.7.1",
"prettier": "^2.2.1",
"semver": "^7.3.5",
"swagger2openapi": "^7.0.4",
"typescript": ">=4.1 <=4.5"
"typescript": "^5.0.4"
},
"husky": {
"hooks": {
Expand Down
8 changes: 0 additions & 8 deletions packages/rtk-query-codegen-openapi/src/bin/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,6 @@
import program from 'commander';
import { dirname, resolve } from 'path';
import { generateEndpoints, parseConfig } from '../';
import semver from 'semver';
import { version as tsVersion } from 'typescript';

if (!semver.satisfies(tsVersion, '>=4.1 <=4.5')) {
console.warn(
'Please note that `@rtk-query/codegen-openapi` only has been tested with TS versions 4.1 to 4.5 - other versions might cause problems.'
);
}

let ts = false;
try {
Expand Down
2 changes: 0 additions & 2 deletions packages/rtk-query-codegen-openapi/src/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export function generateObjectProperties(obj: ObjectPropertyDefinitions) {

export function generateImportNode(pkg: string, namedImports: Record<string, string>, defaultImportName?: string) {
return factory.createImportDeclaration(
undefined,
undefined,
factory.createImportClause(
false,
Expand Down Expand Up @@ -46,7 +45,6 @@ export function generateCreateApiCall({
undefined,
[
factory.createParameterDeclaration(
undefined,
undefined,
undefined,
endpointBuilder,
Expand Down
8 changes: 2 additions & 6 deletions packages/rtk-query-codegen-openapi/src/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import ApiGenerator, {
getReferenceName,
isReference,
supportDeepObjects,
} from '@rtk-query/oazapfts-patched/lib/codegen/generate';
} from 'oazapfts/lib/codegen/generate';
import {
createQuestionToken,
keywordType,
createPropertyAssignment,
isValidIdentifier,
} from '@rtk-query/oazapfts-patched/lib/codegen/tscodegen';
} from 'oazapfts/lib/codegen/tscodegen';
import type { OpenAPIV3 } from 'openapi-types';
import { generateReactHooks } from './generators/react-hooks';
import type { EndpointMatcher, EndpointOverrides, GenerationOptions, OperationDefinition, TextMatcher } from './types';
Expand Down Expand Up @@ -150,7 +150,6 @@ export async function generateApi(
),
}),
factory.createExportDeclaration(
undefined,
undefined,
false,
factory.createNamedExports([
Expand Down Expand Up @@ -242,7 +241,6 @@ export async function generateApi(
const ResponseTypeName = factory.createTypeReferenceNode(
registerInterface(
factory.createTypeAliasDeclaration(
undefined,
[factory.createModifier(ts.SyntaxKind.ExportKeyword)],
capitalize(operationName + responseSuffix),
undefined,
Expand Down Expand Up @@ -309,7 +307,6 @@ export async function generateApi(
const QueryArg = factory.createTypeReferenceNode(
registerInterface(
factory.createTypeAliasDeclaration(
undefined,
[factory.createModifier(ts.SyntaxKind.ExportKeyword)],
capitalize(operationName + argSuffix),
undefined,
Expand Down Expand Up @@ -393,7 +390,6 @@ export async function generateApi(
Object.keys(queryArg).length
? [
factory.createParameterDeclaration(
undefined,
undefined,
undefined,
rootObject,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import ts from 'typescript';
import { getOperationName } from '@rtk-query/oazapfts-patched/lib/codegen/generate';
import { getOperationName } from 'oazapfts/lib/codegen/generate';
import { capitalize, isQuery } from '../utils';
import type { OperationDefinition, EndpointOverrides, ConfigFile } from '../types';
import { getOverrides } from '../generate';
Expand Down
4 changes: 2 additions & 2 deletions packages/rtk-query-codegen-openapi/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ export function parseConfig(fullConfig: ConfigFile) {
}

/**
* Enforces `@rtk-query/oazapfts-patched` to use the same TypeScript version as this module itself uses.
* Enforces `oazapfts` to use the same TypeScript version as this module itself uses.
* That should prevent enums from running out of sync if both libraries use different TS versions.
*/
function enforceOazapftsTsVersion<T>(cb: () => T): T {
const ozTsPath = require.resolve('typescript', { paths: [require.resolve('@rtk-query/oazapfts-patched')] });
const ozTsPath = require.resolve('typescript', { paths: [require.resolve('oazapfts')] });
const tsPath = require.resolve('typescript');
const originalEntry = require.cache[ozTsPath];
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1005,7 +1005,7 @@ const injectedRtkApi = api
overrideExisting: false,
});
export { injectedRtkApi as enhancedApi };
export type GetStructureDefinitionApiResponse = unknown;
export type GetStructureDefinitionApiResponse = /** status 200 Success */ FhirJsonResource;
export type GetStructureDefinitionApiArg = {
/** Some description */
foo?: any;
Expand All @@ -1024,6 +1024,7 @@ export type GetStructureDefinitionApiArg = {
/** Some description */
naming_conflict?: any;
};
export type FhirJsonResource = object;
export const { useGetStructureDefinitionQuery } = injectedRtkApi;

`;
Expand Down
69 changes: 48 additions & 21 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ __metadata:
languageName: node
linkType: hard

"@apidevtools/swagger-parser@npm:^10.0.1, @apidevtools/swagger-parser@npm:^10.0.2":
"@apidevtools/swagger-parser@npm:^10.0.2, @apidevtools/swagger-parser@npm:^10.1.0":
version: 10.1.0
resolution: "@apidevtools/swagger-parser@npm:10.1.0"
dependencies:
Expand Down Expand Up @@ -6521,7 +6521,6 @@ __metadata:
"@babel/preset-env": ^7.12.11
"@babel/preset-typescript": ^7.12.7
"@reduxjs/toolkit": ^1.6.0
"@rtk-query/oazapfts-patched": ^3.6.0-2
"@types/commander": ^2.12.2
"@types/glob-to-regexp": ^0.4.0
"@types/jest": ^27
Expand All @@ -6538,14 +6537,15 @@ __metadata:
husky: ^4.3.6
jest: ^27
msw: ^0.40.2
oazapfts: ^4.7.1
openapi-types: ^9.1.0
prettier: ^2.2.1
pretty-quick: ^3.1.0
semver: ^7.3.5
swagger2openapi: ^7.0.4
ts-jest: ^27
ts-node: ^10.4.0
typescript: ">=4.1 <=4.5"
typescript: ^5.0.4
yalc: ^1.0.0-pre.47
bin:
rtk-query-codegen-openapi: lib/bin/cli.js
Expand All @@ -6568,21 +6568,6 @@ __metadata:
languageName: unknown
linkType: soft

"@rtk-query/oazapfts-patched@npm:^3.6.0-2":
version: 3.6.0-2
resolution: "@rtk-query/oazapfts-patched@npm:3.6.0-2"
dependencies:
"@apidevtools/swagger-parser": ^10.0.1
lodash: ^4.17.20
minimist: ^1.2.5
swagger2openapi: ^7.0.7
typescript: ^4.1.2
bin:
oazapfts: lib/codegen/cli.js
checksum: f95227696b6c1e71ebaa87f7848e0af82a1b900b5c7657a8e5b94c07c8b6328894a09b17a0ff5dceb8333aa48800948081d8476d7dcce4d93e0082374f598039
languageName: node
linkType: hard

"@rushstack/eslint-patch@npm:^1.1.0":
version: 1.1.3
resolution: "@rushstack/eslint-patch@npm:1.1.3"
Expand Down Expand Up @@ -19543,6 +19528,13 @@ fsevents@^1.2.7:
languageName: node
linkType: hard

"minimist@npm:^1.2.8":
version: 1.2.8
resolution: "minimist@npm:1.2.8"
checksum: 75a6d645fb122dad29c06a7597bddea977258957ed88d7a6df59b5cd3fe4a527e253e9bbf2e783e4b73657f9098b96a5fe96ab8a113655d4109108577ecf85b0
languageName: node
linkType: hard

"minipass-collect@npm:^1.0.2":
version: 1.0.2
resolution: "minipass-collect@npm:1.0.2"
Expand Down Expand Up @@ -20265,6 +20257,21 @@ fsevents@^1.2.7:
languageName: node
linkType: hard

"oazapfts@npm:^4.7.1":
version: 4.7.1
resolution: "oazapfts@npm:4.7.1"
dependencies:
"@apidevtools/swagger-parser": ^10.1.0
lodash: ^4.17.21
minimist: ^1.2.8
swagger2openapi: ^7.0.8
typescript: ^5.0.4
bin:
oazapfts: lib/codegen/cli.js
checksum: 9319ae4e4d6db2c1ddcd636b3f00dd2d675203b5720387d642d1743db07bb454833839ec524d53326cbde700e7bc94562423c3e3f8764355f6e2b02b9664998f
languageName: node
linkType: hard

"object-assign@npm:4.1.1, object-assign@npm:^4.1.0, object-assign@npm:^4.1.1":
version: 4.1.1
resolution: "object-assign@npm:4.1.1"
Expand Down Expand Up @@ -26083,7 +26090,7 @@ fsevents@^1.2.7:
languageName: node
linkType: hard

"swagger2openapi@npm:^7.0.4, swagger2openapi@npm:^7.0.7":
"swagger2openapi@npm:^7.0.4, swagger2openapi@npm:^7.0.8":
version: 7.0.8
resolution: "swagger2openapi@npm:7.0.8"
dependencies:
Expand Down Expand Up @@ -26883,7 +26890,7 @@ fsevents@^1.2.7:
languageName: node
linkType: hard

"typescript@npm:>=4.1 <=4.5, typescript@npm:^4.1.2, typescript@npm:^4.1.3, typescript@npm:^4.3.4":
"typescript@npm:^4.1.3, typescript@npm:^4.3.4":
version: 4.5.2
resolution: "typescript@npm:4.5.2"
bin:
Expand All @@ -26903,6 +26910,16 @@ fsevents@^1.2.7:
languageName: node
linkType: hard

"typescript@npm:^5.0.4":
version: 5.0.4
resolution: "typescript@npm:5.0.4"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: 82b94da3f4604a8946da585f7d6c3025fff8410779e5bde2855ab130d05e4fd08938b9e593b6ebed165bda6ad9292b230984f10952cf82f0a0ca07bbeaa08172
languageName: node
linkType: hard

"typescript@npm:~4.2.4":
version: 4.2.4
resolution: "typescript@npm:4.2.4"
Expand Down Expand Up @@ -26933,7 +26950,7 @@ fsevents@^1.2.7:
languageName: node
linkType: hard

"typescript@patch:typescript@>=4.1 <=4.5#~builtin<compat/typescript>, typescript@patch:typescript@^4.1.2#~builtin<compat/typescript>, typescript@patch:typescript@^4.1.3#~builtin<compat/typescript>, typescript@patch:typescript@^4.3.4#~builtin<compat/typescript>":
"typescript@patch:typescript@^4.1.3#~builtin<compat/typescript>, typescript@patch:typescript@^4.3.4#~builtin<compat/typescript>":
version: 4.5.2
resolution: "typescript@patch:typescript@npm%3A4.5.2#~builtin<compat/typescript>::version=4.5.2&hash=701156"
bin:
Expand All @@ -26953,6 +26970,16 @@ fsevents@^1.2.7:
languageName: node
linkType: hard

"typescript@patch:typescript@^5.0.4#~builtin<compat/typescript>":
version: 5.0.4
resolution: "typescript@patch:typescript@npm%3A5.0.4#~builtin<compat/typescript>::version=5.0.4&hash=701156"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: 6a1fe9a77bb9c5176ead919cc4a1499ee63e46b4e05bf667079f11bf3a8f7887f135aa72460a4c3b016e6e6bb65a822cb8689a6d86cbfe92d22cc9f501f09213
languageName: node
linkType: hard

"typescript@patch:typescript@~4.2.4#~builtin<compat/typescript>":
version: 4.2.4
resolution: "typescript@patch:typescript@npm%3A4.2.4#~builtin<compat/typescript>::version=4.2.4&hash=701156"
Expand Down