@zudojs/openapi 0.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +340 -21
  3. package/dist/index.d.ts +26 -21
  4. package/dist/index.js +31 -13
  5. package/dist/openApiComponents/index.d.ts +2 -2
  6. package/dist/openApiComponents/index.js +1 -1
  7. package/dist/openApiConstants/index.d.ts +1 -1
  8. package/dist/openApiConstants/index.js +1 -1
  9. package/dist/openApiConstants/openApiConstants.core.d.ts +15 -3
  10. package/dist/openApiConstants/openApiConstants.core.js +22 -3
  11. package/dist/openApiDocument/index.d.ts +1 -1
  12. package/dist/openApiDocument/index.js +1 -1
  13. package/dist/openApiDocument/openApiDocument.builder.d.ts +39 -52
  14. package/dist/openApiDocument/openApiDocument.builder.js +73 -72
  15. package/dist/openApiErrors/index.d.ts +2 -2
  16. package/dist/openApiErrors/index.js +2 -1
  17. package/dist/openApiErrors/openApiError.base.d.ts +9 -0
  18. package/dist/openApiErrors/openApiError.base.js +7 -0
  19. package/dist/openApiErrors/openApiError.types.d.ts +34 -14
  20. package/dist/openApiErrors/openApiError.types.js +83 -35
  21. package/dist/openApiHttp/index.d.ts +2 -2
  22. package/dist/openApiHttp/index.js +2 -2
  23. package/dist/openApiHttp/openApiHttpAdapter.core.d.ts +129 -25
  24. package/dist/openApiHttp/openApiHttpAdapter.core.js +226 -16
  25. package/dist/openApiRegistry/openApiRegistry.core.d.ts +47 -5
  26. package/dist/openApiRegistry/openApiRegistry.core.js +180 -66
  27. package/dist/openApiRegistry/openApiRegistry.type.d.ts +18 -13
  28. package/dist/openApiRegistry/openApiRegistry.type.js +1 -2
  29. package/dist/openApiRouting/index.d.ts +2 -2
  30. package/dist/openApiRouting/index.js +1 -1
  31. package/dist/openApiRouting/routeConverter.core.d.ts +25 -7
  32. package/dist/openApiRouting/routeConverter.core.js +104 -58
  33. package/dist/openApiRouting/routeMetadata.type.d.ts +40 -17
  34. package/dist/openApiRouting/routeMetadata.type.js +9 -0
  35. package/dist/openApiRouting/routeScanner.core.d.ts +17 -47
  36. package/dist/openApiRouting/routeScanner.core.js +40 -55
  37. package/dist/openApiSchema/index.d.ts +4 -4
  38. package/dist/openApiSchema/index.js +2 -2
  39. package/dist/openApiSchema/references.core.d.ts +18 -1
  40. package/dist/openApiSchema/references.core.js +21 -1
  41. package/dist/openApiSchema/schemaConverter.core.d.ts +61 -3
  42. package/dist/openApiSchema/schemaConverter.core.js +523 -117
  43. package/dist/openApiSchema/schemaRegistry.core.d.ts +27 -10
  44. package/dist/openApiSchema/schemaRegistry.core.js +33 -14
  45. package/dist/openApiSerialization/openApiSerializer.core.d.ts +10 -4
  46. package/dist/openApiSerialization/openApiSerializer.core.js +158 -9
  47. package/dist/openApiTypes/index.d.ts +1 -1
  48. package/dist/openApiTypes/openApiDocument.type.d.ts +16 -0
  49. package/dist/openApiTypes/openApiSchema.type.d.ts +24 -1
  50. package/dist/openApiTypes/openApiSchema.type.js +3 -0
  51. package/dist/openApiUi/index.d.ts +8 -0
  52. package/dist/openApiUi/index.js +8 -0
  53. package/dist/openApiUi/openApiUi.brand.d.ts +26 -0
  54. package/dist/openApiUi/openApiUi.brand.js +44 -0
  55. package/dist/openApiUi/openApiUi.core.d.ts +47 -0
  56. package/dist/openApiUi/openApiUi.core.js +157 -0
  57. package/dist/openApiValidation/index.d.ts +2 -2
  58. package/dist/openApiValidation/index.js +1 -1
  59. package/dist/openApiValidation/openApiValidator.core.d.ts +33 -11
  60. package/dist/openApiValidation/openApiValidator.core.js +295 -66
  61. package/package.json +29 -18
  62. package/dist/.tsbuildinfo +0 -1
  63. package/dist/index.d.ts.map +0 -1
  64. package/dist/index.js.map +0 -1
  65. package/dist/openApiComponents/index.d.ts.map +0 -1
  66. package/dist/openApiComponents/index.js.map +0 -1
  67. package/dist/openApiConstants/index.d.ts.map +0 -1
  68. package/dist/openApiConstants/index.js.map +0 -1
  69. package/dist/openApiConstants/openApiConstants.core.d.ts.map +0 -1
  70. package/dist/openApiConstants/openApiConstants.core.js.map +0 -1
  71. package/dist/openApiDocument/index.d.ts.map +0 -1
  72. package/dist/openApiDocument/index.js.map +0 -1
  73. package/dist/openApiDocument/openApiDocument.builder.d.ts.map +0 -1
  74. package/dist/openApiDocument/openApiDocument.builder.js.map +0 -1
  75. package/dist/openApiErrors/index.d.ts.map +0 -1
  76. package/dist/openApiErrors/index.js.map +0 -1
  77. package/dist/openApiErrors/openApiError.base.d.ts.map +0 -1
  78. package/dist/openApiErrors/openApiError.base.js.map +0 -1
  79. package/dist/openApiErrors/openApiError.core.d.ts.map +0 -1
  80. package/dist/openApiErrors/openApiError.core.js.map +0 -1
  81. package/dist/openApiErrors/openApiError.types.d.ts.map +0 -1
  82. package/dist/openApiErrors/openApiError.types.js.map +0 -1
  83. package/dist/openApiHttp/index.d.ts.map +0 -1
  84. package/dist/openApiHttp/index.js.map +0 -1
  85. package/dist/openApiHttp/openApiHttpAdapter.core.d.ts.map +0 -1
  86. package/dist/openApiHttp/openApiHttpAdapter.core.js.map +0 -1
  87. package/dist/openApiRegistry/index.d.ts.map +0 -1
  88. package/dist/openApiRegistry/index.js.map +0 -1
  89. package/dist/openApiRegistry/openApiRegistry.core.d.ts.map +0 -1
  90. package/dist/openApiRegistry/openApiRegistry.core.js.map +0 -1
  91. package/dist/openApiRegistry/openApiRegistry.type.d.ts.map +0 -1
  92. package/dist/openApiRegistry/openApiRegistry.type.js.map +0 -1
  93. package/dist/openApiRouting/index.d.ts.map +0 -1
  94. package/dist/openApiRouting/index.js.map +0 -1
  95. package/dist/openApiRouting/routeConverter.core.d.ts.map +0 -1
  96. package/dist/openApiRouting/routeConverter.core.js.map +0 -1
  97. package/dist/openApiRouting/routeMetadata.type.d.ts.map +0 -1
  98. package/dist/openApiRouting/routeMetadata.type.js.map +0 -1
  99. package/dist/openApiRouting/routeScanner.core.d.ts.map +0 -1
  100. package/dist/openApiRouting/routeScanner.core.js.map +0 -1
  101. package/dist/openApiSchema/index.d.ts.map +0 -1
  102. package/dist/openApiSchema/index.js.map +0 -1
  103. package/dist/openApiSchema/references.core.d.ts.map +0 -1
  104. package/dist/openApiSchema/references.core.js.map +0 -1
  105. package/dist/openApiSchema/schemaConverter.core.d.ts.map +0 -1
  106. package/dist/openApiSchema/schemaConverter.core.js.map +0 -1
  107. package/dist/openApiSchema/schemaRegistry.core.d.ts.map +0 -1
  108. package/dist/openApiSchema/schemaRegistry.core.js.map +0 -1
  109. package/dist/openApiSerialization/index.d.ts.map +0 -1
  110. package/dist/openApiSerialization/index.js.map +0 -1
  111. package/dist/openApiSerialization/openApiSerializer.core.d.ts.map +0 -1
  112. package/dist/openApiSerialization/openApiSerializer.core.js.map +0 -1
  113. package/dist/openApiTypes/index.d.ts.map +0 -1
  114. package/dist/openApiTypes/index.js.map +0 -1
  115. package/dist/openApiTypes/openApiComponent.type.d.ts.map +0 -1
  116. package/dist/openApiTypes/openApiComponent.type.js.map +0 -1
  117. package/dist/openApiTypes/openApiDocument.type.d.ts.map +0 -1
  118. package/dist/openApiTypes/openApiDocument.type.js.map +0 -1
  119. package/dist/openApiTypes/openApiPath.type.d.ts.map +0 -1
  120. package/dist/openApiTypes/openApiPath.type.js.map +0 -1
  121. package/dist/openApiTypes/openApiSchema.type.d.ts.map +0 -1
  122. package/dist/openApiTypes/openApiSchema.type.js.map +0 -1
  123. package/dist/openApiTypes/openApiSecurity.type.d.ts.map +0 -1
  124. package/dist/openApiTypes/openApiSecurity.type.js.map +0 -1
  125. package/dist/openApiTypes/openApiTypes.core.d.ts.map +0 -1
  126. package/dist/openApiTypes/openApiTypes.core.js.map +0 -1
  127. package/dist/openApiValidation/index.d.ts.map +0 -1
  128. package/dist/openApiValidation/index.js.map +0 -1
  129. package/dist/openApiValidation/openApiValidator.core.d.ts.map +0 -1
  130. package/dist/openApiValidation/openApiValidator.core.js.map +0 -1
