fork of hey-api/openapi-ts because I need some additional things
1import type { SchemaWithType } from '@hey-api/shared';
2
3import type { Ast, IrSchemaToAstOptions } from '../../shared/types';
4import { objectToAst } from './object';
5import { stringToNode } from './string';
6
7export function irSchemaWithTypeToAst({
8 schema,
9 ...args
10}: IrSchemaToAstOptions & {
11 schema: SchemaWithType;
12}): Ast {
13 switch (schema.type) {
14 case 'object':
15 return objectToAst({
16 ...args,
17 schema: schema as SchemaWithType<'object'>,
18 });
19 case 'string':
20 return stringToNode({
21 ...args,
22 schema: schema as SchemaWithType<'string'>,
23 });
24 default:
25 return {
26 // expression: 'Any',
27 models: [],
28 typeAnnotation: 'Any',
29 };
30 }
31}