fork of hey-api/openapi-ts because I need some additional things
1import type { SchemaWithType } from '@hey-api/shared';
2
3import { $ } from '../../../../py-dsl';
4import type { UndefinedResolverContext } from '../../resolvers';
5import type { PydanticType } from '../../shared/types';
6import type { PydanticPlugin } from '../../types';
7
8// eslint-disable-next-line @typescript-eslint/no-unused-vars
9function baseNode(_ctx: UndefinedResolverContext): PydanticType {
10 return {
11 type: 'None',
12 };
13}
14
15function undefinedResolver(ctx: UndefinedResolverContext): PydanticType {
16 return ctx.nodes.base(ctx);
17}
18
19export function undefinedToType({
20 plugin,
21 schema,
22}: {
23 plugin: PydanticPlugin['Instance'];
24 schema: SchemaWithType<'undefined'>;
25}): PydanticType {
26 const ctx: UndefinedResolverContext = {
27 $,
28 nodes: {
29 base: baseNode,
30 },
31 plugin,
32 schema,
33 };
34
35 const resolver = plugin.config['~resolvers']?.undefined;
36 return resolver?.(ctx) ?? undefinedResolver(ctx);
37}