JSON Schema unit formatted for OpenAPI v3.0 specification.

This interface represents a single JSON schema unit that complies with OpenAPI v3.0 standards. It contains one schema definition along with any reusable components that the schema references, formatted according to OpenAPI v3.0 constraints and limitations.

OpenAPI v3.0 characteristics affecting this unit:

  • Schema follows OpenAPI v3.0 JSON Schema subset
  • Limited support for advanced JSON Schema features
  • Uses nullable property for optional null values
  • Cannot natively express tuple types or pattern properties
  • Based on JSON Schema Draft 4 with OpenAPI-specific extensions

Use cases for v3.0:

  • Integration with legacy Swagger tooling
  • Compatibility with older OpenAPI implementations
  • Systems that specifically require OpenAPI v3.0 format
  • Code generation tools that expect v3.0 schemas
interface IV3_0<Type> {
    __type?: Type;
    components: IComponents;
    schema: IJsonSchema;
    version: "3.0";
}

Type Parameters

  • Type

    The original TypeScript type represented by this schema unit. Provides compile-time type information and enables type-safe operations on the schema.

Properties

__type?: Type

Type metadata for compile-time type safety.

This optional property maintains a reference to the original TypeScript type that was used to generate this schema unit. It provides compile-time type information without affecting the runtime JSON representation.

Benefits of type metadata:

  • Enables type-safe schema validation and usage
  • Provides IDE intellisense and autocompletion
  • Allows compile-time checking of schema operations
  • Maintains traceability to original TypeScript definitions

The property is intentionally marked as optional and undefined to ensure it doesn't appear in serialized JSON output while preserving type information at compile time.

components: IComponents

Reusable schema components for OpenAPI v3.0.

Contains all reusable schema definitions and components that may be referenced by the main schema. This enables schema modularity and prevents duplication when the same types are used in multiple places within the schema definition.

Component categories include:

  • schemas: Named type definitions for complex objects, arrays, and unions
  • securitySchemes: Authentication and authorization definitions
  • parameters: Reusable parameter specifications
  • requestBodies: Reusable request body definitions
  • responses: Reusable response specifications
  • headers: Reusable header definitions
  • examples: Reusable example values

All components follow OpenAPI v3.0 format restrictions and capabilities.

schema: IJsonSchema

The primary JSON schema definition.

Contains the main JSON schema that represents the TypeScript type specified in the Type template parameter. This schema follows OpenAPI v3.0 format and may contain references to reusable components defined in the components property.

The schema structure includes:

  • Type definitions following OpenAPI v3.0 constraints
  • Property definitions with v3.0-compatible validation rules
  • References to shared components using $ref syntax
  • Nullable properties for optional fields that can be null

Example schema reference: { "$ref": "#/components/schemas/NestedType" }

version: "3.0"

OpenAPI specification version identifier.

Always set to "3.0" to indicate this schema unit uses OpenAPI v3.0 format and adheres to its specific constraints and limitations.