Skip to content

Commit 8703ce3

Browse files
fix(openapi-generator): do not calculate relative paths from input files
This commit removes the code to calculate a relative path between the directory containing the tsconfig.json file and the input file. This permits a copy of @api-ts/openapi-generator installed in one location to use files from a project in a different location as inputs without crashing. Full bug report below. What I did ---------- ``` $ npx openapi-generator \ --input ../lib/grooble/src/index.ts \ --output api.json \ --tsconfig ../lib/grooble/tsconfig.json \ --name "Grooble" ``` What I Expected to Happen ------------------------- I expected the openapi-generator to create a file named `api.json` with the OpenAPI spec described by `../lib/grooble/src/index.ts`. What Actually Happens --------------------- ``` Error processing project: src/index.ts not in project ``` with a non-zero exit code. What Actually Happens (with These Changes) ------------------------------------------ The openapi-generator successfully creates a file named `api.json` with the OpenAPI spec described by `../lib/grooble/src/index.ts`. However, I'm not sure why this code was added in the first place! So please review thorougly to see if this will regresss some use-cases not captured by the tests. Ticket: BG-41531
1 parent c8ccb46 commit 8703ce3

File tree

1 file changed

+1
-4
lines changed
  • packages/openapi-generator/src

1 file changed

+1
-4
lines changed

packages/openapi-generator/src/cli.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,10 @@ const app = command({
5959
}),
6060
},
6161
handler: async ({ input, output, tsConfig, name, includeInternal }) => {
62-
const baseDir = p.dirname(tsConfig);
63-
const relativeInput = p.relative(baseDir, input);
64-
6562
const api = pipe(
6663
componentsForProject({
6764
virtualFiles: {},
68-
index: relativeInput,
65+
index: input,
6966
tsConfig,
7067
name,
7168
includeInternal,

0 commit comments

Comments
 (0)