@scalar/workspace-store 0.41.2 → 0.42.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 +6 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +5 -1
- package/dist/schemas/extensions/document/x-internal.d.ts +3 -0
- package/dist/schemas/extensions/document/x-internal.d.ts.map +1 -1
- package/dist/schemas/extensions/document/x-internal.js +7 -0
- package/dist/schemas/extensions/document/x-scalar-environments.d.ts +31 -0
- package/dist/schemas/extensions/document/x-scalar-environments.d.ts.map +1 -1
- package/dist/schemas/extensions/document/x-scalar-environments.js +25 -0
- package/dist/schemas/extensions/document/x-scalar-icon.d.ts +3 -0
- package/dist/schemas/extensions/document/x-scalar-icon.d.ts.map +1 -1
- package/dist/schemas/extensions/document/x-scalar-icon.js +7 -0
- package/dist/schemas/extensions/document/x-scalar-ignore.d.ts +4 -1
- package/dist/schemas/extensions/document/x-scalar-ignore.d.ts.map +1 -1
- package/dist/schemas/extensions/document/x-scalar-ignore.js +7 -0
- package/dist/schemas/extensions/document/x-scalar-is-dirty.d.ts +3 -0
- package/dist/schemas/extensions/document/x-scalar-is-dirty.d.ts.map +1 -1
- package/dist/schemas/extensions/document/x-scalar-is-dirty.js +9 -0
- package/dist/schemas/extensions/document/x-scalar-original-document-hash.d.ts +3 -0
- package/dist/schemas/extensions/document/x-scalar-original-document-hash.d.ts.map +1 -1
- package/dist/schemas/extensions/document/x-scalar-original-document-hash.js +7 -0
- package/dist/schemas/extensions/document/x-scalar-registry-meta.d.ts +6 -0
- package/dist/schemas/extensions/document/x-scalar-registry-meta.d.ts.map +1 -1
- package/dist/schemas/extensions/document/x-scalar-registry-meta.js +25 -10
- package/dist/schemas/extensions/document/x-scalar-sdk-installation.d.ts +7 -0
- package/dist/schemas/extensions/document/x-scalar-sdk-installation.d.ts.map +1 -1
- package/dist/schemas/extensions/document/x-scalar-sdk-installation.js +23 -5
- package/dist/schemas/extensions/document/x-scalar-watch-mode.d.ts +3 -0
- package/dist/schemas/extensions/document/x-scalar-watch-mode.d.ts.map +1 -1
- package/dist/schemas/extensions/document/x-scalar-watch-mode.js +7 -0
- package/dist/schemas/extensions/document/x-tags.d.ts +4 -1
- package/dist/schemas/extensions/document/x-tags.d.ts.map +1 -1
- package/dist/schemas/extensions/document/x-tags.js +8 -1
- package/dist/schemas/extensions/example/x-disabled.d.ts +7 -1
- package/dist/schemas/extensions/example/x-disabled.d.ts.map +1 -1
- package/dist/schemas/extensions/example/x-disabled.js +8 -1
- package/dist/schemas/extensions/general/x-scalar-active-environment.d.ts +3 -0
- package/dist/schemas/extensions/general/x-scalar-active-environment.d.ts.map +1 -1
- package/dist/schemas/extensions/general/x-scalar-active-environment.js +7 -0
- package/dist/schemas/extensions/general/x-scalar-cookies.d.ts +16 -0
- package/dist/schemas/extensions/general/x-scalar-cookies.d.ts.map +1 -1
- package/dist/schemas/extensions/general/x-scalar-cookies.js +19 -0
- package/dist/schemas/extensions/general/x-scalar-order.d.ts +3 -0
- package/dist/schemas/extensions/general/x-scalar-order.d.ts.map +1 -1
- package/dist/schemas/extensions/general/x-scalar-order.js +7 -0
- package/dist/schemas/extensions/operation/x-badge.d.ts +12 -0
- package/dist/schemas/extensions/operation/x-badge.d.ts.map +1 -1
- package/dist/schemas/extensions/operation/x-badge.js +23 -0
- package/dist/schemas/extensions/operation/x-code-samples.d.ts +22 -0
- package/dist/schemas/extensions/operation/x-code-samples.d.ts.map +1 -1
- package/dist/schemas/extensions/operation/x-code-samples.js +17 -0
- package/dist/schemas/extensions/operation/x-draft-examples.d.ts +3 -0
- package/dist/schemas/extensions/operation/x-draft-examples.d.ts.map +1 -1
- package/dist/schemas/extensions/operation/x-draft-examples.js +7 -0
- package/dist/schemas/extensions/operation/x-post-response.d.ts +3 -0
- package/dist/schemas/extensions/operation/x-post-response.d.ts.map +1 -1
- package/dist/schemas/extensions/operation/x-post-response.js +9 -0
- package/dist/schemas/extensions/operation/x-scalar-disable-parameters.d.ts +9 -0
- package/dist/schemas/extensions/operation/x-scalar-disable-parameters.d.ts.map +1 -1
- package/dist/schemas/extensions/operation/x-scalar-disable-parameters.js +17 -0
- package/dist/schemas/extensions/operation/x-scalar-selected-content-type.d.ts +3 -0
- package/dist/schemas/extensions/operation/x-scalar-selected-content-type.d.ts.map +1 -1
- package/dist/schemas/extensions/operation/x-scalar-selected-content-type.js +9 -0
- package/dist/schemas/extensions/operation/x-scalar-stability.d.ts +3 -0
- package/dist/schemas/extensions/operation/x-scalar-stability.d.ts.map +1 -1
- package/dist/schemas/extensions/operation/x-scalar-stability.js +9 -0
- package/dist/schemas/extensions/parameter/x-global.d.ts +7 -1
- package/dist/schemas/extensions/parameter/x-global.d.ts.map +1 -1
- package/dist/schemas/extensions/parameter/x-global.js +8 -1
- package/dist/schemas/extensions/schema/x-additional-properties-name.d.ts +3 -0
- package/dist/schemas/extensions/schema/x-additional-properties-name.d.ts.map +1 -1
- package/dist/schemas/extensions/schema/x-additional-properties-name.js +7 -0
- package/dist/schemas/extensions/schema/x-enum-descriptions.d.ts +4 -0
- package/dist/schemas/extensions/schema/x-enum-descriptions.d.ts.map +1 -1
- package/dist/schemas/extensions/schema/x-enum-descriptions.js +9 -0
- package/dist/schemas/extensions/schema/x-enum-varnames.d.ts +4 -0
- package/dist/schemas/extensions/schema/x-enum-varnames.d.ts.map +1 -1
- package/dist/schemas/extensions/schema/x-enum-varnames.js +8 -0
- package/dist/schemas/extensions/schema/x-examples.d.ts +3 -0
- package/dist/schemas/extensions/schema/x-examples.d.ts.map +1 -1
- package/dist/schemas/extensions/schema/x-examples.js +7 -0
- package/dist/schemas/extensions/schema/x-variable.d.ts +3 -0
- package/dist/schemas/extensions/schema/x-variable.d.ts.map +1 -1
- package/dist/schemas/extensions/schema/x-variable.js +7 -0
- package/dist/schemas/extensions/security/x-default-scopes.d.ts +3 -0
- package/dist/schemas/extensions/security/x-default-scopes.d.ts.map +1 -1
- package/dist/schemas/extensions/security/x-default-scopes.js +7 -0
- package/dist/schemas/extensions/security/x-scalar-credentials-location.d.ts +3 -0
- package/dist/schemas/extensions/security/x-scalar-credentials-location.d.ts.map +1 -1
- package/dist/schemas/extensions/security/x-scalar-credentials-location.js +7 -0
- package/dist/schemas/extensions/security/x-scalar-security-body.d.ts +3 -0
- package/dist/schemas/extensions/security/x-scalar-security-body.d.ts.map +1 -1
- package/dist/schemas/extensions/security/x-scalar-security-body.js +7 -0
- package/dist/schemas/extensions/security/x-scalar-security-query.d.ts +3 -0
- package/dist/schemas/extensions/security/x-scalar-security-query.d.ts.map +1 -1
- package/dist/schemas/extensions/security/x-scalar-security-query.js +7 -0
- package/dist/schemas/extensions/security/x-scalar-security-secrets.d.ts +25 -0
- package/dist/schemas/extensions/security/x-scalar-security-secrets.d.ts.map +1 -1
- package/dist/schemas/extensions/security/x-scalar-security-secrets.js +50 -0
- package/dist/schemas/extensions/security/x-tokenName.d.ts +3 -0
- package/dist/schemas/extensions/security/x-tokenName.d.ts.map +1 -1
- package/dist/schemas/extensions/security/x-tokenName.js +7 -0
- package/dist/schemas/extensions/security/x-use-pkce.d.ts +3 -0
- package/dist/schemas/extensions/security/x-use-pkce.d.ts.map +1 -1
- package/dist/schemas/extensions/security/x-use-pkce.js +9 -0
- package/dist/schemas/extensions/server/x-scalar-selected-server.d.ts +3 -0
- package/dist/schemas/extensions/server/x-scalar-selected-server.d.ts.map +1 -1
- package/dist/schemas/extensions/server/x-scalar-selected-server.js +7 -0
- package/dist/schemas/extensions/tag/x-display-name.d.ts +3 -0
- package/dist/schemas/extensions/tag/x-display-name.d.ts.map +1 -1
- package/dist/schemas/extensions/tag/x-display-name.js +7 -0
- package/dist/schemas/extensions/tag/x-tag-groups.d.ts +14 -0
- package/dist/schemas/extensions/tag/x-tag-groups.d.ts.map +1 -1
- package/dist/schemas/extensions/tag/x-tag-groups.js +22 -1
- package/dist/schemas/extensions/workspace/x-scalar-active-proxy.d.ts +3 -0
- package/dist/schemas/extensions/workspace/x-scalar-active-proxy.d.ts.map +1 -1
- package/dist/schemas/extensions/workspace/x-scalar-active-proxy.js +7 -0
- package/dist/schemas/extensions/workspace/x-scalar-tabs.d.ts +13 -0
- package/dist/schemas/extensions/workspace/x-scalar-tabs.d.ts.map +1 -1
- package/dist/schemas/extensions/workspace/x-scalar-tabs.js +20 -0
- package/dist/schemas/v3.1/openapi/index.d.ts +3 -0
- package/dist/schemas/v3.1/openapi/index.d.ts.map +1 -0
- package/dist/schemas/v3.1/openapi/index.js +661 -0
- package/dist/schemas/v3.1/openapi/reference.d.ts +4 -0
- package/dist/schemas/v3.1/openapi/reference.d.ts.map +1 -0
- package/dist/schemas/v3.1/openapi/reference.js +29 -0
- package/dist/schemas/v3.1/strict/example.js +2 -2
- package/dist/schemas/v3.1/strict/parameter.js +2 -2
- package/dist/schemas/v3.1/strict/schema.d.ts +1 -1
- package/dist/schemas/v3.1/strict/schema.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/schema.js +2 -2
- package/package.json +5 -3
|
@@ -0,0 +1,661 @@
|
|
|
1
|
+
import { any, array, boolean, intersection, lazy, literal, number, object, optional, record, string, union, } from '@scalar/validation';
|
|
2
|
+
import { extensions } from '../../../schemas/extensions.js';
|
|
3
|
+
import { XInternal } from '../../../schemas/extensions/document/x-internal.js';
|
|
4
|
+
import { XScalarEnvironments } from '../../../schemas/extensions/document/x-scalar-environments.js';
|
|
5
|
+
import { XScalarIcon } from '../../../schemas/extensions/document/x-scalar-icon.js';
|
|
6
|
+
import { XScalarIgnore } from '../../../schemas/extensions/document/x-scalar-ignore.js';
|
|
7
|
+
import { XScalarIsDirty } from '../../../schemas/extensions/document/x-scalar-is-dirty.js';
|
|
8
|
+
import { XScalarOriginalDocumentHash } from '../../../schemas/extensions/document/x-scalar-original-document-hash.js';
|
|
9
|
+
import { XScalarRegistryMeta } from '../../../schemas/extensions/document/x-scalar-registry-meta.js';
|
|
10
|
+
import { XScalarSdkInstallation } from '../../../schemas/extensions/document/x-scalar-sdk-installation.js';
|
|
11
|
+
import { XScalarWatchMode } from '../../../schemas/extensions/document/x-scalar-watch-mode.js';
|
|
12
|
+
import { XTags } from '../../../schemas/extensions/document/x-tags.js';
|
|
13
|
+
import { XDisabled } from '../../../schemas/extensions/example/x-disabled.js';
|
|
14
|
+
import { XScalarActiveEnvironment } from '../../../schemas/extensions/general/x-scalar-active-environment.js';
|
|
15
|
+
import { XScalarCookies } from '../../../schemas/extensions/general/x-scalar-cookies.js';
|
|
16
|
+
import { XScalarOrder } from '../../../schemas/extensions/general/x-scalar-order.js';
|
|
17
|
+
import { XBadges } from '../../../schemas/extensions/operation/x-badge.js';
|
|
18
|
+
import { XCodeSamples } from '../../../schemas/extensions/operation/x-code-samples.js';
|
|
19
|
+
import { XDraftExamples } from '../../../schemas/extensions/operation/x-draft-examples.js';
|
|
20
|
+
import { XPostResponse } from '../../../schemas/extensions/operation/x-post-response.js';
|
|
21
|
+
import { XScalarDisableParameters } from '../../../schemas/extensions/operation/x-scalar-disable-parameters.js';
|
|
22
|
+
import { XScalarSelectedContentType } from '../../../schemas/extensions/operation/x-scalar-selected-content-type.js';
|
|
23
|
+
import { XScalarStability } from '../../../schemas/extensions/operation/x-scalar-stability.js';
|
|
24
|
+
import { XGlobal } from '../../../schemas/extensions/parameter/x-global.js';
|
|
25
|
+
import { XAdditionalPropertiesName } from '../../../schemas/extensions/schema/x-additional-properties-name.js';
|
|
26
|
+
import { XEnumDescriptions } from '../../../schemas/extensions/schema/x-enum-descriptions.js';
|
|
27
|
+
import { XEnumVarNames } from '../../../schemas/extensions/schema/x-enum-varnames.js';
|
|
28
|
+
import { XExamples } from '../../../schemas/extensions/schema/x-examples.js';
|
|
29
|
+
import { XVariable } from '../../../schemas/extensions/schema/x-variable.js';
|
|
30
|
+
import { XDefaultScopes } from '../../../schemas/extensions/security/x-default-scopes.js';
|
|
31
|
+
import { XScalarCredentialsLocation } from '../../../schemas/extensions/security/x-scalar-credentials-location.js';
|
|
32
|
+
import { XScalarSecurityBody } from '../../../schemas/extensions/security/x-scalar-security-body.js';
|
|
33
|
+
import { XScalarSecurityQuery } from '../../../schemas/extensions/security/x-scalar-security-query.js';
|
|
34
|
+
import { XScalarAuthUrl, XScalarTokenUrl } from '../../../schemas/extensions/security/x-scalar-security-secrets.js';
|
|
35
|
+
import { XTokenName } from '../../../schemas/extensions/security/x-tokenName.js';
|
|
36
|
+
import { XusePkce } from '../../../schemas/extensions/security/x-use-pkce.js';
|
|
37
|
+
import { XScalarSelectedServer } from '../../../schemas/extensions/server/x-scalar-selected-server.js';
|
|
38
|
+
import { XDisplayName } from '../../../schemas/extensions/tag/x-display-name.js';
|
|
39
|
+
import { XTagGroups } from '../../../schemas/extensions/tag/x-tag-groups.js';
|
|
40
|
+
export const generateSchema = (maybeRef) => {
|
|
41
|
+
const contact = object({
|
|
42
|
+
name: optional(string({ typeComment: 'The name of the contact.' })),
|
|
43
|
+
url: optional(string({ typeComment: 'The URI for the contact information. This MUST be in the form of a URI.' })),
|
|
44
|
+
email: optional(string({
|
|
45
|
+
typeComment: 'The email address of the contact person/organization. This MUST be in the form of an email address.',
|
|
46
|
+
})),
|
|
47
|
+
}, { typeName: 'ContactObject' });
|
|
48
|
+
const license = object({
|
|
49
|
+
name: optional(string({ typeComment: 'REQUIRED. The license name used for the API.' })),
|
|
50
|
+
identifier: optional(string({
|
|
51
|
+
typeComment: 'An SPDX license expression for the API. The identifier field is mutually exclusive of the url field.',
|
|
52
|
+
})),
|
|
53
|
+
url: optional(string({
|
|
54
|
+
typeComment: 'A URI for the license used for the API. This MUST be in the form of a URI. The url field is mutually exclusive of the identifier field.',
|
|
55
|
+
})),
|
|
56
|
+
}, { typeName: 'LicenseObject' });
|
|
57
|
+
const info = intersection([
|
|
58
|
+
object({
|
|
59
|
+
title: string({ typeComment: 'REQUIRED. The title of the API.' }),
|
|
60
|
+
version: string({
|
|
61
|
+
typeComment: 'REQUIRED. The version of the OpenAPI Document (which is distinct from the OpenAPI Specification version or the version of the API being described or the version of the OpenAPI Description).',
|
|
62
|
+
}),
|
|
63
|
+
summary: optional(string({ typeComment: 'A short summary of the API.' })),
|
|
64
|
+
description: optional(string({
|
|
65
|
+
typeComment: 'A description of the API. CommonMark syntax MAY be used for rich text representation.',
|
|
66
|
+
})),
|
|
67
|
+
termsOfService: optional(string({ typeComment: 'A URI for the Terms of Service for the API. This MUST be in the form of a URI.' })),
|
|
68
|
+
contact: optional(contact),
|
|
69
|
+
license: optional(license),
|
|
70
|
+
}, { typeName: 'InfoObject' }),
|
|
71
|
+
XScalarSdkInstallation,
|
|
72
|
+
]);
|
|
73
|
+
const serverVariable = object({
|
|
74
|
+
enum: optional(array(string(), {
|
|
75
|
+
typeComment: 'An enumeration of string values to be used if the substitution options are from a limited set. The array MUST NOT be empty.',
|
|
76
|
+
})),
|
|
77
|
+
default: optional(string({
|
|
78
|
+
typeComment: `The default value to use for substitution, which SHALL be sent if an alternate value is not supplied. If the enum is defined, the value MUST exist in the enum\'s values. Note that this behavior is different from the Schema Object's default keyword, which documents the receiver's behavior rather than inserting the value into the data.`,
|
|
79
|
+
})),
|
|
80
|
+
description: optional(string({
|
|
81
|
+
typeComment: 'An optional description for the server variable. CommonMark syntax MAY be used for rich text representation.',
|
|
82
|
+
})),
|
|
83
|
+
}, { typeName: 'ServerVariableObject' });
|
|
84
|
+
const servers = object({
|
|
85
|
+
url: string({
|
|
86
|
+
typeComment: 'REQUIRED. A URL to the target host. This URL supports Server Variables and MAY be relative, to indicate that the host location is relative to the location where the document containing the Server Object is being served. Variable substitutions will be made when a variable is named in {braces}.',
|
|
87
|
+
}),
|
|
88
|
+
description: optional(string({
|
|
89
|
+
typeComment: 'An optional string describing the host designated by the URL. CommonMark syntax MAY be used for rich text representation.',
|
|
90
|
+
})),
|
|
91
|
+
variables: optional(record(string(), serverVariable, {
|
|
92
|
+
typeComment: `A map between a variable name and its value. The value is used for substitution in the server's URL template.`,
|
|
93
|
+
})),
|
|
94
|
+
}, { typeName: 'ServerObject' });
|
|
95
|
+
const externalDocs = object({
|
|
96
|
+
url: string({
|
|
97
|
+
typeComment: 'REQUIRED. The URI for the target documentation. This MUST be in the form of a URI.',
|
|
98
|
+
}),
|
|
99
|
+
description: optional(string({
|
|
100
|
+
typeComment: 'A description of the target documentation. CommonMark syntax MAY be used for rich text representation.',
|
|
101
|
+
})),
|
|
102
|
+
}, { typeName: 'ExternalDocumentationObject' });
|
|
103
|
+
const tag = intersection([
|
|
104
|
+
object({
|
|
105
|
+
name: string({ typeComment: 'REQUIRED. The name of the tag.' }),
|
|
106
|
+
description: optional(string({
|
|
107
|
+
typeComment: 'A description for the tag. CommonMark syntax MAY be used for rich text representation.',
|
|
108
|
+
})),
|
|
109
|
+
externalDocs: optional(externalDocs),
|
|
110
|
+
}, { typeName: 'TagObject' }),
|
|
111
|
+
XDisplayName,
|
|
112
|
+
XInternal,
|
|
113
|
+
XScalarIgnore,
|
|
114
|
+
XScalarOrder,
|
|
115
|
+
]);
|
|
116
|
+
const securityRequirement = record(string(), array(string()), {
|
|
117
|
+
typeName: 'SecurityRequirementObject',
|
|
118
|
+
typeComment: 'Lists the required security schemes to execute this operation. An empty object ({}) indicates anonymous access is supported.',
|
|
119
|
+
});
|
|
120
|
+
const xml = object({
|
|
121
|
+
name: optional(string({
|
|
122
|
+
typeComment: 'Replaces the name of the element/attribute used for the described schema property. When defined within items, it will affect the name of the individual XML elements within the list. When defined alongside type being "array" (outside the items), it will affect the wrapping element if and only if wrapped is true. If wrapped is false, it will be ignored.',
|
|
123
|
+
})),
|
|
124
|
+
namespace: optional(string({
|
|
125
|
+
typeComment: 'The URI of the namespace definition. Value MUST be in the form of a non-relative URI.',
|
|
126
|
+
})),
|
|
127
|
+
prefix: optional(string({ typeComment: 'The prefix to be used for the name.' })),
|
|
128
|
+
attribute: optional(boolean({
|
|
129
|
+
typeComment: 'Declares whether the property definition translates to an attribute instead of an element. Default value is false.',
|
|
130
|
+
})),
|
|
131
|
+
wrapped: optional(boolean({
|
|
132
|
+
typeComment: 'MAY be used only for an array definition. Signifies whether the array is wrapped (for example, <books><book/><book/></books>) or unwrapped (<book/><book/>). Default value is false. The definition takes effect only when defined alongside type being "array" (outside the items).',
|
|
133
|
+
})),
|
|
134
|
+
}, { typeName: 'XMLObject' });
|
|
135
|
+
const discriminatorObject = object({
|
|
136
|
+
propertyName: string({
|
|
137
|
+
typeComment: 'REQUIRED. The name of the property in the payload that will hold the discriminating value. This property SHOULD be required in the payload schema, as the behavior when the property is absent is undefined.',
|
|
138
|
+
}),
|
|
139
|
+
mapping: optional(record(string(), string(), {
|
|
140
|
+
typeComment: 'An object to hold mappings between payload values and schema names or URI references.',
|
|
141
|
+
})),
|
|
142
|
+
}, { typeName: 'DiscriminatorObject' });
|
|
143
|
+
const schemaExtensionObjects = [
|
|
144
|
+
XScalarIgnore,
|
|
145
|
+
XInternal,
|
|
146
|
+
XVariable,
|
|
147
|
+
XExamples,
|
|
148
|
+
XEnumDescriptions,
|
|
149
|
+
XEnumVarNames,
|
|
150
|
+
XAdditionalPropertiesName,
|
|
151
|
+
XTags,
|
|
152
|
+
];
|
|
153
|
+
const coreSchemaProperties = {
|
|
154
|
+
name: optional(string({ typeComment: 'Schema name (extension).' })),
|
|
155
|
+
title: optional(string({ typeComment: 'A title for the schema.' })),
|
|
156
|
+
description: optional(string({ typeComment: 'A description of the schema.' })),
|
|
157
|
+
default: optional(any({ typeComment: 'Default value for the schema.' })),
|
|
158
|
+
enum: optional(array(any(), { typeComment: 'Array of allowed values.', typeName: 'JsonSchemaEnum' })),
|
|
159
|
+
const: optional(any({ typeComment: 'Constant value that must match exactly.' })),
|
|
160
|
+
contentMediaType: optional(string({ typeComment: 'Media type for content validation.' })),
|
|
161
|
+
contentEncoding: optional(string({ typeComment: 'Content encoding.' })),
|
|
162
|
+
contentSchema: optional(maybeRef(lazy(() => schema))),
|
|
163
|
+
deprecated: optional(boolean({ typeComment: 'Whether the schema is deprecated.' })),
|
|
164
|
+
discriminator: optional(discriminatorObject),
|
|
165
|
+
readOnly: optional(boolean({ typeComment: 'Whether the schema is read-only.' })),
|
|
166
|
+
writeOnly: optional(boolean({ typeComment: 'Whether the schema is write-only.' })),
|
|
167
|
+
xml: optional(xml),
|
|
168
|
+
externalDocs: optional(externalDocs),
|
|
169
|
+
example: optional(any({
|
|
170
|
+
typeComment: 'A free-form field to include an example of an instance for this schema. Deprecated in favor of the JSON Schema examples keyword.',
|
|
171
|
+
})),
|
|
172
|
+
examples: optional(array(any(), {
|
|
173
|
+
typeComment: 'An array of examples of valid instances for this schema. This keyword follows the JSON Schema Draft 2020-12 specification.',
|
|
174
|
+
typeName: 'SchemaExamplesArray',
|
|
175
|
+
})),
|
|
176
|
+
allOf: optional(array(maybeRef(lazy(() => schema)), { typeName: 'SchemaObjectAllOf' })),
|
|
177
|
+
oneOf: optional(array(maybeRef(lazy(() => schema)), { typeName: 'SchemaObjectOneOf' })),
|
|
178
|
+
anyOf: optional(array(maybeRef(lazy(() => schema)), { typeName: 'SchemaObjectAnyOf' })),
|
|
179
|
+
not: optional(maybeRef(lazy(() => schema))),
|
|
180
|
+
};
|
|
181
|
+
const schemaScalarMarker = intersection([
|
|
182
|
+
object({ __scalar_: string({ typeComment: 'Internal marker for schema object disambiguation.' }) }),
|
|
183
|
+
object(coreSchemaProperties, { typeName: 'JsonSchemaCoreMarked' }),
|
|
184
|
+
...schemaExtensionObjects,
|
|
185
|
+
]);
|
|
186
|
+
const numericSchema = intersection([
|
|
187
|
+
object({
|
|
188
|
+
...coreSchemaProperties,
|
|
189
|
+
type: union([literal('number'), literal('integer')]),
|
|
190
|
+
format: optional(string({ typeComment: 'Different subtypes.' })),
|
|
191
|
+
multipleOf: optional(number({ typeComment: 'Number must be a multiple of this value.' })),
|
|
192
|
+
maximum: optional(number({ typeComment: 'Maximum value (inclusive).' })),
|
|
193
|
+
exclusiveMaximum: optional(number({ typeComment: 'Maximum value (exclusive).' })),
|
|
194
|
+
minimum: optional(number({ typeComment: 'Minimum value (inclusive).' })),
|
|
195
|
+
exclusiveMinimum: optional(number({ typeComment: 'Minimum value (exclusive).' })),
|
|
196
|
+
}, { typeName: 'NumberSchemaObject' }),
|
|
197
|
+
...schemaExtensionObjects,
|
|
198
|
+
]);
|
|
199
|
+
const stringSchema = intersection([
|
|
200
|
+
object({
|
|
201
|
+
...coreSchemaProperties,
|
|
202
|
+
type: literal('string'),
|
|
203
|
+
format: optional(string({ typeComment: 'Different subtypes.' })),
|
|
204
|
+
maxLength: optional(number({ typeComment: 'Maximum string length.' })),
|
|
205
|
+
minLength: optional(number({ typeComment: 'Minimum string length.' })),
|
|
206
|
+
pattern: optional(string({ typeComment: 'Regular expression pattern.' })),
|
|
207
|
+
}, { typeName: 'StringSchemaObject' }),
|
|
208
|
+
...schemaExtensionObjects,
|
|
209
|
+
]);
|
|
210
|
+
const objectSchema = intersection([
|
|
211
|
+
object({
|
|
212
|
+
...coreSchemaProperties,
|
|
213
|
+
type: literal('object'),
|
|
214
|
+
maxProperties: optional(number({ typeComment: 'Maximum number of properties.' })),
|
|
215
|
+
minProperties: optional(number({ typeComment: 'Minimum number of properties.' })),
|
|
216
|
+
properties: optional(record(string(), maybeRef(lazy(() => schema)), { typeName: 'SchemaObjectProperties' })),
|
|
217
|
+
required: optional(array(string(), { typeName: 'SchemaObjectRequired' })),
|
|
218
|
+
additionalProperties: optional(union([boolean(), maybeRef(lazy(() => schema))], {
|
|
219
|
+
typeName: 'SchemaObjectAdditionalProperties',
|
|
220
|
+
})),
|
|
221
|
+
patternProperties: optional(record(string(), maybeRef(lazy(() => schema)), { typeName: 'SchemaObjectPatternProperties' })),
|
|
222
|
+
propertyNames: optional(maybeRef(lazy(() => schema))),
|
|
223
|
+
}, { typeName: 'ObjectSchemaObject' }),
|
|
224
|
+
...schemaExtensionObjects,
|
|
225
|
+
]);
|
|
226
|
+
const arraySchema = intersection([
|
|
227
|
+
object({
|
|
228
|
+
...coreSchemaProperties,
|
|
229
|
+
type: literal('array'),
|
|
230
|
+
maxItems: optional(number({ typeComment: 'Maximum number of items in array.' })),
|
|
231
|
+
minItems: optional(number({ typeComment: 'Minimum number of items in array.' })),
|
|
232
|
+
uniqueItems: optional(boolean({ typeComment: 'Whether array items must be unique.' })),
|
|
233
|
+
items: optional(maybeRef(lazy(() => schema))),
|
|
234
|
+
prefixItems: optional(array(maybeRef(lazy(() => schema)), { typeComment: 'Schema for tuple validation.' })),
|
|
235
|
+
}, { typeName: 'ArraySchemaObject' }),
|
|
236
|
+
...schemaExtensionObjects,
|
|
237
|
+
]);
|
|
238
|
+
const schemaTypeMulti = union([
|
|
239
|
+
literal('null'),
|
|
240
|
+
literal('boolean'),
|
|
241
|
+
literal('string'),
|
|
242
|
+
literal('number'),
|
|
243
|
+
literal('integer'),
|
|
244
|
+
literal('object'),
|
|
245
|
+
literal('array'),
|
|
246
|
+
], { typeName: 'SchemaObjectMultiTypeKeywords' });
|
|
247
|
+
const otherTypeSchema = intersection([
|
|
248
|
+
object({
|
|
249
|
+
...coreSchemaProperties,
|
|
250
|
+
type: union([literal('null'), literal('boolean'), array(schemaTypeMulti, { typeName: 'SchemaObjectTypeKeywordList' })], { typeName: 'SchemaObjectOtherTypeKeyword' }),
|
|
251
|
+
}, { typeName: 'MultiTypeSchemaObject' }),
|
|
252
|
+
...schemaExtensionObjects,
|
|
253
|
+
]);
|
|
254
|
+
const schema = union([schemaScalarMarker, otherTypeSchema, numericSchema, stringSchema, objectSchema, arraySchema], { typeName: 'SchemaObject' });
|
|
255
|
+
const securitySchemeBase = object({
|
|
256
|
+
description: optional(string({
|
|
257
|
+
typeComment: 'A description for security scheme. CommonMark syntax MAY be used for rich text representation.',
|
|
258
|
+
})),
|
|
259
|
+
});
|
|
260
|
+
const apiKeySecurityScheme = object({
|
|
261
|
+
...securitySchemeBase.properties,
|
|
262
|
+
type: literal('apiKey'),
|
|
263
|
+
name: string({ typeComment: 'REQUIRED. The name of the header, query or cookie parameter to be used.' }),
|
|
264
|
+
in: union([literal('query'), literal('header'), literal('cookie')], {
|
|
265
|
+
typeComment: 'REQUIRED. The location of the API key. Valid values are "query", "header", or "cookie".',
|
|
266
|
+
}),
|
|
267
|
+
}, { typeName: 'ApiKeySecuritySchemeObject' });
|
|
268
|
+
const httpSecurityScheme = object({
|
|
269
|
+
...securitySchemeBase.properties,
|
|
270
|
+
type: literal('http'),
|
|
271
|
+
scheme: union([literal('basic'), literal('bearer')], {
|
|
272
|
+
typeName: 'HttpSecuritySchemeScheme',
|
|
273
|
+
typeComment: 'REQUIRED. The name of the HTTP Authentication scheme to be used in the Authorization header as defined in RFC7235.',
|
|
274
|
+
}),
|
|
275
|
+
bearerFormat: optional(string({
|
|
276
|
+
typeComment: 'A hint to the client to identify how the bearer token is formatted. Bearer tokens are usually generated by an authorization server, so this information is primarily for documentation purposes.',
|
|
277
|
+
})),
|
|
278
|
+
}, { typeName: 'HttpSecuritySchemeObject' });
|
|
279
|
+
const oauthFlowExtensionObjects = [
|
|
280
|
+
XScalarSecurityQuery,
|
|
281
|
+
XScalarSecurityBody,
|
|
282
|
+
XTokenName,
|
|
283
|
+
XScalarAuthUrl,
|
|
284
|
+
XScalarTokenUrl,
|
|
285
|
+
];
|
|
286
|
+
const oauthFlowCore = object({
|
|
287
|
+
refreshUrl: string({
|
|
288
|
+
typeComment: 'The URL to be used for obtaining refresh tokens. This MUST be in the form of a URL. The OAuth2 standard requires the use of TLS.',
|
|
289
|
+
}),
|
|
290
|
+
scopes: record(string(), string(), {
|
|
291
|
+
typeComment: 'REQUIRED. The available scopes for the OAuth2 security scheme. A map between the scope name and a short description for it. The map MAY be empty.',
|
|
292
|
+
typeName: 'OAuthFlowScopes',
|
|
293
|
+
}),
|
|
294
|
+
}, { typeName: 'OAuthFlowBaseCore' });
|
|
295
|
+
const implicitOAuth2Flow = intersection([
|
|
296
|
+
oauthFlowCore,
|
|
297
|
+
...oauthFlowExtensionObjects,
|
|
298
|
+
object({
|
|
299
|
+
authorizationUrl: string({
|
|
300
|
+
typeComment: 'REQUIRED. The authorization URL to be used for this flow. This MUST be in the form of a URL. The OAuth2 standard requires the use of TLS.',
|
|
301
|
+
}),
|
|
302
|
+
}, { typeName: 'ImplicitOAuthFlowObject' }),
|
|
303
|
+
]);
|
|
304
|
+
const passwordOAuth2Flow = intersection([
|
|
305
|
+
oauthFlowCore,
|
|
306
|
+
...oauthFlowExtensionObjects,
|
|
307
|
+
object({
|
|
308
|
+
tokenUrl: string({
|
|
309
|
+
typeComment: 'REQUIRED. The token URL to be used for this flow. This MUST be in the form of a URL. The OAuth2 standard requires the use of TLS.',
|
|
310
|
+
}),
|
|
311
|
+
}, { typeName: 'PasswordOAuthFlowObject' }),
|
|
312
|
+
XScalarCredentialsLocation,
|
|
313
|
+
]);
|
|
314
|
+
const clientCredentialsOAuth2Flow = intersection([
|
|
315
|
+
oauthFlowCore,
|
|
316
|
+
...oauthFlowExtensionObjects,
|
|
317
|
+
object({
|
|
318
|
+
tokenUrl: string({
|
|
319
|
+
typeComment: 'REQUIRED. The token URL to be used for this flow. This MUST be in the form of a URL. The OAuth2 standard requires the use of TLS.',
|
|
320
|
+
}),
|
|
321
|
+
}, { typeName: 'ClientCredentialsOAuthFlowObject' }),
|
|
322
|
+
XScalarCredentialsLocation,
|
|
323
|
+
]);
|
|
324
|
+
const authorizationCodeOAuth2Flow = intersection([
|
|
325
|
+
oauthFlowCore,
|
|
326
|
+
...oauthFlowExtensionObjects,
|
|
327
|
+
object({
|
|
328
|
+
authorizationUrl: string({
|
|
329
|
+
typeComment: 'REQUIRED. The authorization URL to be used for this flow. This MUST be in the form of a URL. The OAuth2 standard requires the use of TLS.',
|
|
330
|
+
}),
|
|
331
|
+
tokenUrl: string({
|
|
332
|
+
typeComment: 'REQUIRED. The token URL to be used for this flow. This MUST be in the form of a URL. The OAuth2 standard requires the use of TLS.',
|
|
333
|
+
}),
|
|
334
|
+
}, { typeName: 'AuthorizationCodeOAuthFlowObject' }),
|
|
335
|
+
XusePkce,
|
|
336
|
+
XScalarCredentialsLocation,
|
|
337
|
+
]);
|
|
338
|
+
const oauth2Flows = object({
|
|
339
|
+
implicit: optional(implicitOAuth2Flow),
|
|
340
|
+
password: optional(passwordOAuth2Flow),
|
|
341
|
+
clientCredentials: optional(clientCredentialsOAuth2Flow),
|
|
342
|
+
authorizationCode: optional(authorizationCodeOAuth2Flow),
|
|
343
|
+
}, { typeName: 'OAuthFlowsObject' });
|
|
344
|
+
const oauth2SecurityScheme = intersection([
|
|
345
|
+
object({
|
|
346
|
+
...securitySchemeBase.properties,
|
|
347
|
+
type: literal('oauth2'),
|
|
348
|
+
flows: oauth2Flows,
|
|
349
|
+
}, { typeName: 'OAuth2SecuritySchemeObject' }),
|
|
350
|
+
XDefaultScopes,
|
|
351
|
+
]);
|
|
352
|
+
const openIdConnectSecurityScheme = object({
|
|
353
|
+
...securitySchemeBase.properties,
|
|
354
|
+
type: literal('openIdConnect'),
|
|
355
|
+
openIdConnectUrl: string({
|
|
356
|
+
typeComment: 'REQUIRED. Well-known URL to discover the [[OpenID-Connect-Discovery]] provider metadata.',
|
|
357
|
+
}),
|
|
358
|
+
}, { typeName: 'OpenIdConnectSecuritySchemeObject' });
|
|
359
|
+
const securityScheme = union([apiKeySecurityScheme, httpSecurityScheme, oauth2SecurityScheme, openIdConnectSecurityScheme], { typeName: 'SecuritySchemeObject' });
|
|
360
|
+
const components = object({
|
|
361
|
+
schemas: optional(record(string(), maybeRef(schema), { typeName: 'ComponentsSchemas' })),
|
|
362
|
+
responses: optional(record(string(), maybeRef(lazy(() => response)), { typeName: 'ComponentsResponses' })),
|
|
363
|
+
parameters: optional(record(string(), maybeRef(lazy(() => parameter)), { typeName: 'ComponentsParameters' })),
|
|
364
|
+
examples: optional(record(string(), maybeRef(lazy(() => example)), { typeName: 'ComponentsExamples' })),
|
|
365
|
+
requestBodies: optional(record(string(), maybeRef(lazy(() => requestBody)), { typeName: 'ComponentsRequestBodies' })),
|
|
366
|
+
headers: optional(record(string(), maybeRef(lazy(() => header)), { typeName: 'ComponentsHeaders' })),
|
|
367
|
+
securitySchemes: optional(record(string(), maybeRef(lazy(() => securityScheme)), { typeName: 'ComponentsSecuritySchemes' })),
|
|
368
|
+
links: optional(record(string(), maybeRef(lazy(() => link)), { typeName: 'ComponentsLinks' })),
|
|
369
|
+
callbacks: optional(record(string(), maybeRef(lazy(() => callback)), { typeName: 'ComponentsCallbacks' })),
|
|
370
|
+
pathItems: optional(record(string(), lazy(() => pathItem), { typeName: 'ComponentsPathItems' })),
|
|
371
|
+
}, { typeName: 'ComponentsObject' });
|
|
372
|
+
const example = intersection([
|
|
373
|
+
object({
|
|
374
|
+
summary: optional(string({ typeComment: 'Short description for the example.' })),
|
|
375
|
+
description: optional(string({
|
|
376
|
+
typeComment: 'Long description for the example. CommonMark syntax MAY be used for rich text representation.',
|
|
377
|
+
})),
|
|
378
|
+
value: optional(any({
|
|
379
|
+
typeComment: 'Embedded literal example. The value field and externalValue field are mutually exclusive.',
|
|
380
|
+
})),
|
|
381
|
+
externalValue: optional(string({
|
|
382
|
+
typeComment: 'A URI that identifies the literal example. The value field and externalValue field are mutually exclusive.',
|
|
383
|
+
})),
|
|
384
|
+
}, { typeName: 'ExampleObject' }),
|
|
385
|
+
XDisabled,
|
|
386
|
+
]);
|
|
387
|
+
const headerBase = object({
|
|
388
|
+
description: optional(string({
|
|
389
|
+
typeComment: 'A brief description of the header. This could contain examples of use. CommonMark syntax MAY be used for rich text representation.',
|
|
390
|
+
})),
|
|
391
|
+
required: optional(boolean({ typeComment: 'Determines whether this header is mandatory. The default value is false.' })),
|
|
392
|
+
deprecated: optional(boolean({
|
|
393
|
+
typeComment: 'Specifies that the header is deprecated and SHOULD be transitioned out of usage. Default value is false.',
|
|
394
|
+
})),
|
|
395
|
+
}, { typeName: 'HeaderBase' });
|
|
396
|
+
const headerWithSchema = intersection([
|
|
397
|
+
headerBase,
|
|
398
|
+
object({
|
|
399
|
+
style: optional(string({
|
|
400
|
+
typeComment: 'Describes how the header value will be serialized. The default (and only legal value for headers) is "simple".',
|
|
401
|
+
})),
|
|
402
|
+
explode: optional(boolean({
|
|
403
|
+
typeComment: 'When this is true, header values of type array or object generate a single header whose value is a comma-separated list of the array items or key-value pairs of the map, see Style Examples.',
|
|
404
|
+
})),
|
|
405
|
+
schema: optional(maybeRef(lazy(() => schema))),
|
|
406
|
+
example: optional(any()),
|
|
407
|
+
examples: optional(record(string(), maybeRef(lazy(() => example)), { typeName: 'HeaderExamples' })),
|
|
408
|
+
}, { typeName: 'HeaderObjectWithSchema' }),
|
|
409
|
+
]);
|
|
410
|
+
const headerWithContent = intersection([
|
|
411
|
+
headerBase,
|
|
412
|
+
object({
|
|
413
|
+
content: optional(record(string(), lazy(() => mediaType), { typeName: 'HeaderContent' })),
|
|
414
|
+
}, { typeName: 'HeaderObjectWithContent' }),
|
|
415
|
+
]);
|
|
416
|
+
const header = union([headerWithSchema, headerWithContent], { typeName: 'HeaderObject' });
|
|
417
|
+
const encoding = object({
|
|
418
|
+
contentType: optional(string({
|
|
419
|
+
typeComment: 'The Content-Type for encoding a specific property. The value is a comma-separated list, each element of which is either a specific media type (e.g. image/png) or a wildcard media type (e.g. image/*).',
|
|
420
|
+
})),
|
|
421
|
+
headers: optional(record(string(), maybeRef(lazy(() => header)), { typeName: 'EncodingHeaders' })),
|
|
422
|
+
}, { typeName: 'EncodingObject' });
|
|
423
|
+
const mediaType = object({
|
|
424
|
+
schema: optional(maybeRef(lazy(() => schema))),
|
|
425
|
+
example: optional(any({ typeComment: 'Example of the media type.' })),
|
|
426
|
+
examples: optional(record(string(), maybeRef(lazy(() => example)), { typeName: 'MediaTypeExamples' })),
|
|
427
|
+
encoding: optional(record(string(), encoding, {
|
|
428
|
+
typeComment: 'A map between a property name and its encoding information. The key, being the property name, MUST exist in the schema as a property.',
|
|
429
|
+
typeName: 'MediaTypeEncoding',
|
|
430
|
+
})),
|
|
431
|
+
}, { typeName: 'MediaTypeObject' });
|
|
432
|
+
const parameterWithSchema = intersection([
|
|
433
|
+
object({
|
|
434
|
+
name: string({
|
|
435
|
+
typeComment: 'REQUIRED. The name of the parameter. Parameter names are case sensitive. If in is "path", the name field MUST correspond to a template expression occurring within the path field in the Paths Object.',
|
|
436
|
+
}),
|
|
437
|
+
in: union([literal('query'), literal('header'), literal('path'), literal('cookie')], {
|
|
438
|
+
typeName: 'ParameterLocation',
|
|
439
|
+
typeComment: 'REQUIRED. The location of the parameter. Possible values are "query", "header", "path" or "cookie".',
|
|
440
|
+
}),
|
|
441
|
+
description: optional(string({
|
|
442
|
+
typeComment: 'A brief description of the parameter. This could contain examples of use. CommonMark syntax MAY be used for rich text representation.',
|
|
443
|
+
})),
|
|
444
|
+
required: optional(boolean({
|
|
445
|
+
typeComment: 'Determines whether this parameter is mandatory. If the parameter location is "path", this field is REQUIRED and its value MUST be true.',
|
|
446
|
+
})),
|
|
447
|
+
deprecated: optional(boolean({
|
|
448
|
+
typeComment: 'Specifies that a parameter is deprecated and SHOULD be transitioned out of usage. Default value is false.',
|
|
449
|
+
})),
|
|
450
|
+
allowEmptyValue: optional(boolean({
|
|
451
|
+
typeComment: 'If true, clients MAY pass a zero-length string value in place of parameters that would otherwise be omitted entirely. This field is valid only for query parameters.',
|
|
452
|
+
})),
|
|
453
|
+
allowReserved: optional(boolean({
|
|
454
|
+
typeComment: 'When this is true, parameter values are serialized using reserved expansion, as defined by RFC6570. This field only applies to parameters with an in value of query. The default value is false.',
|
|
455
|
+
})),
|
|
456
|
+
style: optional(string({
|
|
457
|
+
typeComment: 'Describes how the parameter value will be serialized (depending on the schema type).',
|
|
458
|
+
})),
|
|
459
|
+
explode: optional(boolean({
|
|
460
|
+
typeComment: 'When this is true, parameter values of type array or object generate separate parameters for each array item or object property.',
|
|
461
|
+
})),
|
|
462
|
+
schema: optional(maybeRef(lazy(() => schema))),
|
|
463
|
+
example: optional(any()),
|
|
464
|
+
examples: optional(record(string(), maybeRef(lazy(() => example)), { typeName: 'ParameterExamples' })),
|
|
465
|
+
}, { typeName: 'ParameterObjectWithSchema' }),
|
|
466
|
+
XGlobal,
|
|
467
|
+
XInternal,
|
|
468
|
+
XScalarIgnore,
|
|
469
|
+
]);
|
|
470
|
+
const parameterWithContent = intersection([
|
|
471
|
+
object({
|
|
472
|
+
name: string({
|
|
473
|
+
typeComment: 'REQUIRED. The name of the parameter. Parameter names are case sensitive. If in is "path", the name field MUST correspond to a template expression occurring within the path field in the Paths Object.',
|
|
474
|
+
}),
|
|
475
|
+
in: union([literal('query'), literal('header'), literal('path'), literal('cookie')], {
|
|
476
|
+
typeName: 'ParameterLocation',
|
|
477
|
+
typeComment: 'REQUIRED. The location of the parameter. Possible values are "query", "header", "path" or "cookie".',
|
|
478
|
+
}),
|
|
479
|
+
description: optional(string({
|
|
480
|
+
typeComment: 'A brief description of the parameter. This could contain examples of use. CommonMark syntax MAY be used for rich text representation.',
|
|
481
|
+
})),
|
|
482
|
+
required: optional(boolean({
|
|
483
|
+
typeComment: 'Determines whether this parameter is mandatory. If the parameter location is "path", this field is REQUIRED and its value MUST be true.',
|
|
484
|
+
})),
|
|
485
|
+
deprecated: optional(boolean({
|
|
486
|
+
typeComment: 'Specifies that a parameter is deprecated and SHOULD be transitioned out of usage. Default value is false.',
|
|
487
|
+
})),
|
|
488
|
+
allowEmptyValue: optional(boolean({
|
|
489
|
+
typeComment: 'If true, clients MAY pass a zero-length string value in place of parameters that would otherwise be omitted entirely. This field is valid only for query parameters.',
|
|
490
|
+
})),
|
|
491
|
+
allowReserved: optional(boolean({
|
|
492
|
+
typeComment: 'When this is true, parameter values are serialized using reserved expansion, as defined by RFC6570. This field only applies to parameters with an in value of query. The default value is false.',
|
|
493
|
+
})),
|
|
494
|
+
content: optional(record(string(), lazy(() => mediaType), { typeName: 'ParameterContent' })),
|
|
495
|
+
}, { typeName: 'ParameterObjectWithContent' }),
|
|
496
|
+
XGlobal,
|
|
497
|
+
XInternal,
|
|
498
|
+
XScalarIgnore,
|
|
499
|
+
]);
|
|
500
|
+
const parameter = union([parameterWithSchema, parameterWithContent], { typeName: 'ParameterObject' });
|
|
501
|
+
const requestBody = intersection([
|
|
502
|
+
object({
|
|
503
|
+
description: optional(string({
|
|
504
|
+
typeComment: 'A brief description of the request body. This could contain examples of use. CommonMark syntax MAY be used for rich text representation.',
|
|
505
|
+
})),
|
|
506
|
+
content: record(string(), lazy(() => mediaType), {
|
|
507
|
+
typeComment: 'REQUIRED. The content of the request body. The key is a media type or media type range and the value describes it.',
|
|
508
|
+
typeName: 'RequestBodyContent',
|
|
509
|
+
}),
|
|
510
|
+
required: optional(boolean({ typeComment: 'Determines if the request body is required in the request. Defaults to false.' })),
|
|
511
|
+
}, { typeName: 'RequestBodyObject' }),
|
|
512
|
+
XScalarSelectedContentType,
|
|
513
|
+
]);
|
|
514
|
+
const link = object({
|
|
515
|
+
operationRef: optional(string({
|
|
516
|
+
typeComment: 'A URI reference to an OAS operation. This field is mutually exclusive of the operationId field, and MUST point to an Operation Object.',
|
|
517
|
+
})),
|
|
518
|
+
operationId: optional(string({
|
|
519
|
+
typeComment: 'The name of an existing, resolvable OAS operation, as defined with a unique operationId. This field is mutually exclusive of the operationRef field.',
|
|
520
|
+
})),
|
|
521
|
+
parameters: optional(record(string(), any(), {
|
|
522
|
+
typeComment: 'A map representing parameters to pass to an operation as specified with operationId or identified via operationRef.',
|
|
523
|
+
typeName: 'LinkParameters',
|
|
524
|
+
})),
|
|
525
|
+
requestBody: optional(any({
|
|
526
|
+
typeComment: 'A literal value or {expression} to use as a request body when calling the target operation.',
|
|
527
|
+
})),
|
|
528
|
+
description: optional(string({
|
|
529
|
+
typeComment: 'A description of the link. CommonMark syntax MAY be used for rich text representation.',
|
|
530
|
+
})),
|
|
531
|
+
server: optional(servers),
|
|
532
|
+
}, { typeName: 'LinkObject' });
|
|
533
|
+
const response = object({
|
|
534
|
+
description: string({
|
|
535
|
+
typeComment: 'REQUIRED. A description of the response. CommonMark syntax MAY be used for rich text representation.',
|
|
536
|
+
}),
|
|
537
|
+
headers: optional(record(string(), maybeRef(lazy(() => header)), { typeName: 'ResponseHeaders' })),
|
|
538
|
+
content: optional(record(string(), lazy(() => mediaType), { typeName: 'ResponseContent' })),
|
|
539
|
+
links: optional(record(string(), maybeRef(lazy(() => link)), { typeName: 'ResponseLinks' })),
|
|
540
|
+
}, { typeName: 'ResponseObject' });
|
|
541
|
+
const responsesObject = record(string(), maybeRef(lazy(() => response)), {
|
|
542
|
+
typeName: 'ResponsesObject',
|
|
543
|
+
});
|
|
544
|
+
const callback = record(string(), maybeRef(lazy(() => pathItem)), {
|
|
545
|
+
typeName: 'CallbackObject',
|
|
546
|
+
});
|
|
547
|
+
const operation = intersection([
|
|
548
|
+
object({
|
|
549
|
+
tags: optional(array(string(), {
|
|
550
|
+
typeComment: 'A list of tags for API documentation control. Tags can be used for logical grouping of operations by resources or any other qualifier.',
|
|
551
|
+
typeName: 'OperationTags',
|
|
552
|
+
})),
|
|
553
|
+
summary: optional(string({ typeComment: 'A short summary of what the operation does.' })),
|
|
554
|
+
description: optional(string({
|
|
555
|
+
typeComment: 'A verbose explanation of the operation behavior. CommonMark syntax MAY be used for rich text representation.',
|
|
556
|
+
})),
|
|
557
|
+
externalDocs: optional(externalDocs),
|
|
558
|
+
operationId: optional(string({
|
|
559
|
+
typeComment: 'Unique string used to identify the operation. The id MUST be unique among all operations described in the API. The operationId value is case-sensitive.',
|
|
560
|
+
})),
|
|
561
|
+
parameters: optional(array(maybeRef(lazy(() => parameter)), { typeName: 'OperationParameters' })),
|
|
562
|
+
requestBody: optional(maybeRef(lazy(() => requestBody))),
|
|
563
|
+
responses: optional(lazy(() => responsesObject)),
|
|
564
|
+
deprecated: optional(boolean({
|
|
565
|
+
typeComment: 'Declares this operation to be deprecated. Consumers SHOULD refrain from usage of the declared operation. Default value is false.',
|
|
566
|
+
})),
|
|
567
|
+
security: optional(array(securityRequirement, { typeName: 'OperationSecurity' })),
|
|
568
|
+
servers: optional(array(servers, { typeName: 'OperationServers' })),
|
|
569
|
+
callbacks: optional(record(string(), maybeRef(lazy(() => callback)), { typeName: 'OperationCallbacks' })),
|
|
570
|
+
}, { typeName: 'OperationObject' }),
|
|
571
|
+
XBadges,
|
|
572
|
+
XInternal,
|
|
573
|
+
XScalarIgnore,
|
|
574
|
+
XCodeSamples,
|
|
575
|
+
XScalarStability,
|
|
576
|
+
XScalarDisableParameters,
|
|
577
|
+
XPostResponse,
|
|
578
|
+
XDraftExamples,
|
|
579
|
+
XScalarSelectedServer,
|
|
580
|
+
]);
|
|
581
|
+
const pathItem = object({
|
|
582
|
+
$ref: optional(string({
|
|
583
|
+
typeComment: 'Allows for a referenced definition of this path item. The value MUST be in the form of a URI, and the referenced structure MUST be in the form of a Path Item Object.',
|
|
584
|
+
})),
|
|
585
|
+
summary: optional(string({
|
|
586
|
+
typeComment: 'An optional string summary, intended to apply to all operations in this path.',
|
|
587
|
+
})),
|
|
588
|
+
description: optional(string({
|
|
589
|
+
typeComment: 'An optional string description, intended to apply to all operations in this path. CommonMark syntax MAY be used for rich text representation.',
|
|
590
|
+
})),
|
|
591
|
+
get: optional(maybeRef(lazy(() => operation))),
|
|
592
|
+
put: optional(maybeRef(lazy(() => operation))),
|
|
593
|
+
post: optional(maybeRef(lazy(() => operation))),
|
|
594
|
+
delete: optional(maybeRef(lazy(() => operation))),
|
|
595
|
+
patch: optional(maybeRef(lazy(() => operation))),
|
|
596
|
+
connect: optional(maybeRef(lazy(() => operation))),
|
|
597
|
+
options: optional(maybeRef(lazy(() => operation))),
|
|
598
|
+
head: optional(maybeRef(lazy(() => operation))),
|
|
599
|
+
trace: optional(maybeRef(lazy(() => operation))),
|
|
600
|
+
servers: optional(array(servers, { typeName: 'PathItemServers' })),
|
|
601
|
+
parameters: optional(array(maybeRef(lazy(() => parameter)), { typeName: 'PathItemParameters' })),
|
|
602
|
+
}, { typeName: 'PathItemObject' });
|
|
603
|
+
const openApiExtensionsPartial = object({
|
|
604
|
+
'x-original-oas-version': optional(string({ typeComment: 'Original OpenAPI Specification version of the source document.' })),
|
|
605
|
+
'x-scalar-original-source-url': optional(string({
|
|
606
|
+
typeComment: 'Original document source URL when loading a document from an external source.',
|
|
607
|
+
})),
|
|
608
|
+
[extensions.document.navigation]: optional(any({
|
|
609
|
+
typeComment: 'Client navigation tree (TraversedDocument) for this OpenAPI description. Matches TraversedDocumentObjectRef in strict schemas.',
|
|
610
|
+
})),
|
|
611
|
+
}, { typeName: 'OpenApiExtensionsPartial' });
|
|
612
|
+
const openApiDocumentCore = object({
|
|
613
|
+
openapi: string({
|
|
614
|
+
typeComment: 'REQUIRED. This string MUST be the version number of the OpenAPI Specification that the OpenAPI Document uses. The openapi field SHOULD be used by tooling to interpret the OpenAPI Document. This is not related to the API info.version string.',
|
|
615
|
+
}),
|
|
616
|
+
info,
|
|
617
|
+
jsonSchemaDialect: optional(string({
|
|
618
|
+
typeComment: 'The default value for the $schema keyword within Schema Objects contained within this OAS document. This MUST be in the form of a URI.',
|
|
619
|
+
})),
|
|
620
|
+
servers: optional(array(servers, {
|
|
621
|
+
typeComment: 'An array of Server Objects, which provide connectivity information to a target server. If the servers field is not provided, or is an empty array, the default value would be a Server Object with a url value of /.',
|
|
622
|
+
typeName: 'OpenApiServers',
|
|
623
|
+
})),
|
|
624
|
+
paths: optional(record(string(), pathItem, {
|
|
625
|
+
typeComment: 'The available paths and operations for the API.',
|
|
626
|
+
typeName: 'PathsObject',
|
|
627
|
+
})),
|
|
628
|
+
webhooks: optional(record(string(), pathItem, {
|
|
629
|
+
typeComment: 'The incoming webhooks that MAY be received as part of this API and that the API consumer MAY choose to implement.',
|
|
630
|
+
typeName: 'WebhooksObject',
|
|
631
|
+
})),
|
|
632
|
+
components: optional(components),
|
|
633
|
+
security: optional(array(securityRequirement, {
|
|
634
|
+
typeComment: 'A declaration of which security mechanisms can be used across the API. The list of values includes alternative Security Requirement Objects that can be used. Only one of the Security Requirement Objects need to be satisfied to authorize a request.',
|
|
635
|
+
typeName: 'OpenApiSecurity',
|
|
636
|
+
})),
|
|
637
|
+
tags: optional(array(tag, {
|
|
638
|
+
typeComment: 'A list of tags used by the OpenAPI Description with additional metadata. The order of the tags can be used to reflect on their order by the parsing tools.',
|
|
639
|
+
})),
|
|
640
|
+
externalDocs: optional(externalDocs),
|
|
641
|
+
}, { typeName: 'OpenApiDocumentCore' });
|
|
642
|
+
const openapi = intersection([
|
|
643
|
+
openApiDocumentCore,
|
|
644
|
+
openApiExtensionsPartial,
|
|
645
|
+
XTagGroups,
|
|
646
|
+
XScalarEnvironments,
|
|
647
|
+
XScalarSelectedServer,
|
|
648
|
+
XScalarIcon,
|
|
649
|
+
XScalarOrder,
|
|
650
|
+
XScalarCookies,
|
|
651
|
+
XScalarOriginalDocumentHash,
|
|
652
|
+
XScalarIsDirty,
|
|
653
|
+
XScalarActiveEnvironment,
|
|
654
|
+
XScalarWatchMode,
|
|
655
|
+
XScalarRegistryMeta,
|
|
656
|
+
], {
|
|
657
|
+
typeName: 'OpenApiDocument',
|
|
658
|
+
typeComment: 'Root OpenAPI 3.1 document including Scalar workspace extensions (OpenApiExtensionsSchema).',
|
|
659
|
+
});
|
|
660
|
+
return openapi;
|
|
661
|
+
};
|