@zudojs/openapi 1.5.2 → 1.6.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.
- package/README.md +5 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/openApiComponents/index.d.ts +0 -1
- package/dist/openApiComponents/index.js +0 -1
- package/dist/openApiConstants/index.d.ts +0 -1
- package/dist/openApiConstants/index.js +0 -1
- package/dist/openApiConstants/openApiConstants.core.d.ts +0 -1
- package/dist/openApiConstants/openApiConstants.core.js +0 -1
- package/dist/openApiDocument/index.d.ts +0 -1
- package/dist/openApiDocument/index.js +0 -1
- package/dist/openApiDocument/openApiDocument.builder.d.ts +0 -1
- package/dist/openApiDocument/openApiDocument.builder.js +0 -1
- package/dist/openApiErrors/index.d.ts +0 -1
- package/dist/openApiErrors/index.js +0 -1
- package/dist/openApiErrors/openApiError.base.d.ts +0 -1
- package/dist/openApiErrors/openApiError.base.js +0 -1
- package/dist/openApiErrors/openApiError.core.d.ts +0 -1
- package/dist/openApiErrors/openApiError.core.js +0 -1
- package/dist/openApiErrors/openApiError.types.d.ts +0 -1
- package/dist/openApiErrors/openApiError.types.js +0 -1
- package/dist/openApiFromRoutes/index.d.ts +0 -1
- package/dist/openApiFromRoutes/index.js +0 -1
- package/dist/openApiFromRoutes/openApiFromRoutes.document.d.ts +0 -1
- package/dist/openApiFromRoutes/openApiFromRoutes.document.js +0 -1
- package/dist/openApiFromRoutes/openApiFromRoutes.type.d.ts +0 -1
- package/dist/openApiFromRoutes/openApiFromRoutes.type.js +0 -1
- package/dist/openApiHttp/index.d.ts +0 -1
- package/dist/openApiHttp/index.js +0 -1
- package/dist/openApiHttp/openApiHttpAdapter.core.d.ts +9 -1
- package/dist/openApiHttp/openApiHttpAdapter.core.js +4 -1
- package/dist/openApiRegistry/index.d.ts +0 -1
- package/dist/openApiRegistry/index.js +0 -1
- package/dist/openApiRegistry/openApiRegistry.core.d.ts +0 -1
- package/dist/openApiRegistry/openApiRegistry.core.js +0 -1
- package/dist/openApiRegistry/openApiRegistry.type.d.ts +0 -1
- package/dist/openApiRegistry/openApiRegistry.type.js +0 -1
- package/dist/openApiRouting/index.d.ts +0 -1
- package/dist/openApiRouting/index.js +0 -1
- package/dist/openApiRouting/routeContent.core.d.ts +0 -1
- package/dist/openApiRouting/routeContent.core.js +0 -1
- package/dist/openApiRouting/routeConverter.core.d.ts +0 -1
- package/dist/openApiRouting/routeConverter.core.js +0 -1
- package/dist/openApiRouting/routeMetadata.type.d.ts +0 -1
- package/dist/openApiRouting/routeMetadata.type.js +0 -1
- package/dist/openApiRouting/routeScanner.core.d.ts +0 -1
- package/dist/openApiRouting/routeScanner.core.js +0 -1
- package/dist/openApiRouting/routeSchema.core.d.ts +0 -1
- package/dist/openApiRouting/routeSchema.core.js +0 -1
- package/dist/openApiSchema/index.d.ts +0 -1
- package/dist/openApiSchema/index.js +0 -1
- package/dist/openApiSchema/references.core.d.ts +0 -1
- package/dist/openApiSchema/references.core.js +0 -1
- package/dist/openApiSchema/schemaConverter.core.d.ts +11 -1
- package/dist/openApiSchema/schemaConverter.core.js +12 -3
- package/dist/openApiSchema/schemaInput.core.d.ts +6 -1
- package/dist/openApiSchema/schemaInput.core.js +4 -2
- package/dist/openApiSchema/schemaInput.type.d.ts +0 -1
- package/dist/openApiSchema/schemaInput.type.js +0 -1
- package/dist/openApiSchema/schemaRegistry.core.d.ts +0 -1
- package/dist/openApiSchema/schemaRegistry.core.js +0 -1
- package/dist/openApiSerialization/index.d.ts +0 -1
- package/dist/openApiSerialization/index.js +0 -1
- package/dist/openApiSerialization/openApiSerializer.core.d.ts +0 -1
- package/dist/openApiSerialization/openApiSerializer.core.js +0 -1
- package/dist/openApiTypes/index.d.ts +0 -1
- package/dist/openApiTypes/index.js +0 -1
- package/dist/openApiTypes/openApiComponent.type.d.ts +0 -1
- package/dist/openApiTypes/openApiComponent.type.js +0 -1
- package/dist/openApiTypes/openApiDocument.type.d.ts +0 -1
- package/dist/openApiTypes/openApiDocument.type.js +0 -1
- package/dist/openApiTypes/openApiPath.type.d.ts +0 -1
- package/dist/openApiTypes/openApiPath.type.js +0 -1
- package/dist/openApiTypes/openApiSchema.type.d.ts +0 -1
- package/dist/openApiTypes/openApiSchema.type.js +0 -1
- package/dist/openApiTypes/openApiSecurity.type.d.ts +0 -1
- package/dist/openApiTypes/openApiSecurity.type.js +0 -1
- package/dist/openApiTypes/openApiTypes.core.d.ts +0 -1
- package/dist/openApiTypes/openApiTypes.core.js +0 -1
- package/dist/openApiUi/index.d.ts +0 -1
- package/dist/openApiUi/index.js +0 -1
- package/dist/openApiUi/openApiUi.assets.d.ts +0 -1
- package/dist/openApiUi/openApiUi.assets.js +0 -1
- package/dist/openApiUi/openApiUi.brand.d.ts +0 -1
- package/dist/openApiUi/openApiUi.brand.js +0 -1
- package/dist/openApiUi/openApiUi.core.d.ts +0 -1
- package/dist/openApiUi/openApiUi.core.js +0 -1
- package/dist/openApiUi/openApiUi.csp.d.ts +0 -1
- package/dist/openApiUi/openApiUi.csp.js +0 -1
- package/dist/openApiUi/openApiUiPage/index.d.ts +0 -1
- package/dist/openApiUi/openApiUiPage/index.js +0 -1
- package/dist/openApiUi/openApiUiPage/openApiUiPage.script.d.ts +0 -1
- package/dist/openApiUi/openApiUiPage/openApiUiPage.script.js +0 -1
- package/dist/openApiUi/openApiUiPage/openApiUiPage.theme.d.ts +0 -1
- package/dist/openApiUi/openApiUiPage/openApiUiPage.theme.js +0 -1
- package/dist/openApiValidation/index.d.ts +0 -1
- package/dist/openApiValidation/index.js +0 -1
- package/dist/openApiValidation/openApiValidator.core.d.ts +0 -1
- package/dist/openApiValidation/openApiValidator.core.js +0 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -301,7 +301,11 @@ items unless the schema sets its own `.max()`. The emitted `maxLength` /
|
|
|
301
301
|
`maxItems` carry that effective limit (read from `@zudojs/constants`'
|
|
302
302
|
`SCHEMA_DEFAULT_MAX_STRING_LENGTH` / `SCHEMA_DEFAULT_MAX_ARRAY_LENGTH`, the same
|
|
303
303
|
constants the parser uses), so a client generated from the document is never
|
|
304
|
-
told it may send a payload the server rejects.
|
|
304
|
+
told it may send a payload the server rejects. To emit only the bounds a
|
|
305
|
+
schema declares explicitly, pass `implicitLimits: false` — to
|
|
306
|
+
`createOpenAPIManager`, `createOpenAPIDocumentFromRoutes`, `convertSchema` or
|
|
307
|
+
`resolveSchemaInput`; a string with its own `.max(40)` keeps `maxLength: 40`
|
|
308
|
+
either way.
|
|
305
309
|
|
|
306
310
|
A property is listed in `required` exactly when the object parser rejects
|
|
307
311
|
its absence: fields wrapped in `optional`, fields with a `default`, and
|
package/dist/index.d.ts
CHANGED
|
@@ -56,4 +56,3 @@ export type { OpenAPIValidator, OpenAPIValidationResult, } from "./openApiValida
|
|
|
56
56
|
export { toOpenAPIJSON, toOpenAPIYAML, } from "./openApiSerialization/openApiSerializer.core.js";
|
|
57
57
|
export { OpenAPIManager, createOpenAPIManager, type OpenAPIManagerOptions, type OpenAPIDocumentResponse, type OpenAPIUIResponse, } from "./openApiHttp/index.js";
|
|
58
58
|
export type { OpenAPIVersion, OpenAPIDocument, OpenAPIComponents, OpenAPISecurityRequirement, OpenAPIParameterLocation, OpenAPIResponse, OpenAPIParameter, OpenAPIRequestBody, OpenAPIMediaType, OpenAPIEncoding, OpenAPIHeader, OpenAPILink, OpenAPIExample, OpenAPIPaths, OpenAPIPathItem, OpenAPIOperation, OpenAPIResponses, OpenAPIServer, OpenAPIServerVariable, OpenAPIInfo, OpenAPILogo, OpenAPIContact, OpenAPILicense, OpenAPIExternalDocumentation, OpenAPISchema, OpenAPIDiscriminator, OpenAPIXml, OpenAPISecurityScheme, OpenAPIOAuthFlows, OpenAPIOAuthFlow, OpenAPITag, OpenAPIReference, } from "./openApiTypes/openApiTypes.core.js";
|
|
59
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -61,4 +61,3 @@ export { OpenAPIValidatorImpl, createOpenAPIValidator, } from "./openApiValidati
|
|
|
61
61
|
export { toOpenAPIJSON, toOpenAPIYAML, } from "./openApiSerialization/openApiSerializer.core.js";
|
|
62
62
|
/* ─── Manager ───────────────────────────────────────────────────────────── */
|
|
63
63
|
export { OpenAPIManager, createOpenAPIManager, } from "./openApiHttp/index.js";
|
|
64
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -6,4 +6,3 @@
|
|
|
6
6
|
export { createComponentReference, escapeJsonPointerSegment, unescapeJsonPointerSegment, type ComponentSection, } from "../openApiSchema/references.core.js";
|
|
7
7
|
export type { SchemaRegistry, SchemaRegistryOptions, } from "../openApiSchema/schemaRegistry.core.js";
|
|
8
8
|
export { SchemaRegistryImpl } from "../openApiSchema/schemaRegistry.core.js";
|
|
9
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -2,4 +2,3 @@
|
|
|
2
2
|
* @zudojs/openapi/openApiConstants
|
|
3
3
|
*/
|
|
4
4
|
export { DEFAULT_OPENAPI_VERSION, SUPPORTED_OPENAPI_VERSIONS, MAX_OPERATION_ID_LENGTH, COMPONENT_REF_PREFIX, DEFAULT_MEDIA_TYPE, STATUS_CODE_CATEGORIES, RESPONSE_KEY_PATTERN, PATH_TEMPLATE_PARAMETER, DEFAULT_SERVER_URL, DOCUMENT_CACHE_TTL_MS, UNDOCUMENTED_RESPONSE_DESCRIPTION, } from "./openApiConstants.core.js";
|
|
5
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -2,4 +2,3 @@
|
|
|
2
2
|
* @zudojs/openapi/openApiConstants
|
|
3
3
|
*/
|
|
4
4
|
export { DEFAULT_OPENAPI_VERSION, SUPPORTED_OPENAPI_VERSIONS, MAX_OPERATION_ID_LENGTH, COMPONENT_REF_PREFIX, DEFAULT_MEDIA_TYPE, STATUS_CODE_CATEGORIES, RESPONSE_KEY_PATTERN, PATH_TEMPLATE_PARAMETER, DEFAULT_SERVER_URL, DOCUMENT_CACHE_TTL_MS, UNDOCUMENTED_RESPONSE_DESCRIPTION, } from "./openApiConstants.core.js";
|
|
5
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -5,4 +5,3 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export { OpenAPIError, createOpenAPIError, isOpenAPIError, type OpenAPIErrorOptions, } from "./openApiError.base.js";
|
|
7
7
|
export { OpenAPIValidationError, OpenAPIDocumentError, OpenAPIComponentError, OpenAPIComponentConflictError, OpenAPIReferenceError, OpenAPIRouteError, OpenAPISchemaError, OpenAPISerializationError, OpenAPIVersionError, OpenAPIOperationError, formatIssuePath, type OpenAPIValidationIssue, } from "./openApiError.types.js";
|
|
8
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -5,4 +5,3 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export { OpenAPIError, createOpenAPIError, isOpenAPIError, } from "./openApiError.base.js";
|
|
7
7
|
export { OpenAPIValidationError, OpenAPIDocumentError, OpenAPIComponentError, OpenAPIComponentConflictError, OpenAPIReferenceError, OpenAPIRouteError, OpenAPISchemaError, OpenAPISerializationError, OpenAPIVersionError, OpenAPIOperationError, formatIssuePath, } from "./openApiError.types.js";
|
|
8
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -20,4 +20,3 @@ export { OpenAPIError, type OpenAPIErrorOptions };
|
|
|
20
20
|
export declare function createOpenAPIError(message: string, options?: OpenAPIErrorOptions): OpenAPIError;
|
|
21
21
|
/** Determines whether an unknown value is an OpenAPI error. */
|
|
22
22
|
export declare function isOpenAPIError(value: unknown): value is OpenAPIError;
|
|
23
|
-
//# sourceMappingURL=openApiError.base.d.ts.map
|
|
@@ -8,4 +8,3 @@
|
|
|
8
8
|
*/
|
|
9
9
|
export type { OpenAPIRouteDescriptor, OpenAPIDocumentFromRoutesOptions, } from "./openApiFromRoutes.type.js";
|
|
10
10
|
export { createOpenAPIDocumentFromRoutes, createOpenAPIManagerFromRoutes, routeDescriptorToRouteInfo, } from "./openApiFromRoutes.document.js";
|
|
11
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -40,4 +40,3 @@ export declare function createOpenAPIManagerFromRoutes(routes: readonly OpenAPIR
|
|
|
40
40
|
* is invalid.
|
|
41
41
|
*/
|
|
42
42
|
export declare function createOpenAPIDocumentFromRoutes(routes: readonly OpenAPIRouteDescriptor[], options: OpenAPIDocumentFromRoutesOptions): OpenAPIDocument;
|
|
43
|
-
//# sourceMappingURL=openApiFromRoutes.document.d.ts.map
|
|
@@ -61,4 +61,3 @@ export function createOpenAPIManagerFromRoutes(routes, options) {
|
|
|
61
61
|
export function createOpenAPIDocumentFromRoutes(routes, options) {
|
|
62
62
|
return createOpenAPIManagerFromRoutes(routes, options).generate(options.validate ?? false);
|
|
63
63
|
}
|
|
64
|
-
//# sourceMappingURL=openApiFromRoutes.document.js.map
|
|
@@ -33,6 +33,14 @@ export interface OpenAPIManagerOptions {
|
|
|
33
33
|
readonly onRouteWarning?: (message: string) => void;
|
|
34
34
|
/** Supplies the clock, for tests. */
|
|
35
35
|
readonly now?: () => number;
|
|
36
|
+
/**
|
|
37
|
+
* Whether `@zudojs/schema`'s implicit ceilings — 255 characters for a
|
|
38
|
+
* string and 1000 items for an array without their own `.max()` — are
|
|
39
|
+
* written into the document as `maxLength` / `maxItems`. Default: true,
|
|
40
|
+
* because the parser enforces them, so the document states what the API
|
|
41
|
+
* accepts. Set `false` to emit only explicitly declared bounds.
|
|
42
|
+
*/
|
|
43
|
+
readonly implicitLimits?: boolean;
|
|
36
44
|
/**
|
|
37
45
|
* Logo written to `info["x-logo"]` so viewers such as ReDoc and Scalar
|
|
38
46
|
* show it, and used by {@link OpenAPIManager.toUIResponse}.
|
|
@@ -73,6 +81,7 @@ export declare class OpenAPIManager {
|
|
|
73
81
|
private readonly customLogo;
|
|
74
82
|
private readonly onSchemaWarning;
|
|
75
83
|
private readonly onRouteWarning;
|
|
84
|
+
private readonly implicitLimits;
|
|
76
85
|
private lastRouteWarnings;
|
|
77
86
|
private cachedDocument?;
|
|
78
87
|
private cachedAt;
|
|
@@ -166,4 +175,3 @@ export declare class OpenAPIManager {
|
|
|
166
175
|
}
|
|
167
176
|
/** Creates an OpenAPI manager. */
|
|
168
177
|
export declare function createOpenAPIManager(options?: OpenAPIManagerOptions): OpenAPIManager;
|
|
169
|
-
//# sourceMappingURL=openApiHttpAdapter.core.d.ts.map
|
|
@@ -26,6 +26,7 @@ export class OpenAPIManager {
|
|
|
26
26
|
customLogo;
|
|
27
27
|
onSchemaWarning;
|
|
28
28
|
onRouteWarning;
|
|
29
|
+
implicitLimits;
|
|
29
30
|
lastRouteWarnings = [];
|
|
30
31
|
cachedDocument;
|
|
31
32
|
cachedAt = 0;
|
|
@@ -41,7 +42,9 @@ export class OpenAPIManager {
|
|
|
41
42
|
this.schemas = new SchemaRegistryImpl({
|
|
42
43
|
version: options.version ?? DEFAULT_OPENAPI_VERSION,
|
|
43
44
|
onWarning: options.onSchemaWarning,
|
|
45
|
+
implicitLimits: options.implicitLimits,
|
|
44
46
|
});
|
|
47
|
+
this.implicitLimits = options.implicitLimits;
|
|
45
48
|
this.onSchemaWarning = options.onSchemaWarning;
|
|
46
49
|
this.onRouteWarning = options.onRouteWarning;
|
|
47
50
|
this.cacheTtlMs = options.cacheTtlMs ?? DOCUMENT_CACHE_TTL_MS;
|
|
@@ -164,6 +167,7 @@ export class OpenAPIManager {
|
|
|
164
167
|
const routeWarnings = [];
|
|
165
168
|
const scanned = this.scanner.scan({
|
|
166
169
|
version: this.registry.version,
|
|
170
|
+
implicitLimits: this.implicitLimits,
|
|
167
171
|
onWarning: (message) => {
|
|
168
172
|
routeWarnings.push(message);
|
|
169
173
|
this.onRouteWarning?.(message);
|
|
@@ -317,4 +321,3 @@ export class OpenAPIManager {
|
|
|
317
321
|
export function createOpenAPIManager(options) {
|
|
318
322
|
return new OpenAPIManager(options ?? {});
|
|
319
323
|
}
|
|
320
|
-
//# sourceMappingURL=openApiHttpAdapter.core.js.map
|
|
@@ -8,4 +8,3 @@ export { toOpenAPIPath, extractPathParameters, convertRouteToOpenAPI, buildRespo
|
|
|
8
8
|
export { OpenAPIRouteScannerImpl } from "./routeScanner.core.js";
|
|
9
9
|
export { buildOperationParameters } from "./routeSchema.core.js";
|
|
10
10
|
export { buildOperationRequestBody, buildOperationResponses, describeResponseKey, } from "./routeContent.core.js";
|
|
11
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -7,4 +7,3 @@ export { toOpenAPIPath, extractPathParameters, convertRouteToOpenAPI, buildRespo
|
|
|
7
7
|
export { OpenAPIRouteScannerImpl } from "./routeScanner.core.js";
|
|
8
8
|
export { buildOperationParameters } from "./routeSchema.core.js";
|
|
9
9
|
export { buildOperationRequestBody, buildOperationResponses, describeResponseKey, } from "./routeContent.core.js";
|
|
10
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -19,4 +19,3 @@ export declare function buildOperationRequestBody(meta: RouteOpenAPIMetadata | u
|
|
|
19
19
|
* through `options.onWarning`. No status is invented.
|
|
20
20
|
*/
|
|
21
21
|
export declare function buildOperationResponses(meta: RouteOpenAPIMetadata | undefined, context: string, options?: RouteConversionOptions): OpenAPIResponses;
|
|
22
|
-
//# sourceMappingURL=routeContent.core.d.ts.map
|
|
@@ -16,4 +16,3 @@ import type { RouteConversionOptions, RouteOpenAPIMetadata } from "./routeMetada
|
|
|
16
16
|
* a document that cannot validate.
|
|
17
17
|
*/
|
|
18
18
|
export declare function buildOperationParameters(slots: readonly string[], meta: RouteOpenAPIMetadata | undefined, context: string, options?: RouteConversionOptions): readonly OpenAPIParameter[];
|
|
19
|
-
//# sourceMappingURL=routeSchema.core.d.ts.map
|
|
@@ -9,4 +9,3 @@ export type { SchemaRegistry, SchemaRegistryOptions, } from "./schemaRegistry.co
|
|
|
9
9
|
export { SchemaRegistryImpl } from "./schemaRegistry.core.js";
|
|
10
10
|
export { createComponentReference, escapeJsonPointerSegment, unescapeJsonPointerSegment, type ComponentSection, } from "./references.core.js";
|
|
11
11
|
export { isSchemaDefinition, resolveSchemaInput, type SchemaInputOptions, } from "./schemaInput.core.js";
|
|
12
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -7,4 +7,3 @@ export { convertSchema, createSchemaConverter, isVersion31, } from "./schemaConv
|
|
|
7
7
|
export { SchemaRegistryImpl } from "./schemaRegistry.core.js";
|
|
8
8
|
export { createComponentReference, escapeJsonPointerSegment, unescapeJsonPointerSegment, } from "./references.core.js";
|
|
9
9
|
export { isSchemaDefinition, resolveSchemaInput, } from "./schemaInput.core.js";
|
|
10
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -23,4 +23,3 @@ export declare function unescapeJsonPointerSegment(segment: string): string;
|
|
|
23
23
|
* @param name - The component name
|
|
24
24
|
*/
|
|
25
25
|
export declare function createComponentReference(section: ComponentSection | string, name: string): OpenAPIReference;
|
|
26
|
-
//# sourceMappingURL=references.core.d.ts.map
|
|
@@ -52,6 +52,17 @@ export interface SchemaConversionOptions {
|
|
|
52
52
|
* schema whose `lazy` wrapper resolves to itself. Default: 32.
|
|
53
53
|
*/
|
|
54
54
|
readonly maxDepth?: number;
|
|
55
|
+
/**
|
|
56
|
+
* Whether the parser's implicit ceilings are written into the document.
|
|
57
|
+
*
|
|
58
|
+
* `@zudojs/schema` rejects a string longer than
|
|
59
|
+
* `SCHEMA_DEFAULT_MAX_STRING_LENGTH` (255) and an array longer than
|
|
60
|
+
* `SCHEMA_DEFAULT_MAX_ARRAY_LENGTH` (1000) unless the schema sets its own
|
|
61
|
+
* `.max()`, so by default (`true`) the emitted `maxLength` / `maxItems`
|
|
62
|
+
* states what the API actually accepts. Set `false` to emit only the
|
|
63
|
+
* bounds the schema declares explicitly.
|
|
64
|
+
*/
|
|
65
|
+
readonly implicitLimits?: boolean;
|
|
55
66
|
}
|
|
56
67
|
/** True when the document being produced follows OpenAPI 3.1 or later. */
|
|
57
68
|
export declare function isVersion31(version: string): boolean;
|
|
@@ -69,4 +80,3 @@ export interface SchemaConverter {
|
|
|
69
80
|
}
|
|
70
81
|
/** Creates a converter bound to a specification version. */
|
|
71
82
|
export declare function createSchemaConverter(defaults?: SchemaConversionOptions): SchemaConverter;
|
|
72
|
-
//# sourceMappingURL=schemaConverter.core.d.ts.map
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { SCHEMA_DEFAULT_MAX_ARRAY_LENGTH, SCHEMA_DEFAULT_MAX_STRING_LENGTH, } from "@zudojs/constants";
|
|
2
2
|
import { DEFAULT_OPENAPI_VERSION } from "../openApiConstants/openApiConstants.core.js";
|
|
3
|
+
/**
|
|
4
|
+
* An upper bound to emit: the schema's own when it declares one, else the
|
|
5
|
+
* parser's implicit ceiling when `implicitLimits` is on, else nothing.
|
|
6
|
+
*/
|
|
7
|
+
function bound(keyword, declared, implicit, state) {
|
|
8
|
+
if (declared !== undefined)
|
|
9
|
+
return { [keyword]: declared };
|
|
10
|
+
return state.implicitLimits ? { [keyword]: implicit } : {};
|
|
11
|
+
}
|
|
3
12
|
/** Maps `@zudojs/schema` string formats onto OpenAPI `format` values. */
|
|
4
13
|
const STRING_FORMATS = {
|
|
5
14
|
email: "email",
|
|
@@ -156,7 +165,7 @@ function convertString(schema, state) {
|
|
|
156
165
|
? { minLength: exact, maxLength: exact }
|
|
157
166
|
: {
|
|
158
167
|
...(num(c["min"]) !== undefined ? { minLength: num(c["min"]) } : {}),
|
|
159
|
-
maxLength
|
|
168
|
+
...bound("maxLength", num(c["max"]), SCHEMA_DEFAULT_MAX_STRING_LENGTH, state),
|
|
160
169
|
}),
|
|
161
170
|
...(pattern instanceof RegExp
|
|
162
171
|
? { pattern: pattern.source }
|
|
@@ -343,7 +352,7 @@ function convertSchemaNode(schema, state) {
|
|
|
343
352
|
...(num(c["min"]) !== undefined
|
|
344
353
|
? { minItems: num(c["min"]) }
|
|
345
354
|
: {}),
|
|
346
|
-
maxItems
|
|
355
|
+
...bound("maxItems", num(c["max"]), SCHEMA_DEFAULT_MAX_ARRAY_LENGTH, state),
|
|
347
356
|
}),
|
|
348
357
|
};
|
|
349
358
|
}
|
|
@@ -537,6 +546,7 @@ export function convertSchema(input, options) {
|
|
|
537
546
|
visited: new Set(),
|
|
538
547
|
version: options?.version ?? DEFAULT_OPENAPI_VERSION,
|
|
539
548
|
maxDepth: options?.maxDepth ?? 32,
|
|
549
|
+
implicitLimits: options?.implicitLimits ?? true,
|
|
540
550
|
depth: 0,
|
|
541
551
|
};
|
|
542
552
|
const schema = convertNode(input, state);
|
|
@@ -548,4 +558,3 @@ export function createSchemaConverter(defaults) {
|
|
|
548
558
|
convert: (input, options) => convertSchema(input, { ...defaults, ...options }),
|
|
549
559
|
};
|
|
550
560
|
}
|
|
551
|
-
//# sourceMappingURL=schemaConverter.core.js.map
|
|
@@ -11,6 +11,12 @@ export interface SchemaInputOptions {
|
|
|
11
11
|
readonly version?: string;
|
|
12
12
|
/** Receives everything a conversion could not express exactly. */
|
|
13
13
|
readonly onWarning?: (message: string) => void;
|
|
14
|
+
/**
|
|
15
|
+
* Whether the parser's implicit string and array ceilings are emitted as
|
|
16
|
+
* `maxLength` / `maxItems`. Default: true. See
|
|
17
|
+
* `SchemaConversionOptions.implicitLimits`.
|
|
18
|
+
*/
|
|
19
|
+
readonly implicitLimits?: boolean;
|
|
14
20
|
}
|
|
15
21
|
/** True when `value` is a `@zudojs/schema` schema (it carries a string `_type`). */
|
|
16
22
|
export declare function isSchemaDefinition(value: unknown): value is {
|
|
@@ -25,4 +31,3 @@ export declare function isSchemaDefinition(value: unknown): value is {
|
|
|
25
31
|
* becomes `{}`.
|
|
26
32
|
*/
|
|
27
33
|
export declare function resolveSchemaInput(input: unknown, context: string, options?: SchemaInputOptions): OpenAPISchema;
|
|
28
|
-
//# sourceMappingURL=schemaInput.core.d.ts.map
|
|
@@ -21,7 +21,10 @@ export function isSchemaDefinition(value) {
|
|
|
21
21
|
*/
|
|
22
22
|
export function resolveSchemaInput(input, context, options = {}) {
|
|
23
23
|
if (isSchemaDefinition(input)) {
|
|
24
|
-
const result = convertSchema(input, {
|
|
24
|
+
const result = convertSchema(input, {
|
|
25
|
+
version: options.version,
|
|
26
|
+
implicitLimits: options.implicitLimits,
|
|
27
|
+
});
|
|
25
28
|
for (const warning of result.warnings) {
|
|
26
29
|
options.onWarning?.(`${context}: ${warning}`);
|
|
27
30
|
}
|
|
@@ -33,4 +36,3 @@ export function resolveSchemaInput(input, context, options = {}) {
|
|
|
33
36
|
options.onWarning?.(`${context}: expected a schema, got ${typeof input}; emitted {}.`);
|
|
34
37
|
return {};
|
|
35
38
|
}
|
|
36
|
-
//# sourceMappingURL=schemaInput.core.js.map
|
|
@@ -172,4 +172,3 @@ export function toOpenAPIYAML(document) {
|
|
|
172
172
|
throw new OpenAPISerializationError(`Failed to serialize the OpenAPI document to YAML: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
|
-
//# sourceMappingURL=openApiSerializer.core.js.map
|
|
@@ -4,4 +4,3 @@
|
|
|
4
4
|
* Core OpenAPI specification types.
|
|
5
5
|
*/
|
|
6
6
|
export type { OpenAPIVersion, OpenAPIDocument, OpenAPIComponents, OpenAPISecurityRequirement, OpenAPIParameterLocation, OpenAPIResponse, OpenAPIParameter, OpenAPIRequestBody, OpenAPIMediaType, OpenAPIEncoding, OpenAPIHeader, OpenAPILink, OpenAPIExample, OpenAPIPaths, OpenAPIPathItem, OpenAPIOperation, OpenAPIResponses, OpenAPIServer, OpenAPIServerVariable, OpenAPIInfo, OpenAPILogo, OpenAPIContact, OpenAPILicense, OpenAPIExternalDocumentation, OpenAPISchema, OpenAPIDiscriminator, OpenAPIXml, OpenAPISecurityScheme, OpenAPIOAuthFlows, OpenAPIOAuthFlow, OpenAPITag, OpenAPIReference, } from "./openApiTypes.core.js";
|
|
7
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -45,4 +45,3 @@ export interface OpenAPIParameter {
|
|
|
45
45
|
readonly content?: Readonly<Record<string, import("./openApiComponent.type.js").OpenAPIMediaType>>;
|
|
46
46
|
}
|
|
47
47
|
export type OpenAPIParameterLocation = "query" | "header" | "path" | "cookie";
|
|
48
|
-
//# sourceMappingURL=openApiPath.type.d.ts.map
|
|
@@ -7,4 +7,3 @@ export { renderOpenAPIUI, zudoLogo, escapeHtml, type OpenAPIUIOptions, type Open
|
|
|
7
7
|
export { ZUDO_MARK_SVG, ZUDO_MARK_DARK_SVG, ZUDO_WORDMARK_SVG, ZUDO_WORDMARK_DARK_SVG, ZUDO_FAVICON_SVG, ZUDO_MARK_DATA_URI, ZUDO_MARK_DARK_DATA_URI, ZUDO_WORDMARK_DATA_URI, ZUDO_WORDMARK_DARK_DATA_URI, ZUDO_FAVICON_DATA_URI, ZUDO_SITE_URL, svgToDataUri, } from "./openApiUi.brand.js";
|
|
8
8
|
export { SWAGGER_UI_VERSION, REDOC_VERSION, DEFAULT_SWAGGER_ASSETS, DEFAULT_REDOC_ASSETS, SWAGGER_UI_INTEGRITY, REDOC_INTEGRITY, type OpenAPIUIAssetIntegrity, } from "./openApiUi.assets.js";
|
|
9
9
|
export { buildOpenAPIUIContentSecurityPolicy } from "./openApiUi.csp.js";
|
|
10
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/openApiUi/index.js
CHANGED
|
@@ -7,4 +7,3 @@ export { renderOpenAPIUI, zudoLogo, escapeHtml, } from "./openApiUi.core.js";
|
|
|
7
7
|
export { ZUDO_MARK_SVG, ZUDO_MARK_DARK_SVG, ZUDO_WORDMARK_SVG, ZUDO_WORDMARK_DARK_SVG, ZUDO_FAVICON_SVG, ZUDO_MARK_DATA_URI, ZUDO_MARK_DARK_DATA_URI, ZUDO_WORDMARK_DATA_URI, ZUDO_WORDMARK_DARK_DATA_URI, ZUDO_FAVICON_DATA_URI, ZUDO_SITE_URL, svgToDataUri, } from "./openApiUi.brand.js";
|
|
8
8
|
export { SWAGGER_UI_VERSION, REDOC_VERSION, DEFAULT_SWAGGER_ASSETS, DEFAULT_REDOC_ASSETS, SWAGGER_UI_INTEGRITY, REDOC_INTEGRITY, } from "./openApiUi.assets.js";
|
|
9
9
|
export { buildOpenAPIUIContentSecurityPolicy } from "./openApiUi.csp.js";
|
|
10
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -38,4 +38,3 @@ export declare const REDOC_INTEGRITY: OpenAPIUIAssetIntegrity;
|
|
|
38
38
|
* not a well-formed SRI token, since it is interpolated into an attribute.
|
|
39
39
|
*/
|
|
40
40
|
export declare function integrityAttrs(hash: string | undefined): string;
|
|
41
|
-
//# sourceMappingURL=openApiUi.assets.d.ts.map
|
|
@@ -23,4 +23,3 @@ export declare const ZUDO_WORDMARK_DARK_DATA_URI: string;
|
|
|
23
23
|
export declare const ZUDO_FAVICON_DATA_URI: string;
|
|
24
24
|
/** Where the logo links by default. */
|
|
25
25
|
export declare const ZUDO_SITE_URL = "https://zudojs.oyinlola.site";
|
|
26
|
-
//# sourceMappingURL=openApiUi.brand.d.ts.map
|
|
@@ -41,4 +41,3 @@ export const ZUDO_WORDMARK_DARK_DATA_URI = svgToDataUri(ZUDO_WORDMARK_DARK_SVG);
|
|
|
41
41
|
export const ZUDO_FAVICON_DATA_URI = svgToDataUri(ZUDO_FAVICON_SVG);
|
|
42
42
|
/** Where the logo links by default. */
|
|
43
43
|
export const ZUDO_SITE_URL = "https://zudojs.oyinlola.site";
|
|
44
|
-
//# sourceMappingURL=openApiUi.brand.js.map
|
|
@@ -63,4 +63,3 @@ export declare function zudoLogo(overrides?: Partial<OpenAPILogo>): OpenAPILogo;
|
|
|
63
63
|
export declare function escapeHtml(value: string): string;
|
|
64
64
|
/** Renders a complete, branded documentation page for `options.specUrl`. */
|
|
65
65
|
export declare function renderOpenAPIUI(options: OpenAPIUIOptions): string;
|
|
66
|
-
//# sourceMappingURL=openApiUi.core.d.ts.map
|
|
@@ -22,4 +22,3 @@ export declare function cspSourceFor(url: string): string | undefined;
|
|
|
22
22
|
export declare function buildOpenAPIUIContentSecurityPolicy(options: OpenAPIUIOptions, connectSources?: readonly string[]): string;
|
|
23
23
|
/** Every `servers[].url` in a document: top level, path items and operations. */
|
|
24
24
|
export declare function documentServerUrls(document: OpenAPIDocument): string[];
|
|
25
|
-
//# sourceMappingURL=openApiUi.csp.d.ts.map
|
|
@@ -3,4 +3,3 @@
|
|
|
3
3
|
*/
|
|
4
4
|
/** Built-in page CSS; `customCss` is appended after it. */
|
|
5
5
|
export declare const THEME_CSS = "\n:root{--zd-ink:#1A1A2E;--zd-red:#C0392B;--zd-bg:#FAFAF9;--zd-border:#E5E7EB}\n*{border-radius:0!important}\nhtml,body{margin:0;background:var(--zd-bg);font-family:Inter,system-ui,-apple-system,\"Segoe UI\",sans-serif}\n.zudo-bar{position:sticky;top:0;z-index:50;display:flex;align-items:center;gap:14px;height:56px;padding:0 20px;background:var(--zd-ink);color:var(--zd-bg);border-bottom:3px solid var(--zd-red)}\n.zudo-bar a{display:inline-flex;align-items:center;color:inherit;text-decoration:none}\n.zudo-bar img{height:22px;width:auto;display:block}\n.zudo-bar .zudo-sep{width:1px;height:22px;background:rgba(250,250,249,.25)}\n.zudo-bar .zudo-title{font-weight:800;font-size:14px;letter-spacing:.02em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}\n.zudo-bar .zudo-spec{margin-left:auto;font:700 11px/1 ui-monospace,SFMono-Regular,Menlo,monospace;letter-spacing:.06em;text-transform:uppercase;color:rgba(250,250,249,.75);border:2px solid rgba(250,250,249,.3);padding:6px 10px}\n.zudo-bar .zudo-spec:hover{border-color:var(--zd-bg);color:var(--zd-bg)}\n.zudo-foot{padding:16px 20px;border-top:1px solid var(--zd-border);color:#6B7280;font-size:12px;display:flex;gap:8px;align-items:center}\n.zudo-foot img{height:14px;width:auto}\n.swagger-ui .topbar{display:none}\n.swagger-ui .info .title{font-weight:900;letter-spacing:-.01em;color:var(--zd-ink)}\n.swagger-ui .opblock{border-width:2px;box-shadow:none}\n.swagger-ui .btn{border-width:2px;font-weight:700}\n.swagger-ui .btn.execute{background:var(--zd-red);border-color:var(--zd-red)}\n.swagger-ui .scheme-container{box-shadow:none;border-bottom:1px solid var(--zd-border);background:#fff}\n";
|
|
6
|
-
//# sourceMappingURL=openApiUiPage.theme.d.ts.map
|
|
@@ -22,4 +22,3 @@ html,body{margin:0;background:var(--zd-bg);font-family:Inter,system-ui,-apple-sy
|
|
|
22
22
|
.swagger-ui .btn.execute{background:var(--zd-red);border-color:var(--zd-red)}
|
|
23
23
|
.swagger-ui .scheme-container{box-shadow:none;border-bottom:1px solid var(--zd-border);background:#fff}
|
|
24
24
|
`;
|
|
25
|
-
//# sourceMappingURL=openApiUiPage.theme.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zudojs/openapi",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "OpenAPI 3.0 and 3.1 specification generation, validation, and serialization for Zudojs applications.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -26,12 +26,12 @@
|
|
|
26
26
|
"!dist/.tsbuildinfo"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@zudojs/constants": "1.
|
|
30
|
-
"@zudojs/errors": "1.
|
|
29
|
+
"@zudojs/constants": "1.2.0",
|
|
30
|
+
"@zudojs/errors": "1.4.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/node": "^26.6.2",
|
|
34
|
-
"@zudojs/schema": "1.
|
|
34
|
+
"@zudojs/schema": "1.3.0",
|
|
35
35
|
"typescript": "7.0.2",
|
|
36
36
|
"vitest": "^5.0.1"
|
|
37
37
|
},
|