@scalar/schemas 0.13.1 → 0.14.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/CHANGELOG.md +21 -0
- package/dist/api-reference/api-reference-configuration.d.ts +3 -0
- package/dist/api-reference/api-reference-configuration.d.ts.map +1 -1
- package/dist/api-reference/api-reference-plugin.d.ts +2 -0
- package/dist/api-reference/api-reference-plugin.d.ts.map +1 -1
- package/dist/asyncapi/3.1/operation-trait.d.ts.map +1 -1
- package/dist/asyncapi/3.1/operation-trait.js +2 -0
- package/dist/asyncapi/3.1/schema-payload.d.ts.map +1 -1
- package/dist/asyncapi/3.1/schema-payload.js +3 -4
- package/dist/openapi/3.1/schema.d.ts +5 -0
- package/dist/openapi/3.1/schema.d.ts.map +1 -1
- package/dist/openapi/3.1/schema.js +133 -124
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @scalar/schemas
|
|
2
2
|
|
|
3
|
+
## 0.14.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#10213](https://github.com/scalar/scalar/pull/10213): Add per-reference Markdown rendering hooks and an explicitly loaded Mermaid plugin with interactive diagrams, keyboard panning, and zoom controls.
|
|
8
|
+
|
|
9
|
+
Provide Markdown hooks before mounting the embedded client modal so its initial render receives the configured hooks. The Mermaid viewer uses customizable Scalar theme styles and an intentional light drawing surface.
|
|
10
|
+
|
|
11
|
+
Isolate Markdown plugin cleanup failures so other plugins still release their resources when content changes or unmounts.
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [#10597](https://github.com/scalar/scalar/pull/10597): Render AsyncAPI string discriminators with inherited schema variants and effective discriminator values.
|
|
16
|
+
|
|
17
|
+
## 0.13.2
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- [#10554](https://github.com/scalar/scalar/pull/10554): Render AsyncAPI boolean schemas with explanations in message payloads, headers, and reusable models.
|
|
22
|
+
- [#10565](https://github.com/scalar/scalar/pull/10565): Inherit AsyncAPI operation metadata and replies from traits using recursive merge rules, and use inherited titles in navigation.
|
|
23
|
+
|
|
3
24
|
## 0.13.1
|
|
4
25
|
|
|
5
26
|
## 0.13.0
|
|
@@ -84,6 +84,7 @@ export declare const apiReferenceConfigurationSchema: import("@scalar/validation
|
|
|
84
84
|
onDestroy: import("@scalar/validation").OptionalSchema<import("@scalar/validation").FunctionSchema<() => void>>;
|
|
85
85
|
}>>;
|
|
86
86
|
apiClientPlugins: any[];
|
|
87
|
+
markdown?: import("@scalar/helpers/markdown/markdown-render-hook").MarkdownRenderHook;
|
|
87
88
|
}>>>;
|
|
88
89
|
pluginUrls: import("@scalar/validation").OptionalSchema<import("@scalar/validation").ArraySchema<import("@scalar/validation").StringSchema>>;
|
|
89
90
|
isEditable: import("@scalar/validation").BooleanSchema;
|
|
@@ -288,6 +289,7 @@ export declare const apiReferenceConfigurationWithSourceSchema: (rawInput: unkno
|
|
|
288
289
|
onDestroy: import("@scalar/validation").OptionalSchema<import("@scalar/validation").FunctionSchema<() => void>>;
|
|
289
290
|
}>>;
|
|
290
291
|
apiClientPlugins: any[];
|
|
292
|
+
markdown?: import("@scalar/helpers/markdown/markdown-render-hook").MarkdownRenderHook;
|
|
291
293
|
})[] | undefined;
|
|
292
294
|
pluginUrls?: string[] | undefined;
|
|
293
295
|
modelsSectionLabel?: string | undefined;
|
|
@@ -472,6 +474,7 @@ export declare const apiReferenceConfigurationWithSourceSchema: (rawInput: unkno
|
|
|
472
474
|
onDestroy: import("@scalar/validation").OptionalSchema<import("@scalar/validation").FunctionSchema<() => void>>;
|
|
473
475
|
}>>;
|
|
474
476
|
apiClientPlugins: any[];
|
|
477
|
+
markdown?: import("@scalar/helpers/markdown/markdown-render-hook").MarkdownRenderHook;
|
|
475
478
|
})[] | undefined;
|
|
476
479
|
pluginUrls?: string[] | undefined;
|
|
477
480
|
modelsSectionLabel?: string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-reference-configuration.d.ts","sourceRoot":"","sources":["../../src/api-reference/api-reference-configuration.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAmB,QAAQ,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AACjF,OAAO,EACL,KAAK,aAAa,EAenB,MAAM,oBAAoB,CAAA;AAO3B,eAAO,MAAM,+BAA+B
|
|
1
|
+
{"version":3,"file":"api-reference-configuration.d.ts","sourceRoot":"","sources":["../../src/api-reference/api-reference-configuration.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAmB,QAAQ,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AACjF,OAAO,EACL,KAAK,aAAa,EAenB,MAAM,oBAAoB,CAAA;AAO3B,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBAwBvC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;mBAgGoC,aAAa,CAAC,QAAQ,CAAC;mBACvB,aAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;;;;oHAYnC,MAAM,KAAK,IAAI;oHAGf,IAAI;6GAGX,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;qHAKhD;QACN,OAAO,EAAE,OAAO,CAAA;QAChB,cAAc,EAAE,OAAO,CAAA;QACvB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KACrC,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;oHASlB;QACN,OAAO,EAAE,OAAO,CAAA;QAChB,cAAc,EAAE,OAAO,CAAA;QACvB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KACrC,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;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E,MAAM,CAAA;KAAE,KAAK,MAAM;qCAIpD;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,MAAM;mCAKvD;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,MAAM;4BAGnD;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,KAAK,MAAM;wBAG3E,MAAM,KAAK,MAAM,GAAG,IAAI,GAAG,SAAS;gCA2Cb,GAAG,KAAK,GAAG,KAAK,MAAM;iDAGG,GAAG,KAAK,GAAG,KAAK,MAAM;kBA6FvG,CAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { MarkdownRenderHook } from '@scalar/helpers/markdown/markdown-render-hook';
|
|
1
2
|
import { type Static } from '@scalar/validation';
|
|
2
3
|
declare const openApiExtensionSchema: import("@scalar/validation").ObjectSchema<{
|
|
3
4
|
name: import("@scalar/validation").StringSchema;
|
|
@@ -41,6 +42,7 @@ export declare const apiReferencePluginSchema: import("@scalar/validation").Func
|
|
|
41
42
|
views: Static<typeof viewsSchema>;
|
|
42
43
|
hooks: Static<typeof lifecycleHooksSchema>;
|
|
43
44
|
apiClientPlugins: any[];
|
|
45
|
+
markdown?: MarkdownRenderHook;
|
|
44
46
|
}>;
|
|
45
47
|
export {};
|
|
46
48
|
//# sourceMappingURL=api-reference-plugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-reference-plugin.d.ts","sourceRoot":"","sources":["../../src/api-reference/api-reference-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAsE,MAAM,oBAAoB,CAAA;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,CAAC,OAAO,sBAAsB,CAAC,EAAE,CAAA;IACnD,KAAK,EAAE,MAAM,CAAC,OAAO,WAAW,CAAC,CAAA;IACjC,KAAK,EAAE,MAAM,CAAC,OAAO,oBAAoB,CAAC,CAAA;IAC1C,gBAAgB,EAAE,GAAG,EAAE,CAAA;IACvB,QAAQ,CAAC,EAAE,kBAAkB,CAAA;CAC9B,CACA,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation-trait.d.ts","sourceRoot":"","sources":["../../../src/asyncapi/3.1/operation-trait.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"operation-trait.d.ts","sourceRoot":"","sources":["../../../src/asyncapi/3.1/operation-trait.ts"],"names":[],"mappings":"AASA,gDAAgD;AAChD,eAAO,MAAM,4BAA4B,qCAwBxC,CAAA"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { array, object, optional, string } from '@scalar/validation';
|
|
2
2
|
import { asyncApiOperationBindingsObject } from './bindings.js';
|
|
3
3
|
import { asyncApiExternalDocumentationObject } from './external-documentation.js';
|
|
4
|
+
import { asyncApiOperationReplyObject } from './operation-reply.js';
|
|
4
5
|
import { recursiveRef } from './reference.js';
|
|
5
6
|
import { asyncApiSecuritySchemeObject } from './security-scheme.js';
|
|
6
7
|
import { asyncApiTagsObject } from './tag.js';
|
|
@@ -17,4 +18,5 @@ export const asyncApiOperationTraitObject = recursiveRef(object({
|
|
|
17
18
|
tags: optional(asyncApiTagsObject),
|
|
18
19
|
externalDocs: optional(asyncApiExternalDocumentationObject),
|
|
19
20
|
bindings: optional(recursiveRef(asyncApiOperationBindingsObject)),
|
|
21
|
+
reply: optional(asyncApiOperationReplyObject),
|
|
20
22
|
}, { typeName: 'AsyncApiOperationTraitObject' }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-payload.d.ts","sourceRoot":"","sources":["../../../src/asyncapi/3.1/schema-payload.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,+BAA+B;;;EAa3C,CAAA;
|
|
1
|
+
{"version":3,"file":"schema-payload.d.ts","sourceRoot":"","sources":["../../../src/asyncapi/3.1/schema-payload.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,+BAA+B;;;EAa3C,CAAA;AAOD,uCAAuC;AACvC,eAAO,MAAM,+BAA+B,qCAAwC,CAAA;AAEpF,oEAAoE;AACpE,eAAO,MAAM,qBAAqB,qCAIjC,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { literal, object, optional, string, union, unknown } from '@scalar/validation';
|
|
2
|
-
import {
|
|
2
|
+
import { createSchema } from '../../openapi/3.1/schema.js';
|
|
3
3
|
import { recursiveRef } from './reference.js';
|
|
4
4
|
export const asyncApiMultiFormatSchemaObject = object({
|
|
5
5
|
schemaFormat: optional(string({
|
|
@@ -9,9 +9,8 @@ export const asyncApiMultiFormatSchemaObject = object({
|
|
|
9
9
|
typeComment: 'REQUIRED. Schema definition in the format given by schemaFormat.',
|
|
10
10
|
}),
|
|
11
11
|
}, { typeName: 'AsyncApiMultiFormatSchemaObject' });
|
|
12
|
-
//
|
|
13
|
-
|
|
14
|
-
const asyncApiSchemaJsonShape = union([literal(true), literal(false), schemaObject], {
|
|
12
|
+
// Share the recursive JSON Schema fields while retaining AsyncAPI's property-name discriminator.
|
|
13
|
+
const asyncApiSchemaJsonShape = union([literal(true), literal(false), createSchema(true, string())], {
|
|
15
14
|
typeName: 'AsyncApiSchemaJsonShape',
|
|
16
15
|
});
|
|
17
16
|
/** Schema Object | Reference Object */
|
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
import { type Schema } from '@scalar/validation';
|
|
2
|
+
/**
|
|
3
|
+
* Build the shared Schema Object shape, optionally accepting boolean child schemas.
|
|
4
|
+
* AsyncAPI uses JSON Schema booleans recursively; the OpenAPI ingestion pipeline normalizes them first.
|
|
5
|
+
*/
|
|
6
|
+
export declare const createSchema: (booleanSchemas?: boolean, discriminator?: Schema) => Schema;
|
|
2
7
|
export declare const schema: Schema;
|
|
3
8
|
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/openapi/3.1/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,MAAM,EAaZ,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/openapi/3.1/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,MAAM,EAaZ,MAAM,oBAAoB,CAAA;AAS3B;;;GAGG;AACH,eAAO,MAAM,YAAY,GAAI,wBAAsB,EAAE,gBAAe,MAA4B,KAAG,MA6KlG,CAAA;AAED,eAAO,MAAM,MAAM,QAAiB,CAAA"}
|
|
@@ -5,128 +5,137 @@ import { discriminatorObject } from '../../openapi/3.1/discriminator.js';
|
|
|
5
5
|
import { externalDocs } from '../../openapi/3.1/external-docs.js';
|
|
6
6
|
import { normalRef } from '../../openapi/3.1/reference.js';
|
|
7
7
|
import { xml } from '../../openapi/3.1/xml.js';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
typeComment: '
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
minLength: optional(number({ typeComment: 'Minimum string length.' })),
|
|
63
|
-
pattern: optional(string({ typeComment: 'Regular expression pattern.' })),
|
|
64
|
-
});
|
|
65
|
-
const stringSchema = intersection([
|
|
66
|
-
object({
|
|
67
|
-
type: literal('string'),
|
|
68
|
-
format: optional(string({ typeComment: 'Different subtypes.' })),
|
|
69
|
-
}),
|
|
70
|
-
stringValidationKeywords,
|
|
71
|
-
], { typeName: 'StringSchemaObject' });
|
|
72
|
-
const objectValidationKeywords = object({
|
|
73
|
-
maxProperties: optional(number({ typeComment: 'Maximum number of properties.' })),
|
|
74
|
-
minProperties: optional(number({ typeComment: 'Minimum number of properties.' })),
|
|
75
|
-
properties: optional(record(string(), normalRef(lazy(() => schema)), { typeName: 'SchemaObjectProperties' })),
|
|
76
|
-
required: optional(array(string(), { typeName: 'SchemaObjectRequired' })),
|
|
77
|
-
additionalProperties: optional(union([normalRef(lazy(() => schema)), object({}), boolean()], {
|
|
78
|
-
typeName: 'SchemaObjectAdditionalProperties',
|
|
79
|
-
})),
|
|
80
|
-
patternProperties: optional(record(string(), normalRef(lazy(() => schema)), { typeName: 'SchemaObjectPatternProperties' })),
|
|
81
|
-
propertyNames: optional(normalRef(lazy(() => schema))),
|
|
82
|
-
});
|
|
83
|
-
const objectSchema = intersection([
|
|
84
|
-
object({
|
|
85
|
-
type: literal('object'),
|
|
86
|
-
}),
|
|
87
|
-
objectValidationKeywords,
|
|
88
|
-
], { typeName: 'ObjectSchemaObject' });
|
|
89
|
-
const arrayValidationKeywords = object({
|
|
90
|
-
maxItems: optional(number({ typeComment: 'Maximum number of items in array.' })),
|
|
91
|
-
minItems: optional(number({ typeComment: 'Minimum number of items in array.' })),
|
|
92
|
-
uniqueItems: optional(boolean({ typeComment: 'Whether array items must be unique.' })),
|
|
93
|
-
items: optional(normalRef(lazy(() => schema))),
|
|
94
|
-
prefixItems: optional(array(normalRef(lazy(() => schema)), { typeComment: 'Schema for tuple validation.' })),
|
|
95
|
-
});
|
|
96
|
-
const arraySchema = intersection([
|
|
97
|
-
object({
|
|
98
|
-
type: literal('array'),
|
|
99
|
-
}),
|
|
100
|
-
arrayValidationKeywords,
|
|
101
|
-
], { typeName: 'ArraySchemaObject' });
|
|
102
|
-
const schemaTypeMulti = union([
|
|
103
|
-
literal('null'),
|
|
104
|
-
literal('boolean'),
|
|
105
|
-
literal('string'),
|
|
106
|
-
literal('number'),
|
|
107
|
-
literal('integer'),
|
|
108
|
-
literal('object'),
|
|
109
|
-
literal('array'),
|
|
110
|
-
], { typeName: 'SchemaObjectMultiTypeKeywords' });
|
|
111
|
-
const otherTypeSchema = object({
|
|
112
|
-
type: union([literal('null'), literal('boolean')], {
|
|
113
|
-
typeName: 'SchemaObjectOtherTypeKeyword',
|
|
114
|
-
}),
|
|
115
|
-
});
|
|
116
|
-
const multiTypeSchema = intersection([
|
|
117
|
-
object({
|
|
118
|
-
type: array(schemaTypeMulti, {
|
|
119
|
-
typeName: 'SchemaObjectMultiTypeKeywordArray',
|
|
8
|
+
/**
|
|
9
|
+
* Build the shared Schema Object shape, optionally accepting boolean child schemas.
|
|
10
|
+
* AsyncAPI uses JSON Schema booleans recursively; the OpenAPI ingestion pipeline normalizes them first.
|
|
11
|
+
*/
|
|
12
|
+
export const createSchema = (booleanSchemas = false, discriminator = discriminatorObject) => {
|
|
13
|
+
const schemaExtensionObjects = [
|
|
14
|
+
XScalarIgnore,
|
|
15
|
+
XInternal,
|
|
16
|
+
XVariable,
|
|
17
|
+
XExamples,
|
|
18
|
+
XEnumDescriptions,
|
|
19
|
+
XEnumVarNames,
|
|
20
|
+
XAdditionalPropertiesName,
|
|
21
|
+
XTags,
|
|
22
|
+
];
|
|
23
|
+
const coreSchemaProperties = object({
|
|
24
|
+
name: optional(string({ typeComment: 'Schema name (extension).' })),
|
|
25
|
+
title: optional(string({ typeComment: 'A title for the schema.' })),
|
|
26
|
+
description: optional(string({ typeComment: 'A description of the schema.' })),
|
|
27
|
+
default: optional(any({ typeComment: 'Default value for the schema.' })),
|
|
28
|
+
enum: optional(array(any(), { typeComment: 'Array of allowed values.', typeName: 'JsonSchemaEnum' })),
|
|
29
|
+
const: optional(any({ typeComment: 'Constant value that must match exactly.' })),
|
|
30
|
+
contentMediaType: optional(string({ typeComment: 'Media type for content validation.' })),
|
|
31
|
+
contentEncoding: optional(string({ typeComment: 'Content encoding.' })),
|
|
32
|
+
contentSchema: optional(normalRef(lazy(() => nestedSchema))),
|
|
33
|
+
deprecated: optional(boolean({ typeComment: 'Whether the schema is deprecated.' })),
|
|
34
|
+
discriminator: optional(discriminator),
|
|
35
|
+
readOnly: optional(boolean({ typeComment: 'Whether the schema is read-only.' })),
|
|
36
|
+
writeOnly: optional(boolean({ typeComment: 'Whether the schema is write-only.' })),
|
|
37
|
+
xml: optional(xml),
|
|
38
|
+
externalDocs: optional(externalDocs),
|
|
39
|
+
example: optional(any({
|
|
40
|
+
typeComment: 'A free-form field to include an example of an instance for this schema. Deprecated in favor of the JSON Schema examples keyword.',
|
|
41
|
+
})),
|
|
42
|
+
examples: optional(array(any(), {
|
|
43
|
+
typeComment: 'An array of examples of valid instances for this schema. This keyword follows the JSON Schema Draft 2020-12 specification.',
|
|
44
|
+
typeName: 'SchemaExamplesArray',
|
|
45
|
+
})),
|
|
46
|
+
allOf: optional(array(normalRef(lazy(() => nestedSchema)), { typeName: 'SchemaObjectAllOf' })),
|
|
47
|
+
oneOf: optional(array(normalRef(lazy(() => nestedSchema)), { typeName: 'SchemaObjectOneOf' })),
|
|
48
|
+
anyOf: optional(array(normalRef(lazy(() => nestedSchema)), { typeName: 'SchemaObjectAnyOf' })),
|
|
49
|
+
not: optional(normalRef(lazy(() => nestedSchema))),
|
|
50
|
+
});
|
|
51
|
+
const numericValidationKeywords = object({
|
|
52
|
+
multipleOf: optional(number({ typeComment: 'Number must be a multiple of this value.' })),
|
|
53
|
+
maximum: optional(number({ typeComment: 'Maximum value (inclusive).' })),
|
|
54
|
+
exclusiveMaximum: optional(number({ typeComment: 'Maximum value (exclusive).' })),
|
|
55
|
+
minimum: optional(number({ typeComment: 'Minimum value (inclusive).' })),
|
|
56
|
+
exclusiveMinimum: optional(number({ typeComment: 'Minimum value (exclusive).' })),
|
|
57
|
+
});
|
|
58
|
+
const numericSchema = intersection([
|
|
59
|
+
object({
|
|
60
|
+
type: union([literal('number'), literal('integer')]),
|
|
61
|
+
format: optional(string({ typeComment: 'Different subtypes.' })),
|
|
120
62
|
}),
|
|
121
|
-
|
|
122
|
-
})
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
63
|
+
numericValidationKeywords,
|
|
64
|
+
], { typeName: 'NumberSchemaObject' });
|
|
65
|
+
const stringValidationKeywords = object({
|
|
66
|
+
maxLength: optional(number({ typeComment: 'Maximum string length.' })),
|
|
67
|
+
minLength: optional(number({ typeComment: 'Minimum string length.' })),
|
|
68
|
+
pattern: optional(string({ typeComment: 'Regular expression pattern.' })),
|
|
69
|
+
});
|
|
70
|
+
const stringSchema = intersection([
|
|
71
|
+
object({
|
|
72
|
+
type: literal('string'),
|
|
73
|
+
format: optional(string({ typeComment: 'Different subtypes.' })),
|
|
74
|
+
}),
|
|
75
|
+
stringValidationKeywords,
|
|
76
|
+
], { typeName: 'StringSchemaObject' });
|
|
77
|
+
const objectValidationKeywords = object({
|
|
78
|
+
maxProperties: optional(number({ typeComment: 'Maximum number of properties.' })),
|
|
79
|
+
minProperties: optional(number({ typeComment: 'Minimum number of properties.' })),
|
|
80
|
+
properties: optional(record(string(), normalRef(lazy(() => nestedSchema)), { typeName: 'SchemaObjectProperties' })),
|
|
81
|
+
required: optional(array(string(), { typeName: 'SchemaObjectRequired' })),
|
|
82
|
+
additionalProperties: optional(union([normalRef(lazy(() => nestedSchema)), object({}), boolean()], {
|
|
83
|
+
typeName: 'SchemaObjectAdditionalProperties',
|
|
84
|
+
})),
|
|
85
|
+
patternProperties: optional(record(string(), normalRef(lazy(() => nestedSchema)), { typeName: 'SchemaObjectPatternProperties' })),
|
|
86
|
+
propertyNames: optional(normalRef(lazy(() => nestedSchema))),
|
|
87
|
+
});
|
|
88
|
+
const objectSchema = intersection([
|
|
89
|
+
object({
|
|
90
|
+
type: literal('object'),
|
|
91
|
+
}),
|
|
92
|
+
objectValidationKeywords,
|
|
93
|
+
], { typeName: 'ObjectSchemaObject' });
|
|
94
|
+
const arrayValidationKeywords = object({
|
|
95
|
+
maxItems: optional(number({ typeComment: 'Maximum number of items in array.' })),
|
|
96
|
+
minItems: optional(number({ typeComment: 'Minimum number of items in array.' })),
|
|
97
|
+
uniqueItems: optional(boolean({ typeComment: 'Whether array items must be unique.' })),
|
|
98
|
+
items: optional(normalRef(lazy(() => nestedSchema))),
|
|
99
|
+
prefixItems: optional(array(normalRef(lazy(() => nestedSchema)), { typeComment: 'Schema for tuple validation.' })),
|
|
100
|
+
});
|
|
101
|
+
const arraySchema = intersection([
|
|
102
|
+
object({
|
|
103
|
+
type: literal('array'),
|
|
104
|
+
}),
|
|
105
|
+
arrayValidationKeywords,
|
|
106
|
+
], { typeName: 'ArraySchemaObject' });
|
|
107
|
+
const schemaTypeMulti = union([
|
|
108
|
+
literal('null'),
|
|
109
|
+
literal('boolean'),
|
|
110
|
+
literal('string'),
|
|
111
|
+
literal('number'),
|
|
112
|
+
literal('integer'),
|
|
113
|
+
literal('object'),
|
|
114
|
+
literal('array'),
|
|
115
|
+
], { typeName: 'SchemaObjectMultiTypeKeywords' });
|
|
116
|
+
const otherTypeSchema = object({
|
|
117
|
+
type: union([literal('null'), literal('boolean')], {
|
|
118
|
+
typeName: 'SchemaObjectOtherTypeKeyword',
|
|
119
|
+
}),
|
|
120
|
+
});
|
|
121
|
+
const multiTypeSchema = intersection([
|
|
122
|
+
object({
|
|
123
|
+
type: array(schemaTypeMulti, {
|
|
124
|
+
typeName: 'SchemaObjectMultiTypeKeywordArray',
|
|
125
|
+
}),
|
|
126
|
+
format: optional(string({ typeComment: 'Different subtypes.' })),
|
|
127
|
+
}),
|
|
128
|
+
numericValidationKeywords,
|
|
129
|
+
stringValidationKeywords,
|
|
130
|
+
arrayValidationKeywords,
|
|
131
|
+
objectValidationKeywords,
|
|
132
|
+
], { typeName: 'MultiTypeSchemaObject' });
|
|
133
|
+
const schema = intersection([
|
|
134
|
+
coreSchemaProperties,
|
|
135
|
+
...schemaExtensionObjects,
|
|
136
|
+
union([otherTypeSchema, numericSchema, stringSchema, objectSchema, arraySchema, multiTypeSchema, object({})]),
|
|
137
|
+
], { typeName: 'SchemaObject' });
|
|
138
|
+
const nestedSchema = booleanSchemas ? union([boolean(), schema]) : schema;
|
|
139
|
+
return schema;
|
|
140
|
+
};
|
|
141
|
+
export const schema = createSchema();
|
package/package.json
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"schemas",
|
|
15
15
|
"scalar"
|
|
16
16
|
],
|
|
17
|
-
"version": "0.
|
|
17
|
+
"version": "0.14.0",
|
|
18
18
|
"engines": {
|
|
19
19
|
"node": ">=22"
|
|
20
20
|
},
|
|
@@ -41,11 +41,11 @@
|
|
|
41
41
|
"CHANGELOG.md"
|
|
42
42
|
],
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@scalar/helpers": "0.16.
|
|
45
|
-
"@scalar/validation": "0.6.
|
|
44
|
+
"@scalar/helpers": "0.16.4",
|
|
45
|
+
"@scalar/validation": "0.6.7"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@scalar/types": "0.
|
|
48
|
+
"@scalar/types": "0.24.0",
|
|
49
49
|
"vitest": "4.1.10"
|
|
50
50
|
},
|
|
51
51
|
"scripts": {
|