Something went wrong. Try again.
fork of hey-api/openapi-ts because I need some additional things
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152import type { IR } from '@hey-api/shared';
import type { PydanticMeta, PydanticResult } from './types';
/** * Creates default metadata from a schema. */export function defaultMeta(schema: IR.SchemaObject): PydanticMeta { return { default: schema.default, hasForwardReference: false, nullable: false, readonly: schema.accessScope === 'read', };}
/** * Composes metadata from child results. * * @param children - Results from walking child schemas * @param overrides - Explicit overrides (e.g., from parent schema) */export function composeMeta( children: ReadonlyArray<PydanticResult>, overrides?: Partial<PydanticMeta>,): PydanticMeta { return { default: overrides?.default, hasForwardReference: overrides?.hasForwardReference ?? children.some((c) => c.meta.hasForwardReference), nullable: overrides?.nullable ?? children.some((c) => c.meta.nullable), readonly: overrides?.readonly ?? children.some((c) => c.meta.readonly), };}
/** * Merges parent schema metadata with composed child metadata. * * @param parent - The parent schema * @param children - Results from walking child schemas */export function inheritMeta( parent: IR.SchemaObject, children: ReadonlyArray<PydanticResult>,): PydanticMeta { return composeMeta(children, { default: parent.default, nullable: false, readonly: parent.accessScope === 'read', });}