@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.
- package/LICENSE +21 -0
- package/README.md +340 -21
- package/dist/index.d.ts +26 -21
- package/dist/index.js +31 -13
- package/dist/openApiComponents/index.d.ts +2 -2
- package/dist/openApiComponents/index.js +1 -1
- package/dist/openApiConstants/index.d.ts +1 -1
- package/dist/openApiConstants/index.js +1 -1
- package/dist/openApiConstants/openApiConstants.core.d.ts +15 -3
- package/dist/openApiConstants/openApiConstants.core.js +22 -3
- package/dist/openApiDocument/index.d.ts +1 -1
- package/dist/openApiDocument/index.js +1 -1
- package/dist/openApiDocument/openApiDocument.builder.d.ts +39 -52
- package/dist/openApiDocument/openApiDocument.builder.js +73 -72
- package/dist/openApiErrors/index.d.ts +2 -2
- package/dist/openApiErrors/index.js +2 -1
- package/dist/openApiErrors/openApiError.base.d.ts +9 -0
- package/dist/openApiErrors/openApiError.base.js +7 -0
- package/dist/openApiErrors/openApiError.types.d.ts +34 -14
- package/dist/openApiErrors/openApiError.types.js +83 -35
- package/dist/openApiHttp/index.d.ts +2 -2
- package/dist/openApiHttp/index.js +2 -2
- package/dist/openApiHttp/openApiHttpAdapter.core.d.ts +129 -25
- package/dist/openApiHttp/openApiHttpAdapter.core.js +226 -16
- package/dist/openApiRegistry/openApiRegistry.core.d.ts +47 -5
- package/dist/openApiRegistry/openApiRegistry.core.js +180 -66
- package/dist/openApiRegistry/openApiRegistry.type.d.ts +18 -13
- package/dist/openApiRegistry/openApiRegistry.type.js +1 -2
- package/dist/openApiRouting/index.d.ts +2 -2
- package/dist/openApiRouting/index.js +1 -1
- package/dist/openApiRouting/routeConverter.core.d.ts +25 -7
- package/dist/openApiRouting/routeConverter.core.js +104 -58
- package/dist/openApiRouting/routeMetadata.type.d.ts +40 -17
- package/dist/openApiRouting/routeMetadata.type.js +9 -0
- package/dist/openApiRouting/routeScanner.core.d.ts +17 -47
- package/dist/openApiRouting/routeScanner.core.js +40 -55
- package/dist/openApiSchema/index.d.ts +4 -4
- package/dist/openApiSchema/index.js +2 -2
- package/dist/openApiSchema/references.core.d.ts +18 -1
- package/dist/openApiSchema/references.core.js +21 -1
- package/dist/openApiSchema/schemaConverter.core.d.ts +61 -3
- package/dist/openApiSchema/schemaConverter.core.js +523 -117
- package/dist/openApiSchema/schemaRegistry.core.d.ts +27 -10
- package/dist/openApiSchema/schemaRegistry.core.js +33 -14
- package/dist/openApiSerialization/openApiSerializer.core.d.ts +10 -4
- package/dist/openApiSerialization/openApiSerializer.core.js +158 -9
- package/dist/openApiTypes/index.d.ts +1 -1
- package/dist/openApiTypes/openApiDocument.type.d.ts +16 -0
- package/dist/openApiTypes/openApiSchema.type.d.ts +24 -1
- package/dist/openApiTypes/openApiSchema.type.js +3 -0
- package/dist/openApiUi/index.d.ts +8 -0
- package/dist/openApiUi/index.js +8 -0
- package/dist/openApiUi/openApiUi.brand.d.ts +26 -0
- package/dist/openApiUi/openApiUi.brand.js +44 -0
- package/dist/openApiUi/openApiUi.core.d.ts +47 -0
- package/dist/openApiUi/openApiUi.core.js +157 -0
- package/dist/openApiValidation/index.d.ts +2 -2
- package/dist/openApiValidation/index.js +1 -1
- package/dist/openApiValidation/openApiValidator.core.d.ts +33 -11
- package/dist/openApiValidation/openApiValidator.core.js +295 -66
- package/package.json +29 -18
- package/dist/.tsbuildinfo +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/openApiComponents/index.d.ts.map +0 -1
- package/dist/openApiComponents/index.js.map +0 -1
- package/dist/openApiConstants/index.d.ts.map +0 -1
- package/dist/openApiConstants/index.js.map +0 -1
- package/dist/openApiConstants/openApiConstants.core.d.ts.map +0 -1
- package/dist/openApiConstants/openApiConstants.core.js.map +0 -1
- package/dist/openApiDocument/index.d.ts.map +0 -1
- package/dist/openApiDocument/index.js.map +0 -1
- package/dist/openApiDocument/openApiDocument.builder.d.ts.map +0 -1
- package/dist/openApiDocument/openApiDocument.builder.js.map +0 -1
- package/dist/openApiErrors/index.d.ts.map +0 -1
- package/dist/openApiErrors/index.js.map +0 -1
- package/dist/openApiErrors/openApiError.base.d.ts.map +0 -1
- package/dist/openApiErrors/openApiError.base.js.map +0 -1
- package/dist/openApiErrors/openApiError.core.d.ts.map +0 -1
- package/dist/openApiErrors/openApiError.core.js.map +0 -1
- package/dist/openApiErrors/openApiError.types.d.ts.map +0 -1
- package/dist/openApiErrors/openApiError.types.js.map +0 -1
- package/dist/openApiHttp/index.d.ts.map +0 -1
- package/dist/openApiHttp/index.js.map +0 -1
- package/dist/openApiHttp/openApiHttpAdapter.core.d.ts.map +0 -1
- package/dist/openApiHttp/openApiHttpAdapter.core.js.map +0 -1
- package/dist/openApiRegistry/index.d.ts.map +0 -1
- package/dist/openApiRegistry/index.js.map +0 -1
- package/dist/openApiRegistry/openApiRegistry.core.d.ts.map +0 -1
- package/dist/openApiRegistry/openApiRegistry.core.js.map +0 -1
- package/dist/openApiRegistry/openApiRegistry.type.d.ts.map +0 -1
- package/dist/openApiRegistry/openApiRegistry.type.js.map +0 -1
- package/dist/openApiRouting/index.d.ts.map +0 -1
- package/dist/openApiRouting/index.js.map +0 -1
- package/dist/openApiRouting/routeConverter.core.d.ts.map +0 -1
- package/dist/openApiRouting/routeConverter.core.js.map +0 -1
- package/dist/openApiRouting/routeMetadata.type.d.ts.map +0 -1
- package/dist/openApiRouting/routeMetadata.type.js.map +0 -1
- package/dist/openApiRouting/routeScanner.core.d.ts.map +0 -1
- package/dist/openApiRouting/routeScanner.core.js.map +0 -1
- package/dist/openApiSchema/index.d.ts.map +0 -1
- package/dist/openApiSchema/index.js.map +0 -1
- package/dist/openApiSchema/references.core.d.ts.map +0 -1
- package/dist/openApiSchema/references.core.js.map +0 -1
- package/dist/openApiSchema/schemaConverter.core.d.ts.map +0 -1
- package/dist/openApiSchema/schemaConverter.core.js.map +0 -1
- package/dist/openApiSchema/schemaRegistry.core.d.ts.map +0 -1
- package/dist/openApiSchema/schemaRegistry.core.js.map +0 -1
- package/dist/openApiSerialization/index.d.ts.map +0 -1
- package/dist/openApiSerialization/index.js.map +0 -1
- package/dist/openApiSerialization/openApiSerializer.core.d.ts.map +0 -1
- package/dist/openApiSerialization/openApiSerializer.core.js.map +0 -1
- package/dist/openApiTypes/index.d.ts.map +0 -1
- package/dist/openApiTypes/index.js.map +0 -1
- package/dist/openApiTypes/openApiComponent.type.d.ts.map +0 -1
- package/dist/openApiTypes/openApiComponent.type.js.map +0 -1
- package/dist/openApiTypes/openApiDocument.type.d.ts.map +0 -1
- package/dist/openApiTypes/openApiDocument.type.js.map +0 -1
- package/dist/openApiTypes/openApiPath.type.d.ts.map +0 -1
- package/dist/openApiTypes/openApiPath.type.js.map +0 -1
- package/dist/openApiTypes/openApiSchema.type.d.ts.map +0 -1
- package/dist/openApiTypes/openApiSchema.type.js.map +0 -1
- package/dist/openApiTypes/openApiSecurity.type.d.ts.map +0 -1
- package/dist/openApiTypes/openApiSecurity.type.js.map +0 -1
- package/dist/openApiTypes/openApiTypes.core.d.ts.map +0 -1
- package/dist/openApiTypes/openApiTypes.core.js.map +0 -1
- package/dist/openApiValidation/index.d.ts.map +0 -1
- package/dist/openApiValidation/index.js.map +0 -1
- package/dist/openApiValidation/openApiValidator.core.d.ts.map +0 -1
- package/dist/openApiValidation/openApiValidator.core.js.map +0 -1
|
@@ -1,12 +1,32 @@
|
|
|
1
|
+
import { COMPONENT_REF_PREFIX } from "../openApiConstants/openApiConstants.core.js";
|
|
2
|
+
/**
|
|
3
|
+
* Escapes a component name for use inside a JSON Pointer.
|
|
4
|
+
*
|
|
5
|
+
* RFC 6901 reserves `~` and `/`; a component called `Order/Line` produces a
|
|
6
|
+
* pointer that resolves to the wrong place — or nowhere — unless they are
|
|
7
|
+
* escaped. The `~0` substitution must come first, or the `~1` it introduces
|
|
8
|
+
* would be escaped again.
|
|
9
|
+
*/
|
|
10
|
+
export function escapeJsonPointerSegment(segment) {
|
|
11
|
+
return segment.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
12
|
+
}
|
|
13
|
+
/** Reverses {@link escapeJsonPointerSegment}. */
|
|
14
|
+
export function unescapeJsonPointerSegment(segment) {
|
|
15
|
+
return segment.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
16
|
+
}
|
|
1
17
|
/**
|
|
2
18
|
* Creates an OpenAPI component reference.
|
|
3
19
|
*
|
|
20
|
+
* This is the single `$ref` builder in the package — the registry and the
|
|
21
|
+
* schema registry both delegate here, so escaping cannot be right in one
|
|
22
|
+
* place and missing in another.
|
|
23
|
+
*
|
|
4
24
|
* @param section - The component section (e.g., "schemas", "responses")
|
|
5
25
|
* @param name - The component name
|
|
6
26
|
*/
|
|
7
27
|
export function createComponentReference(section, name) {
|
|
8
28
|
return {
|
|
9
|
-
$ref:
|
|
29
|
+
$ref: `${COMPONENT_REF_PREFIX}/${escapeJsonPointerSegment(section)}/${escapeJsonPointerSegment(name)}`,
|
|
10
30
|
};
|
|
11
31
|
}
|
|
12
32
|
//# sourceMappingURL=references.core.js.map
|
|
@@ -1,11 +1,69 @@
|
|
|
1
1
|
import type { OpenAPISchema } from "../openApiTypes/openApiTypes.core.js";
|
|
2
|
+
/**
|
|
3
|
+
* Converts `@zudojs/schema` schemas into OpenAPI schema objects.
|
|
4
|
+
*
|
|
5
|
+
* The conversion reads the schema classes' runtime fields directly rather
|
|
6
|
+
* than importing them, so this package stays usable with any object that
|
|
7
|
+
* follows the same shape. That structural coupling is the reason every field
|
|
8
|
+
* name below is named in one place and covered by tests: a rename in
|
|
9
|
+
* `@zudojs/schema` is not a compile error here, it is a silently empty
|
|
10
|
+
* document.
|
|
11
|
+
*
|
|
12
|
+
* Field names as of `@zudojs/schema@0.1.0`:
|
|
13
|
+
* object `_config.shape`, `_config.requiredKeys` (a Set), `_config.unknownKeys`
|
|
14
|
+
* array `_config.itemSchema`, `_config.min`, `_config.max`, `_config.length`
|
|
15
|
+
* string `_config.min|max|length|pattern|format`
|
|
16
|
+
* number `_config.min|max|int|gt|lt|multipleOf`
|
|
17
|
+
* coerce.string / coerce.number
|
|
18
|
+
* `_constraints` — the wrapped StringSchema / NumberSchema that
|
|
19
|
+
* carries the `_config` above
|
|
20
|
+
* union `_schemas` intersection `_left` / `_right`
|
|
21
|
+
* enum `_values` literal `_expected`
|
|
22
|
+
* optional `_inner` nullable `_inner`
|
|
23
|
+
* default `_inner`, `_defaultValue` (a value or a factory function)
|
|
24
|
+
* refine `_inner`
|
|
25
|
+
* transform `_inner` (`schema.transform(...)`, TransformModifierSchema)
|
|
26
|
+
* or `_base` (the standalone TransformSchema class)
|
|
27
|
+
* lazy `_factory` / `_inner`
|
|
28
|
+
* record `_keySchema`, `_valueSchema` tuple `_schemas`
|
|
29
|
+
* map `_keySchema`, `_valueSchema` set `_valueSchema`
|
|
30
|
+
* metadata `_metadata` (description, example, title, deprecated)
|
|
31
|
+
*
|
|
32
|
+
* Object parsing accepts a missing key when the field schema is one of
|
|
33
|
+
* `optional`, `default`, `any` or `unknown` (`ACCEPTS_UNDEFINED` in
|
|
34
|
+
* schemaObject.core.ts), so exactly those are left out of `required`.
|
|
35
|
+
*/
|
|
2
36
|
export interface SchemaConversionResult {
|
|
3
37
|
readonly schema: OpenAPISchema;
|
|
4
38
|
readonly warnings: readonly string[];
|
|
5
39
|
}
|
|
6
|
-
|
|
40
|
+
/** Options controlling how a schema is converted. */
|
|
41
|
+
export interface SchemaConversionOptions {
|
|
42
|
+
/**
|
|
43
|
+
* Target specification version. 3.1 expresses nullability as
|
|
44
|
+
* `type: [t, "null"]`; 3.0 uses `nullable: true`, which 3.1 removed.
|
|
45
|
+
*/
|
|
46
|
+
readonly version?: string;
|
|
47
|
+
/**
|
|
48
|
+
* Depth at which conversion stops descending. Guards against a recursive
|
|
49
|
+
* schema whose `lazy` wrapper resolves to itself. Default: 32.
|
|
50
|
+
*/
|
|
51
|
+
readonly maxDepth?: number;
|
|
52
|
+
}
|
|
53
|
+
/** True when the document being produced follows OpenAPI 3.1 or later. */
|
|
54
|
+
export declare function isVersion31(version: string): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Converts a schema into an OpenAPI schema object.
|
|
57
|
+
*
|
|
58
|
+
* Warnings describe everything that could not be represented exactly. They
|
|
59
|
+
* are part of the result rather than a side channel, because silently
|
|
60
|
+
* emitting `{}` for an unsupported construct is how a specification ends up
|
|
61
|
+
* documenting nothing.
|
|
62
|
+
*/
|
|
63
|
+
export declare function convertSchema(input: unknown, options?: SchemaConversionOptions): SchemaConversionResult;
|
|
7
64
|
export interface SchemaConverter {
|
|
8
|
-
convert(input: unknown,
|
|
65
|
+
convert(input: unknown, options?: SchemaConversionOptions): SchemaConversionResult;
|
|
9
66
|
}
|
|
10
|
-
|
|
67
|
+
/** Creates a converter bound to a specification version. */
|
|
68
|
+
export declare function createSchemaConverter(defaults?: SchemaConversionOptions): SchemaConverter;
|
|
11
69
|
//# sourceMappingURL=schemaConverter.core.d.ts.map
|