* Compile a JSON Schema into a TypeScript type via `json-schema-to-typescript`. * Returns `'unknown'` for absent/non-object schemas. The compiled output is an * `export interface { ... }` declaration which callers inline via * inlineBody.
( schema: unknown, typeName: string, )
| 29 | * {@link inlineBody}. |
| 30 | */ |
| 31 | async function schemaToType( |
| 32 | schema: unknown, |
| 33 | typeName: string, |
| 34 | ): Promise<string> { |
| 35 | if (!schema || typeof schema !== 'object') return 'unknown' |
| 36 | const compiled = await compile(schema, typeName, { |
| 37 | bannerComment: '', |
| 38 | additionalProperties: false, |
| 39 | declareExternallyReferenced: true, |
| 40 | }) |
| 41 | return compiled.trim() |
| 42 | } |
| 43 | |
| 44 | export interface EmitInput { |
| 45 | [serverName: string]: { prefix?: string; surface: ServerSurface } |