Skip to content

Commit 382b3de

Browse files
committed
hack: make multiple integration tests generate
1 parent 5770f84 commit 382b3de

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export class OpenapiLoader {
2222
private readonly library = new Map<string, any>()
2323

2424
private constructor(
25-
private readonly entryPointKey: string,
25+
public readonly entryPointKey: string,
2626
private readonly validator: OpenapiValidator,
2727
) {
2828
this.virtualLibrary.set(generationLib.key, generationLib)

packages/openapi-code-generator/src/typescript/typescript-nextjs/typescript-nextjs.generator.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,8 +423,14 @@ export async function generateTypescriptNextJS(
423423
): Promise<void> {
424424
const input = config.input
425425

426-
const appDirectory = "./app/api"
427-
const routesDirectory = "./generated/api"
426+
const subDirectory = process.env["OPENAPI_INTEGRATION_TESTS"]
427+
? path.basename(config.input.loader.entryPointKey)
428+
: ""
429+
430+
const appDirectory = ["./app", subDirectory].filter(isDefined).join(path.sep)
431+
const routesDirectory = ["./generated", subDirectory]
432+
.filter(isDefined)
433+
.join(path.sep)
428434

429435
const rootTypeBuilder = await TypeBuilder.fromInput(
430436
"./generated/api/models.ts",

scripts/generate.single.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,17 @@ template=$1
66
path=$2
77
filename=$(basename "$path")
88

9+
export OPENAPI_INTEGRATION_TESTS='true'
10+
11+
output="integration-tests/$template/src/generated/$filename"
12+
13+
# NextJS is an outlier due to it's path based routing
14+
if [[ "$template" == "typescript-nextjs" ]]; then
15+
output="integration-tests/$template/src"
16+
fi
17+
918
node ./packages/openapi-code-generator/dist/index.js \
1019
--input="$path" \
11-
--output="integration-tests/$template/src/generated/$filename" \
20+
--output="$output" \
1221
--template="$template" \
1322
--schema-builder=zod

0 commit comments

Comments
 (0)