Skip to content

Commit 01bc328

Browse files
authored
refactor: split input.ts into several files (#416)
- moves `ParameterNormalizer` / `SchemaNormalizer` into their own files - add unit tests for `ParameterNormalizer` - removes invalid style "template" from `path` parameters - moves `openapi-loader` into the `loaders` directory
1 parent a7f9090 commit 01bc328

File tree

12 files changed

+1266
-809
lines changed

12 files changed

+1266
-809
lines changed

packages/openapi-code-generator/src/core/input.ts

Lines changed: 4 additions & 789 deletions
Large diffs are not rendered by default.

packages/openapi-code-generator/src/core/openapi-loader.spec.ts renamed to packages/openapi-code-generator/src/core/loaders/openapi-loader.spec.ts

File renamed without changes.

packages/openapi-code-generator/src/core/openapi-loader.ts renamed to packages/openapi-code-generator/src/core/loaders/openapi-loader.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import path from "node:path"
22
import util from "node:util"
3-
import {generationLib, VirtualDefinition} from "./generation-lib"
4-
import type {GenericLoader} from "./loaders/generic.loader"
5-
import type {TypespecLoader} from "./loaders/typespec.loader"
6-
import {isRemote} from "./loaders/utils"
3+
import {generationLib, VirtualDefinition} from "../generation-lib"
74
import type {
85
OpenapiDocument,
96
Operation,
@@ -14,9 +11,12 @@ import type {
1411
Response,
1512
Schema,
1613
xInternalPreproccess,
17-
} from "./openapi-types"
18-
import {isRef} from "./openapi-utils"
19-
import type {OpenapiValidator} from "./openapi-validator"
14+
} from "../openapi-types"
15+
import {isRef} from "../openapi-utils"
16+
import type {IOpenapiValidator} from "../openapi-validator"
17+
import type {GenericLoader} from "./generic.loader"
18+
import type {TypespecLoader} from "./typespec.loader"
19+
import {isRemote} from "./utils"
2020

2121
export class OpenapiLoader {
2222
private readonly virtualLibrary = new Map<string, VirtualDefinition>()
@@ -25,7 +25,7 @@ export class OpenapiLoader {
2525
private constructor(
2626
private readonly entryPointKey: string,
2727
private readonly config: {titleOverride: string | undefined},
28-
private readonly validator: OpenapiValidator,
28+
private readonly validator: IOpenapiValidator,
2929
private readonly genericLoader: GenericLoader,
3030
) {
3131
this.virtualLibrary.set(generationLib.key, generationLib)
@@ -176,7 +176,7 @@ export class OpenapiLoader {
176176

177177
static async createFromLiteral(
178178
value: object,
179-
validator: OpenapiValidator,
179+
validator: IOpenapiValidator,
180180
genericLoader: GenericLoader,
181181
): Promise<OpenapiLoader> {
182182
const loader = new OpenapiLoader(
@@ -197,7 +197,7 @@ export class OpenapiLoader {
197197
fileType: "openapi3" | "typespec"
198198
titleOverride: string | undefined
199199
},
200-
validator: OpenapiValidator,
200+
validator: IOpenapiValidator,
201201
genericLoader: GenericLoader,
202202
typespecLoader: TypespecLoader,
203203
): Promise<OpenapiLoader> {

0 commit comments

Comments
 (0)