Refactor OpenAPI schemas and type definitions across versions 2.0, 3.0, and 3.1 for improved clarity and consistency. Update example files and tests to align with the latest specifications. Adjust package dependencies and enhance README documentation for better guidance on usage and testing.

This commit is contained in:
Luke Hagar
2025-09-30 20:36:16 +00:00
parent 4a82aa3b32
commit 3e81d0b30d
100 changed files with 141724 additions and 157789 deletions

View File

@@ -84,123 +84,123 @@ import type { XML } from "../xml";
* ```
*/
export interface CompositionSchema extends Extension {
/**
* An array of schemas that must all be satisfied.
* The value must conform to all schemas in the array.
*
* Example: `[{ type: "object" }, { properties: { name: { type: "string" } } }]`
*/
allOf?: unknown[];
/**
* An array of schemas that must all be satisfied.
* The value must conform to all schemas in the array.
*
* Example: `[{ type: "object" }, { properties: { name: { type: "string" } } }]`
*/
allOf?: unknown[];
/**
* An array of schemas where at least one must be satisfied.
* The value must conform to at least one schema in the array.
*
* Example: `[{ type: "string" }, { type: "number" }]`
*/
anyOf?: unknown[];
/**
* An array of schemas where at least one must be satisfied.
* The value must conform to at least one schema in the array.
*
* Example: `[{ type: "string" }, { type: "number" }]`
*/
anyOf?: unknown[];
/**
* An array of schemas where exactly one must be satisfied.
* The value must conform to exactly one schema in the array.
*
* Example: `[{ type: "string" }, { type: "number" }]`
*/
oneOf?: unknown[];
/**
* An array of schemas where exactly one must be satisfied.
* The value must conform to exactly one schema in the array.
*
* Example: `[{ type: "string" }, { type: "number" }]`
*/
oneOf?: unknown[];
/**
* A schema that must not be satisfied.
* The value must not conform to this schema.
*
* Example: `{ type: "string" }`
*/
not?: unknown;
/**
* A schema that must not be satisfied.
* The value must not conform to this schema.
*
* Example: `{ type: "string" }`
*/
not?: unknown;
/**
* A schema for conditional validation.
* Used with `then` and `else` for conditional logic.
*
* Example: `{ type: "object", properties: { type: { const: "user" } } }`
*/
if?: unknown;
/**
* A schema for conditional validation.
* Used with `then` and `else` for conditional logic.
*
* Example: `{ type: "object", properties: { type: { const: "user" } } }`
*/
if?: unknown;
/**
* A schema to apply if the `if` condition is met.
* The value must conform to this schema if the `if` schema is satisfied.
*
* Example: `{ type: "object", properties: { name: { type: "string" } } }`
*/
then?: unknown;
/**
* A schema to apply if the `if` condition is met.
* The value must conform to this schema if the `if` schema is satisfied.
*
* Example: `{ type: "object", properties: { name: { type: "string" } } }`
*/
then?: unknown;
/**
* A schema to apply if the `if` condition is not met.
* The value must conform to this schema if the `if` schema is not satisfied.
*
* Example: `{ type: "object", properties: { id: { type: "string" } } }`
*/
else?: unknown;
/**
* A schema to apply if the `if` condition is not met.
* The value must conform to this schema if the `if` schema is not satisfied.
*
* Example: `{ type: "object", properties: { id: { type: "string" } } }`
*/
else?: unknown;
/**
* An array of allowed values.
* The value must be one of the values in this array.
*
* Example: `["active", "inactive"]`
*/
enum?: unknown[];
/**
* An array of allowed values.
* The value must be one of the values in this array.
*
* Example: `["active", "inactive"]`
*/
enum?: unknown[];
/**
* A single allowed value.
* The value must be exactly this value.
*
* Example: `"active"`
*/
const?: unknown;
/**
* A single allowed value.
* The value must be exactly this value.
*
* Example: `"active"`
*/
const?: unknown;
/**
* An example value for the composition.
* This is for documentation purposes only.
*
* Example: `"example"`
*/
example?: unknown;
/**
* An example value for the composition.
* This is for documentation purposes only.
*
* Example: `"example"`
*/
example?: unknown;
/**
* An array of example values.
* These are for documentation purposes only.
*
* Example: `["example1", "example2"]`
*/
examples?: unknown[];
/**
* An array of example values.
* These are for documentation purposes only.
*
* Example: `["example1", "example2"]`
*/
examples?: unknown[];
/**
* The default value.
* This value will be used if no value is provided.
*
* Example: `"default"`
*/
default?: unknown;
/**
* The default value.
* This value will be used if no value is provided.
*
* Example: `"default"`
*/
default?: unknown;
/**
* A short title for the schema.
* This is for documentation purposes only.
*
* Example: `"Composed Schema"`
*/
title?: string;
/**
* A short title for the schema.
* This is for documentation purposes only.
*
* Example: `"Composed Schema"`
*/
title?: string;
/**
* A description of the schema.
* CommonMark syntax MAY be used for rich text representation.
*
* Example: `"A schema composed of multiple schemas"`
*/
description?: string;
/**
* A description of the schema.
* CommonMark syntax MAY be used for rich text representation.
*
* Example: `"A schema composed of multiple schemas"`
*/
description?: string;
/**
* XML representation metadata for the schema.
* Allows for fine-tuned XML model definitions.
*
* Example: `{ name: "composedSchema", attribute: false }`
*/
xml?: XML;
/**
* XML representation metadata for the schema.
* Allows for fine-tuned XML model definitions.
*
* Example: `{ name: "composedSchema", attribute: false }`
*/
xml?: XML;
}