/** * XsdToJsonSchema — XSD → JSON Schema (Draft 7) converter * ────────────────────────────────────────────────────────── * Converts a compiled SchemaModel into a JSON Schema Draft 7 document. * * Mappings * ──────── * xs:complexType with sequence → { type: "object", properties: {…}, required: […] } * xs:complexType with choice → { oneOf: […] } * xs:simpleType with enumeration → { type: "string", enum: […] } * xs:simpleType with pattern → { type: "string", pattern: "…" } * xs:list → { type: "array", items: {…} } * xs:union → { anyOf: […] } * minOccurs=0 → not in required array * maxOccurs=unbounded → { type: "array", items: {…} } * Built-in XSD types → JSON Schema primitives * * Usage * ───── * import { generateJsonSchema } from 'xml-xsd-engine/codegen'; * * const jsonSchema = generateJsonSchema(schema); * // jsonSchema is a plain object compatible with ajv, jsonschema, etc. */ import { SchemaModel } from '../schema/SchemaModel'; export type JsonSchemaValue = string | number | boolean | null | JsonSchemaObject | JsonSchemaValue[]; export interface JsonSchemaObject { [key: string]: JsonSchemaValue; } export interface JsonSchemaDocument { $schema: string; $id?: string; title?: string; definitions?: { [name: string]: JsonSchemaObject; }; [key: string]: JsonSchemaValue | undefined | { [name: string]: JsonSchemaObject; }; } export interface XsdToJsonSchemaOptions { /** * JSON Schema draft URI. * Default: "http://json-schema.org/draft-07/schema#" */ draft?: string; /** * Base `$id` URI for the generated schema. * Default: undefined */ id?: string; /** * Title for the top-level schema object. * Default: undefined */ title?: string; /** * When true, emit a `definitions` block and use `$ref` for named types. * Default: true */ useDefinitions?: boolean; /** * When true, treat xs:any / anyAttribute as `additionalProperties: true`. * Default: true */ allowAdditional?: boolean; /** * Custom type map: XSD type key → JSON Schema fragment. */ typeMap?: Record; } export declare class XsdToJsonSchema { private schema; private opts; private typeMap; private definitions; constructor(schema: SchemaModel, options?: XsdToJsonSchemaOptions); generate(): JsonSchemaDocument; private _elementDeclToSchema; private _complexTypeToSchema; private _complexTypeBody; private _particleToSchema; private _simpleTypeToSchema; private _applyFacets; private _resolveTypeRef; private _attrTypeToSchema; private _defName; } /** * Convert a SchemaModel into a JSON Schema (Draft 7) document. * * @example * ```ts * import { parseXsd, generateJsonSchema } from 'xml-xsd-engine'; * const schema = parseXsd(xsdSource); * const jsonSchema = generateJsonSchema(schema); * ``` */ export declare function generateJsonSchema(schema: SchemaModel, options?: XsdToJsonSchemaOptions): JsonSchemaDocument; /** * P2: Stream JSON Schema generation as an `AsyncIterable`. * Yields the JSON Schema serialised in chunks to avoid holding a large * in-memory string for schemas with many type definitions. * * @example * ```ts * import { createWriteStream } from 'fs'; * const out = createWriteStream('schema.json'); * for await (const chunk of generateJsonSchemaStream(schema)) { * out.write(chunk); * } * out.end(); * ``` */ export declare function generateJsonSchemaStream(schema: SchemaModel, options?: XsdToJsonSchemaOptions): AsyncGenerator; //# sourceMappingURL=XsdToJsonSchema.d.ts.map