fork of hey-api/openapi-ts because I need some additional things
1import { definePluginConfig, mappers } from '@hey-api/shared';
2
3import { handler } from './plugin';
4import type { PydanticPlugin } from './types';
5
6export const defaultConfig: PydanticPlugin['Config'] = {
7 config: {
8 case: 'PascalCase',
9 comments: true,
10 includeInEntry: false,
11 strict: false,
12 },
13 handler,
14 name: 'pydantic',
15 resolveConfig: (plugin, context) => {
16 plugin.config.definitions = context.valueToObject({
17 defaultValue: {
18 case: plugin.config.case ?? 'PascalCase',
19 enabled: true,
20 name: '{{name}}',
21 },
22 mappers,
23 value: plugin.config.definitions,
24 });
25
26 plugin.config.requests = context.valueToObject({
27 defaultValue: {
28 case: plugin.config.case ?? 'PascalCase',
29 enabled: true,
30 name: '{{name}}Request',
31 },
32 mappers,
33 value: plugin.config.requests,
34 });
35
36 plugin.config.responses = context.valueToObject({
37 defaultValue: {
38 case: plugin.config.case ?? 'PascalCase',
39 enabled: true,
40 name: '{{name}}Response',
41 },
42 mappers,
43 value: plugin.config.responses,
44 });
45
46 plugin.config.webhooks = context.valueToObject({
47 defaultValue: {
48 case: plugin.config.case ?? 'PascalCase',
49 enabled: true,
50 name: '{{name}}Webhook',
51 },
52 mappers,
53 value: plugin.config.webhooks,
54 });
55 },
56 tags: ['validator'],
57};
58
59/**
60 * Type helper for Pydantic plugin, returns {@link Plugin.Config} object
61 */
62export const defineConfig = definePluginConfig(defaultConfig);