Skip to content

Commit f017284

Browse files
authored
Merge pull request #1710 from hey-api/fix/relative-import-path
fix: use relative path to custom config file if provided when resolving relative paths
2 parents 403d38a + 4afdaa1 commit f017284

File tree

59 files changed

+2033
-4745
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+2033
-4745
lines changed

.changeset/many-mangos-sell.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@hey-api/openapi-ts': patch
3+
---
4+
5+
fix: use relative path to custom config file if provided when resolving relative paths

examples/openapi-ts-next/src/client/sdk.gen.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ export type Options<
5252
* custom client.
5353
*/
5454
client?: Client;
55+
/**
56+
* You can pass arbitrary values through the `meta` object. This can be
57+
* used to access values that aren't defined as part of the SDK function.
58+
*/
59+
meta?: Record<string, unknown>;
5560
};
5661

5762
/**

packages/openapi-ts/src/generate/files.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,15 +202,22 @@ export class TypeScriptFile {
202202
}): string {
203203
let filePath = '';
204204

205-
if (!id.startsWith('.')) {
205+
// relative file path
206+
if (id.startsWith('.')) {
207+
let configFileParts: Array<string> = [];
208+
// if providing a custom configuration file, relative paths must resolve
209+
// relative to the configuration file.
210+
if (context.config.configFile) {
211+
const cfgParts = context.config.configFile.split('/');
212+
configFileParts = cfgParts.slice(0, cfgParts.length - 1);
213+
}
214+
filePath = path.resolve(process.cwd(), ...configFileParts, id);
215+
} else {
206216
const file = context.file({ id });
207217
if (!file) {
208218
throw new Error(`File with id ${id} does not exist`);
209219
}
210-
211220
filePath = file._path;
212-
} else {
213-
filePath = path.resolve(process.cwd(), id);
214221
}
215222

216223
const thisPathParts = this._path.split(path.sep);

packages/openapi-ts/src/plugins/@tanstack/angular-query-experimental/types.d.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
import type { Plugin } from '../../types';
2+
import type { TanStackQuery } from '../query-core/types';
23

34
export interface Config
4-
extends Plugin.Name<'@tanstack/angular-query-experimental'> {
5-
/**
6-
* Should the exports from the generated files be re-exported in the index
7-
* barrel file?
8-
*
9-
* @default false
10-
*/
11-
exportFromIndex?: boolean;
5+
extends Plugin.Name<'@tanstack/angular-query-experimental'>,
6+
TanStackQuery.Config {
127
/**
138
* Generate {@link https://tanstack.com/query/v5/docs/framework/angular/reference/infiniteQueryOptions `infiniteQueryOptions()`} helpers? These will be generated from GET and POST requests where a pagination parameter is detected.
149
*

packages/openapi-ts/src/plugins/@tanstack/query-core/infiniteQueryOptions.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -185,15 +185,15 @@ const createInfiniteParamsFunction = ({
185185
}),
186186
}),
187187
compiler.returnVariable({
188-
expression: ts.factory.createAsExpression(
189-
ts.factory.createAsExpression(
190-
compiler.identifier({ text: 'params' }),
191-
ts.factory.createKeywordTypeNode(ts.SyntaxKind.UnknownKeyword),
192-
),
193-
ts.factory.createTypeQueryNode(
188+
expression: compiler.asExpression({
189+
expression: compiler.asExpression({
190+
expression: compiler.identifier({ text: 'params' }),
191+
type: compiler.keywordTypeNode({ keyword: 'unknown' }),
192+
}),
193+
type: ts.factory.createTypeQueryNode(
194194
compiler.identifier({ text: 'page' }),
195195
),
196-
),
196+
}),
197197
}),
198198
],
199199
types: [

0 commit comments

Comments
 (0)