UNPKG

@tsed/schema

Version:
39 lines (38 loc) 1.21 kB
import { OS3MediaType } from "@tsed/openspec"; import { JsonMap } from "./JsonMap.js"; import { JsonSchema } from "./JsonSchema.js"; /** * Represents a media type definition for HTTP request or response bodies. * * JsonMedia encapsulates the schema and examples for a specific media type * (e.g., "application/json", "application/xml") in OpenAPI specifications. * It provides methods to configure the schema and examples for the media type. * * ### Usage * * ```typescript * const media = new JsonMedia(); * media.type(User); * media.examples({ * user1: { * value: {name: "John", email: "john@example.com"} * } * }); * ``` * * ### Key Features * * - **Schema Definition**: Associated JSON schema for validation * - **Examples**: Request/response examples for documentation * - **Type Handling**: Automatic schema generation from TypeScript types * - **Union Types**: Support for oneOf schemas with multiple types * * @public */ export declare class JsonMedia extends JsonMap<any> { $kind: string; constructor(obj?: Partial<OS3MediaType<JsonSchema>>); schema(schema?: JsonSchema): JsonSchema; examples(examples?: any): this; type(type: any): this; }