tangled
alpha
login
or
join now
mokkenstorm.dev
/
openapi-ts
0
fork
atom
fork of hey-api/openapi-ts because I need some additional things
0
fork
atom
overview
issues
pulls
pipelines
chore: pass plugin.output to path in context.createFile()
Lubos
1 year ago
22b113db
cefd05fe
+25
-23
16 changed files
expand all
collapse all
unified
split
packages
openapi-ts
src
plugins
@hey-api
schemas
config.ts
plugin.ts
services
config.ts
plugin.ts
transformers
config.ts
plugin.ts
types
config.ts
plugin.ts
@tanstack
angular-query-experimental
config.ts
react-query
config.ts
solid-query
config.ts
svelte-query
config.ts
vue-query
config.ts
fastify
config.ts
plugin.ts
types.d.ts
+1
-1
packages/openapi-ts/src/plugins/@hey-api/schemas/config.ts
···
13
13
};
14
14
15
15
/**
16
16
-
* Type helper for Hey API schemas plugin, returns {@link PluginConfig} object
16
16
+
* Type helper for `@hey-api/schemas` plugin, returns {@link PluginConfig} object
17
17
*/
18
18
export const defineConfig: DefineConfig<Config> = (config) => ({
19
19
...defaultConfig,
+2
-2
packages/openapi-ts/src/plugins/@hey-api/schemas/plugin.ts
···
291
291
}
292
292
};
293
293
294
294
-
export const handler: PluginHandler<Config> = ({ context }) => {
294
294
+
export const handler: PluginHandler<Config> = ({ context, plugin }) => {
295
295
context.createFile({
296
296
id: schemasId,
297
297
-
path: 'schemas',
297
297
+
path: plugin.output,
298
298
});
299
299
300
300
if (context.spec.openapi) {
+1
-1
packages/openapi-ts/src/plugins/@hey-api/services/config.ts
···
17
17
};
18
18
19
19
/**
20
20
-
* Type helper for Hey API services plugin, returns {@link PluginConfig} object
20
20
+
* Type helper for `@hey-api/services` plugin, returns {@link PluginConfig} object
21
21
*/
22
22
export const defineConfig: DefineConfig<Config> = (config) => ({
23
23
...defaultConfig,
+2
-2
packages/openapi-ts/src/plugins/@hey-api/services/plugin.ts
···
421
421
}
422
422
};
423
423
424
424
-
export const handler: PluginHandler<Config> = ({ context }) => {
424
424
+
export const handler: PluginHandler<Config> = ({ context, plugin }) => {
425
425
if (!context.config.client.name) {
426
426
throw new Error(
427
427
'🚫 client needs to be set to generate services - which HTTP client do you want to use?',
···
430
430
431
431
const file = context.createFile({
432
432
id: servicesId,
433
433
-
path: 'services',
433
433
+
path: plugin.output,
434
434
});
435
435
const servicesOutput = file.nameWithoutExtension();
436
436
+1
-1
packages/openapi-ts/src/plugins/@hey-api/transformers/config.ts
···
13
13
};
14
14
15
15
/**
16
16
-
* Type helper for Hey API transformers plugin, returns {@link PluginConfig} object
16
16
+
* Type helper for `@hey-api/transformers`, returns {@link PluginConfig} object
17
17
*/
18
18
export const defineConfig: DefineConfig<Config> = (config) => ({
19
19
...defaultConfig,
+2
-2
packages/openapi-ts/src/plugins/@hey-api/transformers/plugin.ts
···
356
356
};
357
357
358
358
// handles only response transformers for now
359
359
-
export const handler: PluginHandler<Config> = ({ context }) => {
359
359
+
export const handler: PluginHandler<Config> = ({ context, plugin }) => {
360
360
const file = context.createFile({
361
361
id: transformersId,
362
362
-
path: 'transformers',
362
362
+
path: plugin.output,
363
363
});
364
364
365
365
for (const path in context.ir.paths) {
+1
-1
packages/openapi-ts/src/plugins/@hey-api/types/config.ts
···
14
14
};
15
15
16
16
/**
17
17
-
* Type helper for Hey API types plugin, returns {@link PluginConfig} object
17
17
+
* Type helper for `@hey-api/types` plugin, returns {@link PluginConfig} object
18
18
*/
19
19
export const defineConfig: DefineConfig<Config> = (config) => ({
20
20
...defaultConfig,
+2
-2
packages/openapi-ts/src/plugins/@hey-api/types/plugin.ts
···
173
173
}
174
174
};
175
175
176
176
-
export const handler: PluginHandler<Config> = ({ context }) => {
176
176
+
export const handler: PluginHandler<Config> = ({ context, plugin }) => {
177
177
const file = context.createFile({
178
178
id: typesId,
179
179
-
path: 'types',
179
179
+
path: plugin.output,
180
180
});
181
181
const options: SchemaToTypeOptions = {
182
182
enums: context.config.plugins['@hey-api/types']?.enums,
+1
-1
packages/openapi-ts/src/plugins/@tanstack/angular-query-experimental/config.ts
···
15
15
};
16
16
17
17
/**
18
18
-
* Type helper for TanStack Angular Query Experimental plugin, returns {@link PluginConfig} object
18
18
+
* Type helper for `@tanstack/angular-query-experimental` plugin, returns {@link PluginConfig} object
19
19
*/
20
20
export const defineConfig: DefineConfig<Config> = (config) => ({
21
21
...defaultConfig,
+1
-1
packages/openapi-ts/src/plugins/@tanstack/react-query/config.ts
···
15
15
};
16
16
17
17
/**
18
18
-
* Type helper for TanStack React Query plugin, returns {@link PluginConfig} object
18
18
+
* Type helper for `@tanstack/react-query` plugin, returns {@link PluginConfig} object
19
19
*/
20
20
export const defineConfig: DefineConfig<Config> = (config) => ({
21
21
...defaultConfig,
+1
-1
packages/openapi-ts/src/plugins/@tanstack/solid-query/config.ts
···
15
15
};
16
16
17
17
/**
18
18
-
* Type helper for TanStack Solid Query plugin, returns {@link PluginConfig} object
18
18
+
* Type helper for `@tanstack/solid-query` plugin, returns {@link PluginConfig} object
19
19
*/
20
20
export const defineConfig: DefineConfig<Config> = (config) => ({
21
21
...defaultConfig,
+1
-1
packages/openapi-ts/src/plugins/@tanstack/svelte-query/config.ts
···
15
15
};
16
16
17
17
/**
18
18
-
* Type helper for TanStack Svelte Query plugin, returns {@link PluginConfig} object
18
18
+
* Type helper for `@tanstack/svelte-query` plugin, returns {@link PluginConfig} object
19
19
*/
20
20
export const defineConfig: DefineConfig<Config> = (config) => ({
21
21
...defaultConfig,
+1
-1
packages/openapi-ts/src/plugins/@tanstack/vue-query/config.ts
···
15
15
};
16
16
17
17
/**
18
18
-
* Type helper for TanStack Vue Query plugin, returns {@link PluginConfig} object
18
18
+
* Type helper for `@tanstack/vue-query` plugin, returns {@link PluginConfig} object
19
19
*/
20
20
export const defineConfig: DefineConfig<Config> = (config) => ({
21
21
...defaultConfig,
+1
-1
packages/openapi-ts/src/plugins/fastify/config.ts
···
12
12
};
13
13
14
14
/**
15
15
-
* Type helper for the Fastify plugin, returns {@link PluginConfig} object
15
15
+
* Type helper for `fastify` plugin, returns {@link PluginConfig} object
16
16
*/
17
17
export const defineConfig: DefineConfig<Config> = (config) => ({
18
18
...defaultConfig,
+7
-3
packages/openapi-ts/src/plugins/fastify/plugin.ts
···
17
17
} from '../utils/types';
18
18
import type { Config } from './types';
19
19
20
20
-
const FILE_ID = 'fastify';
20
20
+
const fastifyId = 'fastify';
21
21
const ROUTE_HANDLER_NAME = 'RouteHandler';
22
22
const OPERATIONS_IDENTIFIER = 'RouteHandlers';
23
23
const ROUTE_PROPERTY_NAME = {
···
154
154
}
155
155
}
156
156
157
157
-
const identifier = context.file({ id: FILE_ID })!.identifier({
157
157
+
const identifier = context.file({ id: fastifyId })!.identifier({
158
158
$ref: OPERATIONS_IDENTIFIER,
159
159
create: true,
160
160
namespace: 'type',
···
171
171
};
172
172
173
173
export const handler: PluginHandler<Config> = ({ context, plugin }) => {
174
174
-
const file = context.createFile({ id: FILE_ID, path: plugin.output });
174
174
+
const file = context.createFile({
175
175
+
id: fastifyId,
176
176
+
path: plugin.output,
177
177
+
});
178
178
+
175
179
const options: SchemaToTypeOptions = { file };
176
180
file.import({ asType: true, module: 'fastify', name: ROUTE_HANDLER_NAME });
177
181
componentsToType({
-2
packages/openapi-ts/src/plugins/fastify/types.d.ts
···
13
13
*/
14
14
output?: string;
15
15
}
16
16
-
17
17
-
export interface UserConfig extends Omit<Config, 'output'> {}