|
1 | | -import * as path from 'path'; |
2 | | - |
| 1 | +import { camelCase } from 'lodash'; |
| 2 | +import path from 'node:path'; |
3 | 3 | import ApiGenerator, { |
4 | 4 | getOperationName as _getOperationName, |
5 | 5 | getReferenceName, |
6 | 6 | isReference, |
7 | 7 | supportDeepObjects, |
8 | 8 | } from 'oazapfts/lib/codegen/generate'; |
9 | | -import type { EndpointMatcher, EndpointOverrides, GenerationOptions, OperationDefinition, TextMatcher } from './types'; |
10 | | -import { capitalize, getOperationDefinitions, getV3Doc, removeUndefined, isQuery as testIsQuery } from './utils'; |
11 | 9 | import { |
12 | 10 | createPropertyAssignment, |
13 | 11 | createQuestionToken, |
14 | 12 | isValidIdentifier, |
15 | 13 | keywordType, |
16 | 14 | } from 'oazapfts/lib/codegen/tscodegen'; |
17 | | -import { generateCreateApiCall, generateEndpointDefinition, generateImportNode, generateTagTypes } from './codegen'; |
18 | | - |
19 | | -import type { ObjectPropertyDefinitions } from './codegen'; |
20 | 15 | import type { OpenAPIV3 } from 'openapi-types'; |
21 | | -import { camelCase } from 'lodash'; |
22 | | -import { factory } from './utils/factory'; |
23 | | -import { generateReactHooks } from './generators/react-hooks'; |
24 | 16 | import ts from 'typescript'; |
| 17 | +import type { ObjectPropertyDefinitions } from './codegen'; |
| 18 | +import { generateCreateApiCall, generateEndpointDefinition, generateImportNode, generateTagTypes } from './codegen'; |
| 19 | +import { generateReactHooks } from './generators/react-hooks'; |
| 20 | +import type { EndpointMatcher, EndpointOverrides, GenerationOptions, OperationDefinition, TextMatcher } from './types'; |
| 21 | +import { capitalize, getOperationDefinitions, getV3Doc, removeUndefined, isQuery as testIsQuery } from './utils'; |
| 22 | +import { factory } from './utils/factory'; |
25 | 23 |
|
26 | 24 | const generatedApiName = 'injectedRtkApi'; |
27 | 25 |
|
@@ -136,7 +134,7 @@ export async function generateApi( |
136 | 134 | if (apiFile.startsWith('.')) { |
137 | 135 | apiFile = path.relative(path.dirname(outputFile), apiFile); |
138 | 136 | apiFile = apiFile.replace(/\\/g, '/'); |
139 | | - if (!apiFile.startsWith('.')) apiFile = './' + apiFile; |
| 137 | + if (!apiFile.startsWith('.')) apiFile = `./${apiFile}`; |
140 | 138 | } |
141 | 139 | } |
142 | 140 | apiFile = apiFile.replace(/\.[jt]sx?$/, ''); |
@@ -191,7 +189,7 @@ export async function generateApi( |
191 | 189 | ); |
192 | 190 |
|
193 | 191 | function extractAllTagTypes({ operationDefinitions }: { operationDefinitions: OperationDefinition[] }) { |
194 | | - let allTagTypes = new Set<string>(); |
| 192 | + const allTagTypes = new Set<string>(); |
195 | 193 |
|
196 | 194 | for (const operationDefinition of operationDefinitions) { |
197 | 195 | const { verb, pathItem } = operationDefinition; |
@@ -280,7 +278,7 @@ export async function generateApi( |
280 | 278 | } |
281 | 279 | // if there are still any naming conflicts, prepend with underscore |
282 | 280 | while (name in queryArg) { |
283 | | - name = '_' + name; |
| 281 | + name = `_${name}`; |
284 | 282 | } |
285 | 283 | return name; |
286 | 284 | } |
|
0 commit comments