@camunda8/docusaurus-plugin-openapi-docs 4.5.1
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 +386 -0
- package/lib/index.d.ts +9 -0
- package/lib/index.js +714 -0
- package/lib/markdown/createArrayBracket.d.ts +2 -0
- package/lib/markdown/createArrayBracket.js +36 -0
- package/lib/markdown/createAuthentication.d.ts +2 -0
- package/lib/markdown/createAuthentication.js +173 -0
- package/lib/markdown/createAuthorization.d.ts +1 -0
- package/lib/markdown/createAuthorization.js +15 -0
- package/lib/markdown/createCallbackMethodEndpoint.d.ts +1 -0
- package/lib/markdown/createCallbackMethodEndpoint.js +20 -0
- package/lib/markdown/createCallbacks.d.ts +6 -0
- package/lib/markdown/createCallbacks.js +77 -0
- package/lib/markdown/createContactInfo.d.ts +2 -0
- package/lib/markdown/createContactInfo.js +39 -0
- package/lib/markdown/createDeprecationNotice.d.ts +6 -0
- package/lib/markdown/createDeprecationNotice.js +20 -0
- package/lib/markdown/createDescription.d.ts +1 -0
- package/lib/markdown/createDescription.js +13 -0
- package/lib/markdown/createDetails.d.ts +2 -0
- package/lib/markdown/createDetails.js +17 -0
- package/lib/markdown/createDetailsSummary.d.ts +2 -0
- package/lib/markdown/createDetailsSummary.js +17 -0
- package/lib/markdown/createDownload.d.ts +1 -0
- package/lib/markdown/createDownload.js +16 -0
- package/lib/markdown/createHeading.d.ts +1 -0
- package/lib/markdown/createHeading.js +20 -0
- package/lib/markdown/createLicense.d.ts +2 -0
- package/lib/markdown/createLicense.js +32 -0
- package/lib/markdown/createLogo.d.ts +2 -0
- package/lib/markdown/createLogo.js +18 -0
- package/lib/markdown/createMethodEndpoint.d.ts +1 -0
- package/lib/markdown/createMethodEndpoint.js +20 -0
- package/lib/markdown/createParamsDetails.d.ts +6 -0
- package/lib/markdown/createParamsDetails.js +18 -0
- package/lib/markdown/createRequestBodyDetails.d.ts +13 -0
- package/lib/markdown/createRequestBodyDetails.js +13 -0
- package/lib/markdown/createRequestHeader.d.ts +1 -0
- package/lib/markdown/createRequestHeader.js +23 -0
- package/lib/markdown/createRequestSchema.d.ts +14 -0
- package/lib/markdown/createRequestSchema.js +20 -0
- package/lib/markdown/createResponseSchema.d.ts +14 -0
- package/lib/markdown/createResponseSchema.js +20 -0
- package/lib/markdown/createSchema.d.ts +9 -0
- package/lib/markdown/createSchema.js +668 -0
- package/lib/markdown/createSchema.test.d.ts +1 -0
- package/lib/markdown/createSchema.test.js +913 -0
- package/lib/markdown/createStatusCodes.d.ts +9 -0
- package/lib/markdown/createStatusCodes.js +63 -0
- package/lib/markdown/createTermsOfService.d.ts +1 -0
- package/lib/markdown/createTermsOfService.js +31 -0
- package/lib/markdown/createVendorExtensions.d.ts +1 -0
- package/lib/markdown/createVendorExtensions.js +24 -0
- package/lib/markdown/createVersionBadge.d.ts +1 -0
- package/lib/markdown/createVersionBadge.js +19 -0
- package/lib/markdown/index.d.ts +5 -0
- package/lib/markdown/index.js +93 -0
- package/lib/markdown/schema.d.ts +3 -0
- package/lib/markdown/schema.js +157 -0
- package/lib/markdown/schema.test.d.ts +1 -0
- package/lib/markdown/schema.test.js +181 -0
- package/lib/markdown/utils.d.ts +20 -0
- package/lib/markdown/utils.js +68 -0
- package/lib/openapi/createRequestExample.d.ts +2 -0
- package/lib/openapi/createRequestExample.js +14 -0
- package/lib/openapi/createResponseExample.d.ts +2 -0
- package/lib/openapi/createResponseExample.js +14 -0
- package/lib/openapi/createSchemaExample.d.ts +7 -0
- package/lib/openapi/createSchemaExample.js +231 -0
- package/lib/openapi/index.d.ts +1 -0
- package/lib/openapi/index.js +12 -0
- package/lib/openapi/openapi.d.ts +12 -0
- package/lib/openapi/openapi.js +634 -0
- package/lib/openapi/openapi.test.d.ts +1 -0
- package/lib/openapi/openapi.test.js +33 -0
- package/lib/openapi/sdkExamples.d.ts +39 -0
- package/lib/openapi/sdkExamples.js +141 -0
- package/lib/openapi/types.d.ts +352 -0
- package/lib/openapi/types.js +8 -0
- package/lib/openapi/utils/loadAndResolveSpec.d.ts +2 -0
- package/lib/openapi/utils/loadAndResolveSpec.js +153 -0
- package/lib/openapi/utils/services/OpenAPIParser.d.ts +52 -0
- package/lib/openapi/utils/services/OpenAPIParser.js +343 -0
- package/lib/openapi/utils/services/RedocNormalizedOptions.d.ts +100 -0
- package/lib/openapi/utils/services/RedocNormalizedOptions.js +170 -0
- package/lib/openapi/utils/types/index.d.ts +2 -0
- package/lib/openapi/utils/types/index.js +23 -0
- package/lib/openapi/utils/types/open-api.d.ts +305 -0
- package/lib/openapi/utils/types/open-api.js +8 -0
- package/lib/openapi/utils/types.d.ts +307 -0
- package/lib/openapi/utils/types.js +8 -0
- package/lib/openapi/utils/utils/JsonPointer.d.ts +51 -0
- package/lib/openapi/utils/utils/JsonPointer.js +95 -0
- package/lib/openapi/utils/utils/helpers.d.ts +43 -0
- package/lib/openapi/utils/utils/helpers.js +230 -0
- package/lib/openapi/utils/utils/index.d.ts +3 -0
- package/lib/openapi/utils/utils/index.js +25 -0
- package/lib/openapi/utils/utils/openapi.d.ts +40 -0
- package/lib/openapi/utils/utils/openapi.js +605 -0
- package/lib/openapi/webhooks.test.d.ts +1 -0
- package/lib/openapi/webhooks.test.js +23 -0
- package/lib/options.d.ts +2 -0
- package/lib/options.js +70 -0
- package/lib/sidebars/index.d.ts +4 -0
- package/lib/sidebars/index.js +226 -0
- package/lib/sidebars/utils.d.ts +2 -0
- package/lib/sidebars/utils.js +30 -0
- package/lib/types.d.ts +138 -0
- package/lib/types.js +8 -0
- package/package.json +68 -0
- package/src/index.ts +955 -0
- package/src/markdown/__snapshots__/createSchema.test.ts.snap +1605 -0
- package/src/markdown/createArrayBracket.ts +35 -0
- package/src/markdown/createAuthentication.ts +209 -0
- package/src/markdown/createAuthorization.ts +13 -0
- package/src/markdown/createCallbackMethodEndpoint.ts +19 -0
- package/src/markdown/createCallbacks.ts +101 -0
- package/src/markdown/createContactInfo.ts +41 -0
- package/src/markdown/createDeprecationNotice.ts +31 -0
- package/src/markdown/createDescription.ts +12 -0
- package/src/markdown/createDetails.ts +16 -0
- package/src/markdown/createDetailsSummary.ts +16 -0
- package/src/markdown/createDownload.ts +15 -0
- package/src/markdown/createHeading.ts +23 -0
- package/src/markdown/createLicense.ts +34 -0
- package/src/markdown/createLogo.ts +21 -0
- package/src/markdown/createMethodEndpoint.ts +19 -0
- package/src/markdown/createParamsDetails.ts +22 -0
- package/src/markdown/createRequestBodyDetails.ts +24 -0
- package/src/markdown/createRequestHeader.ts +22 -0
- package/src/markdown/createRequestSchema.ts +32 -0
- package/src/markdown/createResponseSchema.ts +32 -0
- package/src/markdown/createSchema.test.ts +1075 -0
- package/src/markdown/createSchema.ts +864 -0
- package/src/markdown/createStatusCodes.ts +63 -0
- package/src/markdown/createTermsOfService.ts +30 -0
- package/src/markdown/createVendorExtensions.ts +22 -0
- package/src/markdown/createVersionBadge.ts +22 -0
- package/src/markdown/index.ts +145 -0
- package/src/markdown/schema.test.ts +208 -0
- package/src/markdown/schema.ts +188 -0
- package/src/markdown/utils.ts +89 -0
- package/src/openapi/__fixtures__/examples/openapi.yaml +49 -0
- package/src/openapi/__fixtures__/webhook/openapi.yaml +17 -0
- package/src/openapi/createRequestExample.ts +13 -0
- package/src/openapi/createResponseExample.ts +13 -0
- package/src/openapi/createSchemaExample.ts +292 -0
- package/src/openapi/index.ts +8 -0
- package/src/openapi/openapi.test.ts +40 -0
- package/src/openapi/openapi.ts +772 -0
- package/src/openapi/sdkExamples.ts +195 -0
- package/src/openapi/types.ts +458 -0
- package/src/openapi/utils/loadAndResolveSpec.ts +171 -0
- package/src/openapi/utils/services/OpenAPIParser.ts +434 -0
- package/src/openapi/utils/services/RedocNormalizedOptions.ts +330 -0
- package/src/openapi/utils/types/index.ts +10 -0
- package/src/openapi/utils/types/open-api.ts +303 -0
- package/src/openapi/utils/types.ts +304 -0
- package/src/openapi/utils/utils/JsonPointer.ts +99 -0
- package/src/openapi/utils/utils/helpers.ts +239 -0
- package/src/openapi/utils/utils/index.ts +11 -0
- package/src/openapi/utils/utils/openapi.ts +771 -0
- package/src/openapi/webhooks.test.ts +30 -0
- package/src/openapi-to-postmanv2.d.ts +10 -0
- package/src/options.ts +78 -0
- package/src/plugin-openapi.d.ts +88 -0
- package/src/sidebars/index.ts +322 -0
- package/src/sidebars/utils.ts +29 -0
- package/src/types.ts +180 -0
- package/tsconfig.json +7 -0
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
/* ============================================================================
|
|
2
|
+
* Copyright (c) Palo Alto Networks
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
* ========================================================================== */
|
|
7
|
+
|
|
8
|
+
import path from "path";
|
|
9
|
+
|
|
10
|
+
import fs from "fs-extra";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Configuration for a single SDK example source.
|
|
14
|
+
*/
|
|
15
|
+
export interface SdkExampleSource {
|
|
16
|
+
/** Language label shown in the code sample tab (e.g. "TypeScript", "Python", "C#"). */
|
|
17
|
+
lang: string;
|
|
18
|
+
/** Syntax highlight mode (e.g. "typescript", "python", "csharp"). */
|
|
19
|
+
highlight?: string;
|
|
20
|
+
/** Path to the operation-map.json file (relative to site root or absolute). */
|
|
21
|
+
operationMapPath: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* A single entry in operation-map.json for one operationId.
|
|
26
|
+
*/
|
|
27
|
+
interface OperationMapEntry {
|
|
28
|
+
file: string;
|
|
29
|
+
region: string;
|
|
30
|
+
label?: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Shape of operation-map.json: operationId -> entries[].
|
|
35
|
+
*/
|
|
36
|
+
type OperationMap = Record<string, OperationMapEntry[]>;
|
|
37
|
+
|
|
38
|
+
// Region marker patterns for supported languages.
|
|
39
|
+
// Each pattern matches the start/end of a named region.
|
|
40
|
+
const REGION_PATTERNS: {
|
|
41
|
+
start: RegExp;
|
|
42
|
+
end: RegExp;
|
|
43
|
+
}[] = [
|
|
44
|
+
// TypeScript/JavaScript: //#region Name ... //#endregion [Name]
|
|
45
|
+
{
|
|
46
|
+
start: /^\s*\/\/#region\s+(.+?)\s*$/,
|
|
47
|
+
end: /^\s*\/\/#endregion(?:\s+(.+?))?\s*$/,
|
|
48
|
+
},
|
|
49
|
+
// C#: #region Name ... #endregion [Name]
|
|
50
|
+
{
|
|
51
|
+
start: /^\s*#region\s+(.+?)\s*$/,
|
|
52
|
+
end: /^\s*#endregion(?:\s+(.+?))?\s*$/,
|
|
53
|
+
},
|
|
54
|
+
// XML-style: // <RegionName> ... // </RegionName>
|
|
55
|
+
{
|
|
56
|
+
start: /^\s*\/\/\s*<([A-Za-z]\w*)>\s*$/,
|
|
57
|
+
end: /^\s*\/\/\s*<\/([A-Za-z]\w*)>\s*$/,
|
|
58
|
+
},
|
|
59
|
+
// Python: # region Name ... # endregion [Name]
|
|
60
|
+
{
|
|
61
|
+
start: /^\s*#\s*region\s+(.+?)\s*$/,
|
|
62
|
+
end: /^\s*#\s*endregion(?:\s+(.+?))?\s*$/,
|
|
63
|
+
},
|
|
64
|
+
];
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Extract the code between region markers from a source file's content.
|
|
68
|
+
* Returns the trimmed code block or undefined if the region is not found.
|
|
69
|
+
*/
|
|
70
|
+
function extractRegion(
|
|
71
|
+
content: string,
|
|
72
|
+
regionName: string
|
|
73
|
+
): string | undefined {
|
|
74
|
+
const lines = content.split(/\r?\n/);
|
|
75
|
+
let capturing = false;
|
|
76
|
+
let capturedLines: string[] = [];
|
|
77
|
+
|
|
78
|
+
for (const line of lines) {
|
|
79
|
+
if (capturing) {
|
|
80
|
+
// Check if this line is an end marker for our region
|
|
81
|
+
for (const pattern of REGION_PATTERNS) {
|
|
82
|
+
const endMatch = line.match(pattern.end);
|
|
83
|
+
if (
|
|
84
|
+
endMatch &&
|
|
85
|
+
(!endMatch[1] || endMatch[1].trim() === regionName)
|
|
86
|
+
) {
|
|
87
|
+
// Found end marker — return captured content
|
|
88
|
+
return trimIndentation(capturedLines);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
capturedLines.push(line);
|
|
92
|
+
} else {
|
|
93
|
+
// Check if this line is a start marker for our region
|
|
94
|
+
for (const pattern of REGION_PATTERNS) {
|
|
95
|
+
const startMatch = line.match(pattern.start);
|
|
96
|
+
if (startMatch && startMatch[1].trim() === regionName) {
|
|
97
|
+
capturing = true;
|
|
98
|
+
capturedLines = [];
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return undefined;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Remove the common leading whitespace from all non-empty lines.
|
|
110
|
+
*/
|
|
111
|
+
function trimIndentation(lines: string[]): string {
|
|
112
|
+
const nonEmptyLines = lines.filter((l) => l.trim().length > 0);
|
|
113
|
+
if (nonEmptyLines.length === 0) return "";
|
|
114
|
+
|
|
115
|
+
const minIndent = Math.min(
|
|
116
|
+
...nonEmptyLines.map((l) => {
|
|
117
|
+
const match = l.match(/^(\s*)/);
|
|
118
|
+
return match ? match[1].length : 0;
|
|
119
|
+
})
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
return lines
|
|
123
|
+
.map((l) => (l.trim().length === 0 ? "" : l.slice(minIndent)))
|
|
124
|
+
.join("\n")
|
|
125
|
+
.trim();
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Build x-codeSamples entries for a given operationId from all configured SDK sources.
|
|
130
|
+
*
|
|
131
|
+
* @param operationId - The OpenAPI operationId to look up.
|
|
132
|
+
* @param sdkExamples - Array of SDK example source configurations.
|
|
133
|
+
* @param siteDir - The Docusaurus site root directory (for resolving relative paths).
|
|
134
|
+
* @param fileCache - Shared cache to avoid re-reading the same source files.
|
|
135
|
+
* @param mapCache - Shared cache for parsed operation-map.json files.
|
|
136
|
+
* @returns Array of x-codeSamples entries, or empty array if none found.
|
|
137
|
+
*/
|
|
138
|
+
export function buildCodeSamples(
|
|
139
|
+
operationId: string,
|
|
140
|
+
sdkExamples: SdkExampleSource[],
|
|
141
|
+
siteDir: string,
|
|
142
|
+
fileCache: Map<string, string>,
|
|
143
|
+
mapCache: Map<string, OperationMap>
|
|
144
|
+
): { lang: string; label: string; source: string }[] {
|
|
145
|
+
const samples: { lang: string; label: string; source: string }[] = [];
|
|
146
|
+
|
|
147
|
+
for (const sdk of sdkExamples) {
|
|
148
|
+
const mapPath = path.resolve(siteDir, sdk.operationMapPath);
|
|
149
|
+
let operationMap = mapCache.get(mapPath);
|
|
150
|
+
if (!operationMap) {
|
|
151
|
+
if (!fs.existsSync(mapPath)) {
|
|
152
|
+
console.warn(`SDK examples: operation-map not found at ${mapPath}`);
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
operationMap = fs.readJSONSync(mapPath) as OperationMap;
|
|
156
|
+
mapCache.set(mapPath, operationMap);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const entries = operationMap[operationId];
|
|
160
|
+
if (!entries || entries.length === 0) continue;
|
|
161
|
+
|
|
162
|
+
const mapDir = path.dirname(mapPath);
|
|
163
|
+
|
|
164
|
+
for (const entry of entries) {
|
|
165
|
+
const filePath = path.resolve(mapDir, entry.file);
|
|
166
|
+
let fileContent = fileCache.get(filePath);
|
|
167
|
+
if (fileContent === undefined) {
|
|
168
|
+
if (!fs.existsSync(filePath)) {
|
|
169
|
+
console.warn(
|
|
170
|
+
`SDK examples: source file not found at ${filePath} (referenced by ${sdk.lang} operation-map for ${operationId})`
|
|
171
|
+
);
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
fileContent = fs.readFileSync(filePath, "utf-8");
|
|
175
|
+
fileCache.set(filePath, fileContent);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const code = extractRegion(fileContent, entry.region);
|
|
179
|
+
if (!code) {
|
|
180
|
+
console.warn(
|
|
181
|
+
`SDK examples: region "${entry.region}" not found in ${filePath} (${sdk.lang}, ${operationId})`
|
|
182
|
+
);
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
samples.push({
|
|
187
|
+
lang: sdk.lang,
|
|
188
|
+
label: "SDK",
|
|
189
|
+
source: code,
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
return samples;
|
|
195
|
+
}
|
|
@@ -0,0 +1,458 @@
|
|
|
1
|
+
/* ============================================================================
|
|
2
|
+
* Copyright (c) Palo Alto Networks
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
* ========================================================================== */
|
|
7
|
+
|
|
8
|
+
import type {
|
|
9
|
+
JSONSchema4,
|
|
10
|
+
JSONSchema6,
|
|
11
|
+
JSONSchema7,
|
|
12
|
+
JSONSchema7TypeName,
|
|
13
|
+
} from "json-schema";
|
|
14
|
+
|
|
15
|
+
export interface OpenApiObject {
|
|
16
|
+
openapi: string;
|
|
17
|
+
info: InfoObject;
|
|
18
|
+
servers?: ServerObject[];
|
|
19
|
+
paths: PathsObject;
|
|
20
|
+
components?: ComponentsObject;
|
|
21
|
+
security?: SecurityRequirementObject[];
|
|
22
|
+
tags?: TagObject[];
|
|
23
|
+
externalDocs?: ExternalDocumentationObject;
|
|
24
|
+
swagger?: string;
|
|
25
|
+
webhooks?: PathsObject;
|
|
26
|
+
"x-webhooks"?: PathsObject;
|
|
27
|
+
"x-tagGroups"?: TagGroupObject[];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface OpenApiObjectWithRef {
|
|
31
|
+
openapi: string;
|
|
32
|
+
info: InfoObject;
|
|
33
|
+
servers?: ServerObject[];
|
|
34
|
+
paths: PathsObjectWithRef;
|
|
35
|
+
components?: ComponentsObjectWithRef;
|
|
36
|
+
security?: SecurityRequirementObject[];
|
|
37
|
+
tags?: TagObject[];
|
|
38
|
+
externalDocs?: ExternalDocumentationObject;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface InfoObject {
|
|
42
|
+
title: string;
|
|
43
|
+
description?: string;
|
|
44
|
+
termsOfService?: string;
|
|
45
|
+
contact?: ContactObject;
|
|
46
|
+
license?: LicenseObject;
|
|
47
|
+
version: string;
|
|
48
|
+
tags?: TagObject[];
|
|
49
|
+
"x-logo"?: LogoObject;
|
|
50
|
+
"x-dark-logo"?: LogoObject;
|
|
51
|
+
logo?: LogoObject;
|
|
52
|
+
darkLogo?: LogoObject;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface LogoObject {
|
|
56
|
+
url?: string;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface ContactObject {
|
|
60
|
+
name?: string;
|
|
61
|
+
url?: string;
|
|
62
|
+
email?: string;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface LicenseObject {
|
|
66
|
+
name: string;
|
|
67
|
+
url?: string;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface ServerObject {
|
|
71
|
+
url: string;
|
|
72
|
+
description?: string;
|
|
73
|
+
variables?: Record<string, ServerVariable>;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface ServerVariable {
|
|
77
|
+
enum?: string[];
|
|
78
|
+
default: string;
|
|
79
|
+
description?: string;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export interface ComponentsObject {
|
|
83
|
+
schemas?: Record<string, SchemaObject>;
|
|
84
|
+
responses?: Record<string, ResponseObject>;
|
|
85
|
+
parameters?: Record<string, ParameterObject>;
|
|
86
|
+
examples?: Record<string, ExampleObject>;
|
|
87
|
+
requestBodies?: Record<string, RequestBodyObject>;
|
|
88
|
+
headers?: Record<string, HeaderObject>;
|
|
89
|
+
securitySchemes?: Record<string, SecuritySchemeObject>;
|
|
90
|
+
links?: Record<string, LinkObject>;
|
|
91
|
+
callbacks?: Record<string, CallbackObject>;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export interface ComponentsObjectWithRef {
|
|
95
|
+
schemas?: Record<string, SchemaObjectWithRef | ReferenceObject>;
|
|
96
|
+
responses?: Record<string, ResponseObjectWithRef | ReferenceObject>;
|
|
97
|
+
parameters?: Record<string, ParameterObjectWithRef | ReferenceObject>;
|
|
98
|
+
examples?: Record<string, ExampleObject | ReferenceObject>;
|
|
99
|
+
requestBodies?: Record<string, RequestBodyObjectWithRef | ReferenceObject>;
|
|
100
|
+
headers?: Record<string, HeaderObjectWithRef | ReferenceObject>;
|
|
101
|
+
securitySchemes?: Record<string, SecuritySchemeObject | ReferenceObject>;
|
|
102
|
+
links?: Record<string, LinkObject | ReferenceObject>;
|
|
103
|
+
callbacks?: Record<string, CallbackObjectWithRef | ReferenceObject>;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export type PathsObject = Record<string, PathItemObject>;
|
|
107
|
+
|
|
108
|
+
export type PathsObjectWithRef = Record<string, PathItemObjectWithRef>;
|
|
109
|
+
|
|
110
|
+
export interface PathItemObject {
|
|
111
|
+
$ref?: string;
|
|
112
|
+
summary?: string;
|
|
113
|
+
description?: string;
|
|
114
|
+
get?: OperationObject;
|
|
115
|
+
put?: OperationObject;
|
|
116
|
+
post?: OperationObject;
|
|
117
|
+
delete?: OperationObject;
|
|
118
|
+
options?: OperationObject;
|
|
119
|
+
head?: OperationObject;
|
|
120
|
+
patch?: OperationObject;
|
|
121
|
+
trace?: OperationObject;
|
|
122
|
+
servers?: ServerObject[];
|
|
123
|
+
parameters?: ParameterObject[];
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export interface PathItemObjectWithRef {
|
|
127
|
+
$ref?: string;
|
|
128
|
+
summary?: string;
|
|
129
|
+
description?: string;
|
|
130
|
+
get?: OperationObjectWithRef;
|
|
131
|
+
put?: OperationObjectWithRef;
|
|
132
|
+
post?: OperationObjectWithRef;
|
|
133
|
+
delete?: OperationObjectWithRef;
|
|
134
|
+
options?: OperationObjectWithRef;
|
|
135
|
+
head?: OperationObjectWithRef;
|
|
136
|
+
patch?: OperationObjectWithRef;
|
|
137
|
+
trace?: OperationObjectWithRef;
|
|
138
|
+
servers?: ServerObject[];
|
|
139
|
+
parameters?: (ParameterObjectWithRef | ReferenceObject)[];
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export interface OperationObject {
|
|
143
|
+
tags?: string[];
|
|
144
|
+
summary?: string;
|
|
145
|
+
description?: string;
|
|
146
|
+
externalDocs?: ExternalDocumentationObject;
|
|
147
|
+
operationId?: string;
|
|
148
|
+
parameters?: ParameterObject[];
|
|
149
|
+
requestBody?: RequestBodyObject;
|
|
150
|
+
responses: ResponsesObject;
|
|
151
|
+
callbacks?: Record<string, CallbackObject>;
|
|
152
|
+
deprecated?: boolean;
|
|
153
|
+
security?: SecurityRequirementObject[];
|
|
154
|
+
servers?: ServerObject[];
|
|
155
|
+
// extensions
|
|
156
|
+
"x-position"?: number;
|
|
157
|
+
"x-deprecated-description"?: string;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export interface OperationObjectWithRef {
|
|
161
|
+
tags?: string[];
|
|
162
|
+
summary?: string;
|
|
163
|
+
description?: string;
|
|
164
|
+
externalDocs?: ExternalDocumentationObject;
|
|
165
|
+
operationId?: string;
|
|
166
|
+
parameters?: (ParameterObjectWithRef | ReferenceObject)[];
|
|
167
|
+
requestBody?: RequestBodyObjectWithRef | ReferenceObject;
|
|
168
|
+
responses: ResponsesObjectWithRef;
|
|
169
|
+
callbacks?: Record<string, CallbackObjectWithRef | ReferenceObject>;
|
|
170
|
+
deprecated?: boolean;
|
|
171
|
+
security?: SecurityRequirementObject[];
|
|
172
|
+
servers?: ServerObject[];
|
|
173
|
+
|
|
174
|
+
// extensions
|
|
175
|
+
"x-deprecated-description"?: string;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export interface ExternalDocumentationObject {
|
|
179
|
+
description?: string;
|
|
180
|
+
url: string;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export interface ParameterObject {
|
|
184
|
+
name: string;
|
|
185
|
+
in: "query" | "header" | "path" | "cookie";
|
|
186
|
+
description?: string;
|
|
187
|
+
required?: boolean;
|
|
188
|
+
deprecated?: boolean;
|
|
189
|
+
allowEmptyValue?: boolean;
|
|
190
|
+
//
|
|
191
|
+
style?: string;
|
|
192
|
+
explode?: string;
|
|
193
|
+
allowReserved?: boolean;
|
|
194
|
+
schema?: SchemaObject;
|
|
195
|
+
example?: any;
|
|
196
|
+
examples?: Record<string, ExampleObject>;
|
|
197
|
+
//
|
|
198
|
+
content?: Record<string, MediaTypeObject>;
|
|
199
|
+
param?: Object;
|
|
200
|
+
// ignoring stylings: matrix, label, form, simple, spaceDelimited,
|
|
201
|
+
// pipeDelimited and deepObject
|
|
202
|
+
"x-enumDescriptions"?: Record<string, string>;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export interface ParameterObjectWithRef {
|
|
206
|
+
name: string;
|
|
207
|
+
in: string;
|
|
208
|
+
description?: string;
|
|
209
|
+
required?: boolean;
|
|
210
|
+
deprecated?: boolean;
|
|
211
|
+
allowEmptyValue?: boolean;
|
|
212
|
+
//
|
|
213
|
+
style?: string;
|
|
214
|
+
explode?: string;
|
|
215
|
+
allowReserved?: boolean;
|
|
216
|
+
schema?: SchemaObjectWithRef | ReferenceObject;
|
|
217
|
+
example?: any;
|
|
218
|
+
examples?: Record<string, ExampleObject | ReferenceObject>;
|
|
219
|
+
//
|
|
220
|
+
content?: Record<string, MediaTypeObjectWithRef>;
|
|
221
|
+
// ignoring stylings: matrix, label, form, simple, spaceDelimited,
|
|
222
|
+
// pipeDelimited and deepObject
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
export interface RequestBodyObject {
|
|
226
|
+
description?: string;
|
|
227
|
+
content: Record<string, MediaTypeObject>;
|
|
228
|
+
required?: boolean;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
export interface RequestBodyObjectWithRef {
|
|
232
|
+
description?: string;
|
|
233
|
+
content: Record<string, MediaTypeObjectWithRef>;
|
|
234
|
+
required?: boolean;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export interface MediaTypeObject {
|
|
238
|
+
schema?: SchemaObject;
|
|
239
|
+
example?: any;
|
|
240
|
+
examples?: Record<string, ExampleObject>;
|
|
241
|
+
encoding?: Record<string, EncodingObject>;
|
|
242
|
+
type?: any;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
export interface MediaTypeObjectWithRef {
|
|
246
|
+
schema?: SchemaObjectWithRef | ReferenceObject;
|
|
247
|
+
example?: any;
|
|
248
|
+
examples?: Record<string, ExampleObject | ReferenceObject>;
|
|
249
|
+
encoding?: Record<string, EncodingObjectWithRef>;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export interface EncodingObject {
|
|
253
|
+
contentType?: string;
|
|
254
|
+
headers?: Record<string, HeaderObject>;
|
|
255
|
+
style?: string;
|
|
256
|
+
explode?: boolean;
|
|
257
|
+
allowReserved?: boolean;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
export interface EncodingObjectWithRef {
|
|
261
|
+
contentType?: string;
|
|
262
|
+
headers?: Record<string, HeaderObjectWithRef | ReferenceObject>;
|
|
263
|
+
style?: string;
|
|
264
|
+
explode?: boolean;
|
|
265
|
+
allowReserved?: boolean;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
export type ResponsesObject = Record<string, ResponseObject>;
|
|
269
|
+
|
|
270
|
+
export type ResponsesObjectWithRef = Record<
|
|
271
|
+
string,
|
|
272
|
+
ResponseObjectWithRef | ReferenceObject
|
|
273
|
+
>;
|
|
274
|
+
|
|
275
|
+
export interface ResponseObject {
|
|
276
|
+
description: string;
|
|
277
|
+
headers?: Record<string, HeaderObject>;
|
|
278
|
+
content?: Record<string, MediaTypeObject>;
|
|
279
|
+
links?: Record<string, LinkObject>;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
export interface ResponseObjectWithRef {
|
|
283
|
+
description: string;
|
|
284
|
+
headers?: Record<string, HeaderObjectWithRef | ReferenceObject>;
|
|
285
|
+
content?: Record<string, MediaTypeObjectWithRef>;
|
|
286
|
+
links?: Record<string, LinkObject | ReferenceObject>;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
export type CallbackObject = Record<string, PathItemObject>;
|
|
290
|
+
|
|
291
|
+
export type CallbackObjectWithRef = Record<string, PathItemObjectWithRef>;
|
|
292
|
+
|
|
293
|
+
export interface ExampleObject {
|
|
294
|
+
summary?: string;
|
|
295
|
+
description?: string;
|
|
296
|
+
value?: any;
|
|
297
|
+
externalValue?: string;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
export interface LinkObject {
|
|
301
|
+
operationRef?: string;
|
|
302
|
+
operationId?: string;
|
|
303
|
+
parameters?: Record<string, any>;
|
|
304
|
+
requestBody?: any;
|
|
305
|
+
description?: string;
|
|
306
|
+
server?: ServerObject;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
export type HeaderObject = Omit<ParameterObject, "name" | "in">;
|
|
310
|
+
|
|
311
|
+
export type HeaderObjectWithRef = Omit<ParameterObjectWithRef, "name" | "in">;
|
|
312
|
+
|
|
313
|
+
export interface TagObject {
|
|
314
|
+
name?: string;
|
|
315
|
+
description?: string;
|
|
316
|
+
externalDocs?: ExternalDocumentationObject;
|
|
317
|
+
"x-displayName"?: string;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
export interface TagGroupObject {
|
|
321
|
+
name: string;
|
|
322
|
+
tags: string[];
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
export interface ReferenceObject {
|
|
326
|
+
$ref: string;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
export type JSONSchema = JSONSchema4 | JSONSchema6 | JSONSchema7;
|
|
330
|
+
export type SchemaType = JSONSchema7TypeName;
|
|
331
|
+
export type SchemaObject = Omit<
|
|
332
|
+
JSONSchema,
|
|
333
|
+
| "type"
|
|
334
|
+
| "allOf"
|
|
335
|
+
| "oneOf"
|
|
336
|
+
| "anyOf"
|
|
337
|
+
| "not"
|
|
338
|
+
| "items"
|
|
339
|
+
| "properties"
|
|
340
|
+
| "additionalProperties"
|
|
341
|
+
> & {
|
|
342
|
+
// OpenAPI specific overrides
|
|
343
|
+
type?: SchemaType;
|
|
344
|
+
allOf?: SchemaObject[];
|
|
345
|
+
oneOf?: SchemaObject[];
|
|
346
|
+
anyOf?: SchemaObject[];
|
|
347
|
+
not?: SchemaObject;
|
|
348
|
+
items?: SchemaObject;
|
|
349
|
+
properties?: Record<string, SchemaObject>;
|
|
350
|
+
additionalProperties?: boolean | SchemaObject;
|
|
351
|
+
|
|
352
|
+
// OpenAPI additions
|
|
353
|
+
nullable?: boolean;
|
|
354
|
+
discriminator?: DiscriminatorObject;
|
|
355
|
+
readOnly?: boolean;
|
|
356
|
+
writeOnly?: boolean;
|
|
357
|
+
xml?: XMLObject;
|
|
358
|
+
externalDocs?: ExternalDocumentationObject;
|
|
359
|
+
example?: any;
|
|
360
|
+
deprecated?: boolean;
|
|
361
|
+
"x-tags"?: string[];
|
|
362
|
+
"x-enumDescriptions"?: Record<string, string>;
|
|
363
|
+
};
|
|
364
|
+
|
|
365
|
+
export type SchemaObjectWithRef = Omit<
|
|
366
|
+
JSONSchema,
|
|
367
|
+
| "type"
|
|
368
|
+
| "allOf"
|
|
369
|
+
| "oneOf"
|
|
370
|
+
| "anyOf"
|
|
371
|
+
| "not"
|
|
372
|
+
| "items"
|
|
373
|
+
| "properties"
|
|
374
|
+
| "additionalProperties"
|
|
375
|
+
> & {
|
|
376
|
+
// OpenAPI specific overrides
|
|
377
|
+
type?: SchemaType;
|
|
378
|
+
allOf?: (SchemaObject | ReferenceObject)[];
|
|
379
|
+
oneOf?: (SchemaObject | ReferenceObject)[];
|
|
380
|
+
anyOf?: (SchemaObject | ReferenceObject)[];
|
|
381
|
+
not?: SchemaObject | ReferenceObject;
|
|
382
|
+
items?: SchemaObject | ReferenceObject;
|
|
383
|
+
properties?: Record<string, SchemaObject | ReferenceObject>;
|
|
384
|
+
additionalProperties?: boolean | SchemaObject | ReferenceObject;
|
|
385
|
+
|
|
386
|
+
// OpenAPI additions
|
|
387
|
+
nullable?: boolean;
|
|
388
|
+
discriminator?: DiscriminatorObject;
|
|
389
|
+
readOnly?: boolean;
|
|
390
|
+
writeOnly?: boolean;
|
|
391
|
+
xml?: XMLObject;
|
|
392
|
+
externalDocs?: ExternalDocumentationObject;
|
|
393
|
+
example?: any;
|
|
394
|
+
deprecated?: boolean;
|
|
395
|
+
};
|
|
396
|
+
|
|
397
|
+
export interface DiscriminatorObject {
|
|
398
|
+
propertyName: string;
|
|
399
|
+
mapping?: Record<string, string>;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
export interface XMLObject {
|
|
403
|
+
name?: string;
|
|
404
|
+
namespace?: string;
|
|
405
|
+
prefix?: string;
|
|
406
|
+
attribute?: boolean;
|
|
407
|
+
wrapped?: boolean;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
export type SecuritySchemeObject =
|
|
411
|
+
| ApiKeySecuritySchemeObject
|
|
412
|
+
| HttpSecuritySchemeObject
|
|
413
|
+
| Oauth2SecuritySchemeObject
|
|
414
|
+
| OpenIdConnectSecuritySchemeObject;
|
|
415
|
+
|
|
416
|
+
export interface ApiKeySecuritySchemeObject {
|
|
417
|
+
type: "apiKey";
|
|
418
|
+
description?: string;
|
|
419
|
+
name: string;
|
|
420
|
+
in: "query" | "header" | "cookie";
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
export interface HttpSecuritySchemeObject {
|
|
424
|
+
type: "http";
|
|
425
|
+
description?: string;
|
|
426
|
+
scheme: string;
|
|
427
|
+
bearerFormat?: string;
|
|
428
|
+
name?: string;
|
|
429
|
+
in?: string;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
export interface Oauth2SecuritySchemeObject {
|
|
433
|
+
type: "oauth2";
|
|
434
|
+
description?: string;
|
|
435
|
+
flows: OAuthFlowsObject;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
export interface OpenIdConnectSecuritySchemeObject {
|
|
439
|
+
type: "openIdConnect";
|
|
440
|
+
description?: string;
|
|
441
|
+
openIdConnectUrl: string;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
export interface OAuthFlowsObject {
|
|
445
|
+
implicit?: OAuthFlowObject;
|
|
446
|
+
password?: OAuthFlowObject;
|
|
447
|
+
clientCredentials?: OAuthFlowObject;
|
|
448
|
+
authorizationCode?: OAuthFlowObject;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
export interface OAuthFlowObject {
|
|
452
|
+
authorizationUrl?: string; // required for some
|
|
453
|
+
tokenUrl?: string; // required for some
|
|
454
|
+
refreshUrl?: string;
|
|
455
|
+
scopes: Record<string, string>;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
export type SecurityRequirementObject = Record<string, string[]>;
|