File tree Expand file tree Collapse file tree 3 files changed +19
-4
lines changed
packages/openapi-code-generator/src
typescript/typescript-nextjs Expand file tree Collapse file tree 3 files changed +19
-4
lines changed Original file line number Diff line number Diff 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 )
Original file line number Diff line number Diff 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" ,
Original file line number Diff line number Diff line change @@ -6,8 +6,17 @@ template=$1
66path=$2
77filename=$( 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+
918node ./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
You can’t perform that action at this time.
0 commit comments