@@ -1,27 +1,62 @@
1
1
  /**
2
2
  * Specific OpenAPI error subclasses.
3
+ *
4
+ * Each subclass supplies a default `code`, `statusCode` and `expose`, and each
5
+ * lets the caller override them — the options are spread *after* the defaults,
6
+ * so a value passed in is the value used.
3
7
  */
4
8
  import { OpenAPIError } from "./openApiError.base.js";
5
- /** Error thrown when OpenAPI validation fails. */
9
+ /** Renders an issue path the way a reader would write it. */
10
+ export function formatIssuePath(path) {
11
+ return path
12
+ .map((segment) => (typeof segment === "number" ? `[${segment}]` : segment))
13
+ .join(".")
14
+ .replace(/\.\[/g, "[");
15
+ }
16
+ /**
17
+ * Error thrown when OpenAPI validation fails.
18
+ *
19
+ * The issues are kept on the error. Discarding them left callers with the
20
+ * message "OpenAPI validation failed." and no way to learn what was wrong
21
+ * short of re-running the validator.
22
+ */
6
23
  export class OpenAPIValidationError extends OpenAPIError {
7
- constructor(message, issues, options = {}) {
24
+ issues;
25
+ constructor(message, issues = [], options = {}) {
8
26
  super(message, {
27
+ code: "OPENAPI_VALIDATION",
28
+ statusCode: 500,
29
+ expose: false,
9
30
  ...options,
10
- code: options.code ?? "OPENAPI_VALIDATION",
11
- statusCode: 400,
12
- expose: true,
31
+ metadata: {
32
+ issueCount: issues.length,
33
+ issues: issues.map((issue) => ({
34
+ path: formatIssuePath(issue.path),
35
+ message: issue.message,
36
+ severity: issue.severity,
37
+ })),
38
+ ...(options.metadata ?? {}),
39
+ },
13
40
  });
14
41
  this.name = "OpenAPIValidationError";
42
+ this.issues = Object.freeze([...issues]);
43
+ }
44
+ /** A multi-line summary suitable for a log line or a CLI. */
45
+ format() {
46
+ if (this.issues.length === 0)
47
+ return this.message;
48
+ const lines = this.issues.map((issue) => ` ${issue.severity}: ${formatIssuePath(issue.path)} — ${issue.message}`);
49
+ return [this.message, ...lines].join("\n");
15
50
  }
16
51
  }
17
52
  /** Error thrown when the OpenAPI document is invalid. */
18
53
  export class OpenAPIDocumentError extends OpenAPIError {
19
54
  constructor(message, options = {}) {
20
55
  super(message, {
21
- ...options,
22
- code: options.code ?? "OPENAPI_DOCUMENT",
56
+ code: "OPENAPI_DOCUMENT",
23
57
  statusCode: 500,
24
58
  expose: false,
59
+ ...options,
25
60
  });
26
61
  this.name = "OpenAPIDocumentError";
27
62
  }
@@ -30,46 +65,55 @@ export class OpenAPIDocumentError extends OpenAPIError {
30
65
  export class OpenAPIComponentError extends OpenAPIError {
31
66
  constructor(message, options = {}) {
32
67
  super(message, {
33
- ...options,
34
- code: options.code ?? "OPENAPI_COMPONENT",
68
+ code: "OPENAPI_COMPONENT",
35
69
  statusCode: 500,
36
70
  expose: false,
71
+ ...options,
37
72
  });
38
73
  this.name = "OpenAPIComponentError";
39
74
  }
40
75
  }
41
- /** Error thrown when an OpenAPI component conflicts with an existing component. */
76
+ /** Error thrown when a component name is already registered. */
42
77
  export class OpenAPIComponentConflictError extends OpenAPIError {
43
- constructor(message, options = {}) {
44
- super(message, {
78
+ section;
79
+ componentName;
80
+ constructor(section, componentName, options = {}) {
81
+ super(`A component named "${componentName}" is already registered under "${section}". ` +
82
+ `Component names must be unique within a section.`, {
83
+ code: "OPENAPI_COMPONENT_CONFLICT",
84
+ statusCode: 500,
85
+ expose: false,
45
86
  ...options,
46
- code: options.code ?? "OPENAPI_COMPONENT_CONFLICT",
47
- statusCode: 409,
48
- expose: true,
87
+ metadata: { section, componentName, ...(options.metadata ?? {}) },
49
88
  });
50
89
  this.name = "OpenAPIComponentConflictError";
90
+ this.section = section;
91
+ this.componentName = componentName;
51
92
  }
52
93
  }
53
- /** Error thrown when an OpenAPI reference is invalid. */
94
+ /** Error thrown when an OpenAPI reference is invalid or cannot be resolved. */
54
95
  export class OpenAPIReferenceError extends OpenAPIError {
55
- constructor(message, options = {}) {
56
- super(message, {
96
+ reference;
97
+ constructor(reference, options = {}) {
98
+ super(`Unresolvable OpenAPI reference: "${reference}".`, {
99
+ code: "OPENAPI_REFERENCE",
100
+ statusCode: 500,
101
+ expose: false,
57
102
  ...options,
58
- code: options.code ?? "OPENAPI_REFERENCE",
59
- statusCode: 400,
60
- expose: true,
103
+ metadata: { reference, ...(options.metadata ?? {}) },
61
104
  });
62
105
  this.name = "OpenAPIReferenceError";
106
+ this.reference = reference;
63
107
  }
64
108
  }
65
- /** Error thrown when an OpenAPI route is invalid. */
109
+ /** Error thrown when an OpenAPI route cannot be converted. */
66
110
  export class OpenAPIRouteError extends OpenAPIError {
67
111
  constructor(message, options = {}) {
68
112
  super(message, {
69
- ...options,
70
- code: options.code ?? "OPENAPI_ROUTE",
113
+ code: "OPENAPI_ROUTE",
71
114
  statusCode: 500,
72
115
  expose: false,
116
+ ...options,
73
117
  });
74
118
  this.name = "OpenAPIRouteError";
75
119
  }
@@ -78,10 +122,10 @@ export class OpenAPIRouteError extends OpenAPIError {
78
122
  export class OpenAPISchemaError extends OpenAPIError {
79
123
  constructor(message, options = {}) {
80
124
  super(message, {
81
- ...options,
82
- code: options.code ?? "OPENAPI_SCHEMA",
125
+ code: "OPENAPI_SCHEMA",
83
126
  statusCode: 500,
84
127
  expose: false,
128
+ ...options,
85
129
  });
86
130
  this.name = "OpenAPISchemaError";
87
131
  }
@@ -90,34 +134,38 @@ export class OpenAPISchemaError extends OpenAPIError {
90
134
  export class OpenAPISerializationError extends OpenAPIError {
91
135
  constructor(message, options = {}) {
92
136
  super(message, {
93
- ...options,
94
- code: options.code ?? "OPENAPI_SERIALIZATION",
137
+ code: "OPENAPI_SERIALIZATION",
95
138
  statusCode: 500,
96
139
  expose: false,
140
+ ...options,
97
141
  });
98
142
  this.name = "OpenAPISerializationError";
99
143
  }
100
144
  }
101
145
  /** Error thrown when the OpenAPI version is unsupported. */
102
146
  export class OpenAPIVersionError extends OpenAPIError {
103
- constructor(message, options = {}) {
104
- super(message, {
147
+ version;
148
+ constructor(version, supported = [], options = {}) {
149
+ super(`Unsupported OpenAPI version "${version}".` +
150
+ (supported.length > 0 ? ` Supported: ${supported.join(", ")}.` : ""), {
151
+ code: "OPENAPI_VERSION",
152
+ statusCode: 500,
153
+ expose: false,
105
154
  ...options,
106
- code: options.code ?? "OPENAPI_VERSION",
107
- statusCode: 400,
108
- expose: true,
155
+ metadata: { version, supported, ...(options.metadata ?? {}) },
109
156
  });
110
157
  this.name = "OpenAPIVersionError";
158
+ this.version = version;
111
159
  }
112
160
  }
113
161
  /** Error thrown when an OpenAPI operation is invalid. */
114
162
  export class OpenAPIOperationError extends OpenAPIError {
115
163
  constructor(message, options = {}) {
116
164
  super(message, {
117
- ...options,
118
- code: options.code ?? "OPENAPI_OPERATION",
165
+ code: "OPENAPI_OPERATION",
119
166
  statusCode: 500,
120
167
  expose: false,
168
+ ...options,
121
169
  });
122
170
  this.name = "OpenAPIOperationError";
123
171
  }
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @zudojs/openapi/openApiHttp
3
3
  *
4
- * HTTP integration for OpenAPI document serving.
4
+ * Document coordination and HTTP serving.
5
5
  */
6
- export { OpenAPIManager } from "./openApiHttpAdapter.core.js";
6
+ export { OpenAPIManager, createOpenAPIManager, type OpenAPIManagerOptions, type OpenAPIDocumentResponse, type OpenAPIUIResponse, } from "./openApiHttpAdapter.core.js";
7
7
  //# sourceMappingURL=index.d.ts.map
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @zudojs/openapi/openApiHttp
3
3
  *
4
- * HTTP integration for OpenAPI document serving.
4
+ * Document coordination and HTTP serving.
5
5
  */
6
- export { OpenAPIManager } from "./openApiHttpAdapter.core.js";
6
+ export { OpenAPIManager, createOpenAPIManager, } from "./openApiHttpAdapter.core.js";
7
7
  //# sourceMappingURL=index.js.map
@@ -1,38 +1,142 @@
1
- import type { OpenAPIDocument } from "../openApiTypes/openApiTypes.core.js";
2
- import { OpenAPIRegistryImpl } from "../openApiRegistry/openApiRegistry.core.js";
3
- import { OpenAPIRouteScannerImpl } from "../openApiRouting/routeScanner.core.js";
1
+ import type { OpenAPIDocument, OpenAPIInfo, OpenAPILogo, OpenAPISchema, OpenAPISecurityRequirement, OpenAPISecurityScheme, OpenAPIServer, OpenAPITag } from "../openApiTypes/openApiTypes.core.js";
2
+ import type { RouteInfo, OpenAPIHttpMethod } from "../openApiRouting/routeMetadata.type.js";
3
+ import { type OpenAPIValidationResult } from "../openApiValidation/openApiValidator.core.js";
4
+ import { type OpenAPIUIOptions } from "../openApiUi/openApiUi.core.js";
5
+ /** Options for {@link OpenAPIManager}. */
6
+ export interface OpenAPIManagerOptions {
7
+ /** Specification version to emit. Default: 3.1.0. */
8
+ readonly version?: string;
9
+ /** Document metadata. Without it the document is titled "API" at 0.0.0. */
10
+ readonly info?: OpenAPIInfo;
11
+ readonly servers?: readonly OpenAPIServer[];
12
+ readonly tags?: readonly OpenAPITag[];
13
+ readonly security?: readonly OpenAPISecurityRequirement[];
14
+ /**
15
+ * How long a generated document is reused before it is rebuilt, in ms.
16
+ * Default: five minutes. `0` disables caching. Mutating the manager
17
+ * invalidates the cache regardless.
18
+ */
19
+ readonly cacheTtlMs?: number;
20
+ /** Reports what a schema conversion could not express. */
21
+ readonly onSchemaWarning?: (name: string, warnings: readonly string[]) => void;
22
+ /** Supplies the clock, for tests. */
23
+ readonly now?: () => number;
24
+ /**
25
+ * Logo written to `info["x-logo"]` so viewers such as ReDoc and Scalar
26
+ * show it, and used by {@link OpenAPIManager.toUIResponse}.
27
+ * Default: the Zudo mark. Pass `false` to emit no logo, or an
28
+ * {@link OpenAPILogo} to use your own.
29
+ */
30
+ readonly branding?: boolean | OpenAPILogo;
31
+ }
32
+ /** An HTTP response carrying a rendered documentation page. */
33
+ export interface OpenAPIUIResponse {
34
+ readonly status: 200;
35
+ readonly headers: Readonly<Record<string, string>>;
36
+ readonly body: string;
37
+ }
38
+ /** An HTTP response carrying the specification document. */
39
+ export interface OpenAPIDocumentResponse {
40
+ readonly status: 200;
41
+ readonly headers: Readonly<Record<string, string>>;
42
+ readonly body: string;
43
+ }
4
44
  /**
5
- * High-level OpenAPI manager that coordinates generation, validation, and serving.
45
+ * High-level OpenAPI manager that coordinates generation, validation, and
46
+ * serving.
47
+ *
48
+ * Every mutation invalidates the cached document, so a route added after a
49
+ * first `generate()` appears in the next one, and regeneration is idempotent
50
+ * rather than throwing on the routes it registered last time.
6
51
  */
7
52
  export declare class OpenAPIManager {
8
53
  private readonly registry;
9
54
  private readonly scanner;
10
55
  private readonly validator;
56
+ private readonly schemas;
57
+ private readonly cacheTtlMs;
58
+ private readonly now;
59
+ private readonly logo;
60
+ /** True when `branding` was a caller-supplied logo rather than the default. */
61
+ private readonly customLogo;
11
62
  private cachedDocument?;
12
- constructor(version?: string);
13
- get registryInstance(): OpenAPIRegistryImpl;
14
- get scannerInstance(): OpenAPIRouteScannerImpl;
15
- addRoute(route: {
16
- readonly method: "get" | "put" | "post" | "delete" | "options" | "head" | "patch" | "trace";
17
- readonly path: string;
18
- readonly metadata?: {
19
- readonly openapi?: {
20
- readonly operationId?: string;
21
- readonly summary?: string;
22
- readonly description?: string;
23
- readonly tags?: readonly string[];
24
- readonly responses?: Record<string, unknown>;
25
- readonly requestBody?: unknown;
26
- readonly parameters?: readonly unknown[];
27
- readonly security?: readonly Record<string, readonly string[]>[];
28
- };
29
- };
30
- }): void;
31
- addSchema(name: string, schema: unknown): void;
63
+ private cachedAt;
64
+ /** Whether the cached document was produced by a validating generate. */
65
+ private cachedValidated;
66
+ constructor(versionOrOptions?: string | OpenAPIManagerOptions);
67
+ /** The document version this manager emits. */
68
+ get version(): string;
69
+ /** Sets the document's `info` object. */
70
+ setInfo(info: OpenAPIInfo): this;
71
+ addServer(server: OpenAPIServer): this;
72
+ addTag(tag: OpenAPITag): this;
73
+ addSecurityRequirement(requirement: OpenAPISecurityRequirement): this;
74
+ addSecurityScheme(name: string, scheme: OpenAPISecurityScheme): this;
75
+ /** Registers a route. Duplicate method+path combinations are rejected. */
76
+ addRoute(route: RouteInfo): this;
77
+ /** Registers a route, replacing any existing one for the same method+path. */
78
+ setRoute(route: RouteInfo): this;
79
+ /** Removes a route. Returns whether one was removed. */
80
+ removeRoute(method: OpenAPIHttpMethod, path: string): boolean;
81
+ /**
82
+ * Registers a component schema.
83
+ *
84
+ * `schema` is converted from a `@zudojs/schema` schema; pass an already
85
+ * converted {@link OpenAPISchema} to {@link OpenAPIManager.addRawSchema}.
86
+ */
87
+ addSchema(name: string, schema: unknown): this;
88
+ /** Registers an already-converted OpenAPI schema. */
89
+ addRawSchema(name: string, schema: OpenAPISchema): this;
90
+ /** Conversion warnings, keyed by component name. */
91
+ schemaWarnings(): ReadonlyMap<string, readonly string[]>;
92
+ /**
93
+ * Builds the document from the registered routes and components.
94
+ *
95
+ * Safe to call repeatedly: routes are replaced rather than re-added.
96
+ */
32
97
  generate(validate?: boolean): OpenAPIDocument;
33
- getDocument(validate?: boolean): Readonly<OpenAPIDocument>;
98
+ /**
99
+ * Returns the document, rebuilding it when the cache is stale, absent, or
100
+ * was produced without the validation this call asks for.
101
+ */
102
+ getDocument(validate?: boolean): OpenAPIDocument;
103
+ private isCacheFresh;
104
+ /** Validates the current document without throwing. */
105
+ validate(): OpenAPIValidationResult;
106
+ /** Drops the cached document. Called automatically by every mutation. */
107
+ invalidateCache(): this;
108
+ /** Drops every registered route, component and the cached document. */
109
+ reset(): this;
110
+ /**
111
+ * @deprecated Use {@link OpenAPIManager.reset} — the old name cleared all
112
+ * registered routes, which is not what "invalidate" suggests.
113
+ */
34
114
  invalidate(): void;
35
115
  toJSON(validate?: boolean): string;
36
116
  toYAML(validate?: boolean): string;
117
+ /**
118
+ * Builds an HTTP response carrying the document.
119
+ *
120
+ * Framework-agnostic on purpose: `{ status, headers, body }` is what every
121
+ * adapter in this monorepo can turn into its own response type.
122
+ */
123
+ toResponse(options?: {
124
+ readonly format?: "json" | "yaml";
125
+ readonly validate?: boolean;
126
+ readonly cacheControl?: string;
127
+ }): OpenAPIDocumentResponse;
128
+ /**
129
+ * Builds an HTTP response carrying a branded documentation page (Swagger UI
130
+ * by default, ReDoc on request) that loads the specification from
131
+ * `options.specUrl`. Pair it with {@link OpenAPIManager.toResponse}:
132
+ *
133
+ * ```ts
134
+ * app.get("/openapi.json", () => manager.toResponse());
135
+ * app.get("/docs", () => manager.toUIResponse({ specUrl: "/openapi.json" }));
136
+ * ```
137
+ */
138
+ toUIResponse(options: OpenAPIUIOptions): OpenAPIUIResponse;
37
139
  }
140
+ /** Creates an OpenAPI manager. */
141
+ export declare function createOpenAPIManager(options?: OpenAPIManagerOptions): OpenAPIManager;
38
142
  //# sourceMappingURL=openApiHttpAdapter.core.d.ts.map