docusaurus-plugin-openapi-docs 0.0.0-1000
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +361 -0
- package/lib/index.d.ts +9 -0
- package/lib/index.js +709 -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 +171 -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 +21 -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 +92 -0
- package/lib/markdown/schema.d.ts +3 -0
- package/lib/markdown/schema.js +154 -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 +191 -0
- package/lib/openapi/createResponseExample.d.ts +2 -0
- package/lib/openapi/createResponseExample.js +192 -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 +544 -0
- package/lib/openapi/openapi.test.d.ts +1 -0
- package/lib/openapi/openapi.test.js +33 -0
- package/lib/openapi/types.d.ts +354 -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 +306 -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/options.d.ts +2 -0
- package/lib/options.js +69 -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 +135 -0
- package/lib/types.js +8 -0
- package/package.json +69 -0
- package/src/index.ts +945 -0
- package/src/markdown/__snapshots__/createSchema.test.ts.snap +1605 -0
- package/src/markdown/createArrayBracket.ts +35 -0
- package/src/markdown/createAuthentication.ts +201 -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 +24 -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 +862 -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 +144 -0
- package/src/markdown/schema.test.ts +208 -0
- package/src/markdown/schema.ts +185 -0
- package/src/markdown/utils.ts +89 -0
- package/src/openapi/__fixtures__/examples/openapi.yaml +49 -0
- package/src/openapi/createRequestExample.ts +235 -0
- package/src/openapi/createResponseExample.ts +238 -0
- package/src/openapi/index.ts +8 -0
- package/src/openapi/openapi.test.ts +40 -0
- package/src/openapi/openapi.ts +697 -0
- package/src/openapi/types.ts +455 -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 +303 -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-to-postmanv2.d.ts +10 -0
- package/src/options.ts +77 -0
- package/src/plugin-content-docs-types.d.ts +42 -0
- package/src/plugin-openapi.d.ts +87 -0
- package/src/postman-collection.d.ts +10 -0
- package/src/sidebars/index.ts +322 -0
- package/src/sidebars/utils.ts +29 -0
- package/src/types.ts +176 -0
- package/tsconfig.json +7 -0
|
@@ -0,0 +1,913 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* ============================================================================
|
|
3
|
+
* Copyright (c) Palo Alto Networks
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
* ========================================================================== */
|
|
8
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
}) : (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
}));
|
|
19
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
20
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
21
|
+
}) : function(o, v) {
|
|
22
|
+
o["default"] = v;
|
|
23
|
+
});
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
const prettier = __importStar(require("prettier"));
|
|
43
|
+
const createSchema_1 = require("./createSchema");
|
|
44
|
+
describe("createNodes", () => {
|
|
45
|
+
describe("oneOf", () => {
|
|
46
|
+
it("should create readable MODs for oneOf primitive properties", async () => {
|
|
47
|
+
const schema = {
|
|
48
|
+
"x-tags": ["clown"],
|
|
49
|
+
type: "object",
|
|
50
|
+
properties: {
|
|
51
|
+
oneOfProperty: {
|
|
52
|
+
oneOf: [
|
|
53
|
+
{
|
|
54
|
+
type: "object",
|
|
55
|
+
properties: {
|
|
56
|
+
noseLength: {
|
|
57
|
+
type: "number",
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
required: ["noseLength"],
|
|
61
|
+
description: "Clown's nose length",
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
type: "array",
|
|
65
|
+
items: {
|
|
66
|
+
type: "string",
|
|
67
|
+
},
|
|
68
|
+
description: "Array of strings",
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
type: "boolean",
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
type: "number",
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
type: "string",
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
expect(await Promise.all((0, createSchema_1.createNodes)(schema, "request").map(async (md) => await prettier.format(md, { parser: "babel" })))).toMatchSnapshot();
|
|
84
|
+
});
|
|
85
|
+
it("should handle oneOf with different primitive types", async () => {
|
|
86
|
+
const schema = {
|
|
87
|
+
type: "object",
|
|
88
|
+
properties: {
|
|
89
|
+
oneOfProperty: {
|
|
90
|
+
oneOf: [
|
|
91
|
+
{ type: "string" },
|
|
92
|
+
{ type: "number" },
|
|
93
|
+
{ type: "boolean" },
|
|
94
|
+
],
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
expect(await Promise.all((0, createSchema_1.createNodes)(schema, "response").map(async (md) => await prettier.format(md, { parser: "babel" })))).toMatchSnapshot();
|
|
99
|
+
});
|
|
100
|
+
it("should handle oneOf with complex types", async () => {
|
|
101
|
+
const schema = {
|
|
102
|
+
type: "object",
|
|
103
|
+
properties: {
|
|
104
|
+
oneOfProperty: {
|
|
105
|
+
oneOf: [
|
|
106
|
+
{
|
|
107
|
+
type: "object",
|
|
108
|
+
properties: {
|
|
109
|
+
objectProp: { type: "string" },
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
type: "array",
|
|
114
|
+
items: { type: "number" },
|
|
115
|
+
},
|
|
116
|
+
],
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
expect(await Promise.all((0, createSchema_1.createNodes)(schema, "response").map(async (md) => await prettier.format(md, { parser: "babel" })))).toMatchSnapshot();
|
|
121
|
+
});
|
|
122
|
+
it("should handle nested oneOf clauses", async () => {
|
|
123
|
+
const schema = {
|
|
124
|
+
type: "object",
|
|
125
|
+
properties: {
|
|
126
|
+
oneOfProperty: {
|
|
127
|
+
oneOf: [
|
|
128
|
+
{
|
|
129
|
+
type: "object",
|
|
130
|
+
properties: {
|
|
131
|
+
nestedOneOfProp: {
|
|
132
|
+
oneOf: [{ type: "string" }, { type: "number" }],
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
{ type: "boolean" },
|
|
137
|
+
],
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
};
|
|
141
|
+
expect(await Promise.all((0, createSchema_1.createNodes)(schema, "response").map(async (md) => await prettier.format(md, { parser: "babel" })))).toMatchSnapshot();
|
|
142
|
+
});
|
|
143
|
+
// TypeError: Cannot read properties of undefined (reading 'length')
|
|
144
|
+
// eslint-disable-next-line jest/no-commented-out-tests
|
|
145
|
+
// it("should handle oneOf with discriminator", async () => {
|
|
146
|
+
// const schema: SchemaObject = {
|
|
147
|
+
// type: "object",
|
|
148
|
+
// discriminator: { propertyName: "type" },
|
|
149
|
+
// properties: {
|
|
150
|
+
// type: { type: "string" },
|
|
151
|
+
// },
|
|
152
|
+
// oneOf: [
|
|
153
|
+
// {
|
|
154
|
+
// type: "object",
|
|
155
|
+
// properties: {
|
|
156
|
+
// type: { type: "string", enum: ["typeA"] },
|
|
157
|
+
// propA: { type: "string" },
|
|
158
|
+
// },
|
|
159
|
+
// required: ["type"],
|
|
160
|
+
// },
|
|
161
|
+
// {
|
|
162
|
+
// type: "object",
|
|
163
|
+
// properties: {
|
|
164
|
+
// type: { type: "string", enum: ["typeB"] },
|
|
165
|
+
// propB: { type: "number" },
|
|
166
|
+
// },
|
|
167
|
+
// required: ["type"],
|
|
168
|
+
// },
|
|
169
|
+
// ],
|
|
170
|
+
// };
|
|
171
|
+
// expect(
|
|
172
|
+
// await Promise.all(
|
|
173
|
+
// createNodes(schema, "response").map(
|
|
174
|
+
// async (md: any) => await prettier.format(md, { parser: "babel" })
|
|
175
|
+
// )
|
|
176
|
+
// )
|
|
177
|
+
// ).toMatchSnapshot();
|
|
178
|
+
// });
|
|
179
|
+
it("should handle oneOf with shared properties", async () => {
|
|
180
|
+
const schema = {
|
|
181
|
+
type: "object",
|
|
182
|
+
properties: {
|
|
183
|
+
sharedProp: { type: "string" },
|
|
184
|
+
oneOfProperty: {
|
|
185
|
+
oneOf: [
|
|
186
|
+
{
|
|
187
|
+
type: "object",
|
|
188
|
+
properties: {
|
|
189
|
+
specificPropA: { type: "string" },
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
type: "object",
|
|
194
|
+
properties: {
|
|
195
|
+
specificPropB: { type: "number" },
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
],
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
};
|
|
202
|
+
expect(await Promise.all((0, createSchema_1.createNodes)(schema, "response").map(async (md) => await prettier.format(md, { parser: "babel" })))).toMatchSnapshot();
|
|
203
|
+
});
|
|
204
|
+
it("should handle oneOf with required properties", async () => {
|
|
205
|
+
const schema = {
|
|
206
|
+
type: "object",
|
|
207
|
+
properties: {
|
|
208
|
+
oneOfProperty: {
|
|
209
|
+
oneOf: [
|
|
210
|
+
{
|
|
211
|
+
type: "object",
|
|
212
|
+
properties: {
|
|
213
|
+
requiredPropA: { type: "string" },
|
|
214
|
+
},
|
|
215
|
+
required: ["requiredPropA"],
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
type: "object",
|
|
219
|
+
properties: {
|
|
220
|
+
requiredPropB: { type: "number" },
|
|
221
|
+
},
|
|
222
|
+
required: ["requiredPropB"],
|
|
223
|
+
},
|
|
224
|
+
],
|
|
225
|
+
},
|
|
226
|
+
},
|
|
227
|
+
};
|
|
228
|
+
expect(await Promise.all((0, createSchema_1.createNodes)(schema, "response").map(async (md) => await prettier.format(md, { parser: "babel" })))).toMatchSnapshot();
|
|
229
|
+
});
|
|
230
|
+
});
|
|
231
|
+
describe("anyOf", () => {
|
|
232
|
+
it("should render primitives within anyOf", async () => {
|
|
233
|
+
const schema = {
|
|
234
|
+
type: "object",
|
|
235
|
+
properties: {
|
|
236
|
+
oneOfProperty: {
|
|
237
|
+
anyOf: [
|
|
238
|
+
{
|
|
239
|
+
type: "integer",
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
type: "boolean",
|
|
243
|
+
},
|
|
244
|
+
],
|
|
245
|
+
title: "One of int or bool",
|
|
246
|
+
},
|
|
247
|
+
},
|
|
248
|
+
};
|
|
249
|
+
expect(await Promise.all((0, createSchema_1.createNodes)(schema, "response").map(async (md) => await prettier.format(md, { parser: "babel" })))).toMatchSnapshot();
|
|
250
|
+
});
|
|
251
|
+
it("should render oneOf within anyOf", async () => {
|
|
252
|
+
const schema = {
|
|
253
|
+
type: "object",
|
|
254
|
+
properties: {
|
|
255
|
+
oneOfProperty: {
|
|
256
|
+
anyOf: [
|
|
257
|
+
{
|
|
258
|
+
oneOf: [
|
|
259
|
+
{
|
|
260
|
+
type: "integer",
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
type: "boolean",
|
|
264
|
+
},
|
|
265
|
+
],
|
|
266
|
+
title: "An int or a bool",
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
type: "string",
|
|
270
|
+
},
|
|
271
|
+
],
|
|
272
|
+
title: "One of int or bool, or a string",
|
|
273
|
+
},
|
|
274
|
+
},
|
|
275
|
+
};
|
|
276
|
+
expect(await Promise.all((0, createSchema_1.createNodes)(schema, "response").map(async (md) => await prettier.format(md, { parser: "babel" })))).toMatchSnapshot();
|
|
277
|
+
});
|
|
278
|
+
});
|
|
279
|
+
describe("allOf", () => {
|
|
280
|
+
it("should render same-level properties with allOf", async () => {
|
|
281
|
+
const schema = {
|
|
282
|
+
allOf: [
|
|
283
|
+
{
|
|
284
|
+
type: "object",
|
|
285
|
+
properties: {
|
|
286
|
+
allOfProp1: {
|
|
287
|
+
type: "string",
|
|
288
|
+
},
|
|
289
|
+
allOfProp2: {
|
|
290
|
+
type: "string",
|
|
291
|
+
},
|
|
292
|
+
},
|
|
293
|
+
},
|
|
294
|
+
],
|
|
295
|
+
properties: {
|
|
296
|
+
parentProp1: {
|
|
297
|
+
type: "string",
|
|
298
|
+
},
|
|
299
|
+
parentProp2: {
|
|
300
|
+
type: "string",
|
|
301
|
+
},
|
|
302
|
+
},
|
|
303
|
+
};
|
|
304
|
+
expect(await Promise.all((0, createSchema_1.createNodes)(schema, "response").map(async (md) => await prettier.format(md, { parser: "babel" })))).toMatchSnapshot();
|
|
305
|
+
});
|
|
306
|
+
it("should correctly merge nested properties from multiple allOf schemas", async () => {
|
|
307
|
+
const schema = {
|
|
308
|
+
allOf: [
|
|
309
|
+
{
|
|
310
|
+
type: "object",
|
|
311
|
+
properties: {
|
|
312
|
+
outerProp1: {
|
|
313
|
+
type: "object",
|
|
314
|
+
properties: {
|
|
315
|
+
innerProp1: {
|
|
316
|
+
type: "string",
|
|
317
|
+
},
|
|
318
|
+
},
|
|
319
|
+
},
|
|
320
|
+
},
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
type: "object",
|
|
324
|
+
properties: {
|
|
325
|
+
outerProp2: {
|
|
326
|
+
type: "object",
|
|
327
|
+
properties: {
|
|
328
|
+
innerProp2: {
|
|
329
|
+
type: "number",
|
|
330
|
+
},
|
|
331
|
+
},
|
|
332
|
+
},
|
|
333
|
+
},
|
|
334
|
+
},
|
|
335
|
+
],
|
|
336
|
+
};
|
|
337
|
+
expect(await Promise.all((0, createSchema_1.createNodes)(schema, "response").map(async (md) => await prettier.format(md, { parser: "babel" })))).toMatchSnapshot();
|
|
338
|
+
});
|
|
339
|
+
it("should correctly handle shared required properties across allOf schemas", async () => {
|
|
340
|
+
const schema = {
|
|
341
|
+
allOf: [
|
|
342
|
+
{
|
|
343
|
+
type: "object",
|
|
344
|
+
properties: {
|
|
345
|
+
sharedProp: {
|
|
346
|
+
type: "string",
|
|
347
|
+
},
|
|
348
|
+
},
|
|
349
|
+
required: ["sharedProp"],
|
|
350
|
+
},
|
|
351
|
+
{
|
|
352
|
+
type: "object",
|
|
353
|
+
properties: {
|
|
354
|
+
anotherProp: {
|
|
355
|
+
type: "number",
|
|
356
|
+
},
|
|
357
|
+
},
|
|
358
|
+
required: ["anotherProp"],
|
|
359
|
+
},
|
|
360
|
+
],
|
|
361
|
+
};
|
|
362
|
+
expect(await Promise.all((0, createSchema_1.createNodes)(schema, "response").map(async (md) => await prettier.format(md, { parser: "babel" })))).toMatchSnapshot();
|
|
363
|
+
});
|
|
364
|
+
// Could not resolve values for path:"properties.conflictingProp.type". They are probably incompatible. Values:
|
|
365
|
+
// "string"
|
|
366
|
+
// "number"
|
|
367
|
+
// eslint-disable-next-line jest/no-commented-out-tests
|
|
368
|
+
// it("should handle conflicting properties in allOf schemas", async () => {
|
|
369
|
+
// const schema: SchemaObject = {
|
|
370
|
+
// allOf: [
|
|
371
|
+
// {
|
|
372
|
+
// type: "object",
|
|
373
|
+
// properties: {
|
|
374
|
+
// conflictingProp: {
|
|
375
|
+
// type: "string",
|
|
376
|
+
// },
|
|
377
|
+
// },
|
|
378
|
+
// },
|
|
379
|
+
// {
|
|
380
|
+
// type: "object",
|
|
381
|
+
// properties: {
|
|
382
|
+
// conflictingProp: {
|
|
383
|
+
// type: "number",
|
|
384
|
+
// },
|
|
385
|
+
// },
|
|
386
|
+
// },
|
|
387
|
+
// ],
|
|
388
|
+
// };
|
|
389
|
+
// expect(
|
|
390
|
+
// await Promise.all(
|
|
391
|
+
// createNodes(schema, "response").map(
|
|
392
|
+
// async (md: any) => await prettier.format(md, { parser: "babel" })
|
|
393
|
+
// )
|
|
394
|
+
// )
|
|
395
|
+
// ).toMatchSnapshot();
|
|
396
|
+
// });
|
|
397
|
+
// Could not resolve values for path:"type". They are probably incompatible. Values:
|
|
398
|
+
// "object"
|
|
399
|
+
// "array"
|
|
400
|
+
// eslint-disable-next-line jest/no-commented-out-tests
|
|
401
|
+
// it("should handle mixed data types in allOf schemas", async () => {
|
|
402
|
+
// const schema: SchemaObject = {
|
|
403
|
+
// allOf: [
|
|
404
|
+
// {
|
|
405
|
+
// type: "object",
|
|
406
|
+
// properties: {
|
|
407
|
+
// mixedTypeProp1: {
|
|
408
|
+
// type: "string",
|
|
409
|
+
// },
|
|
410
|
+
// },
|
|
411
|
+
// },
|
|
412
|
+
// {
|
|
413
|
+
// type: "array",
|
|
414
|
+
// items: {
|
|
415
|
+
// type: "number",
|
|
416
|
+
// },
|
|
417
|
+
// },
|
|
418
|
+
// ],
|
|
419
|
+
// };
|
|
420
|
+
// expect(
|
|
421
|
+
// await Promise.all(
|
|
422
|
+
// createNodes(schema, "response").map(
|
|
423
|
+
// async (md: any) => await prettier.format(md, { parser: "babel" })
|
|
424
|
+
// )
|
|
425
|
+
// )
|
|
426
|
+
// ).toMatchSnapshot();
|
|
427
|
+
// });
|
|
428
|
+
it("should correctly deep merge properties in allOf schemas", async () => {
|
|
429
|
+
const schema = {
|
|
430
|
+
allOf: [
|
|
431
|
+
{
|
|
432
|
+
type: "object",
|
|
433
|
+
properties: {
|
|
434
|
+
deepProp: {
|
|
435
|
+
type: "object",
|
|
436
|
+
properties: {
|
|
437
|
+
innerProp1: {
|
|
438
|
+
type: "string",
|
|
439
|
+
},
|
|
440
|
+
},
|
|
441
|
+
},
|
|
442
|
+
},
|
|
443
|
+
},
|
|
444
|
+
{
|
|
445
|
+
type: "object",
|
|
446
|
+
properties: {
|
|
447
|
+
deepProp: {
|
|
448
|
+
type: "object",
|
|
449
|
+
properties: {
|
|
450
|
+
innerProp2: {
|
|
451
|
+
type: "number",
|
|
452
|
+
},
|
|
453
|
+
},
|
|
454
|
+
},
|
|
455
|
+
},
|
|
456
|
+
},
|
|
457
|
+
],
|
|
458
|
+
};
|
|
459
|
+
expect(await Promise.all((0, createSchema_1.createNodes)(schema, "response").map(async (md) => await prettier.format(md, { parser: "babel" })))).toMatchSnapshot();
|
|
460
|
+
});
|
|
461
|
+
// eslint-disable-next-line jest/no-commented-out-tests
|
|
462
|
+
// it("should handle discriminator with allOf schemas", async () => {
|
|
463
|
+
// const schema: SchemaObject = {
|
|
464
|
+
// allOf: [
|
|
465
|
+
// {
|
|
466
|
+
// type: "object",
|
|
467
|
+
// discriminator: {
|
|
468
|
+
// propertyName: "type",
|
|
469
|
+
// },
|
|
470
|
+
// properties: {
|
|
471
|
+
// type: {
|
|
472
|
+
// type: "string",
|
|
473
|
+
// },
|
|
474
|
+
// },
|
|
475
|
+
// },
|
|
476
|
+
// {
|
|
477
|
+
// type: "object",
|
|
478
|
+
// properties: {
|
|
479
|
+
// specificProp: {
|
|
480
|
+
// type: "string",
|
|
481
|
+
// },
|
|
482
|
+
// },
|
|
483
|
+
// },
|
|
484
|
+
// ],
|
|
485
|
+
// };
|
|
486
|
+
// expect(
|
|
487
|
+
// await Promise.all(
|
|
488
|
+
// createNodes(schema, "response").map(
|
|
489
|
+
// async (md: any) => await prettier.format(md, { parser: "babel" })
|
|
490
|
+
// )
|
|
491
|
+
// )
|
|
492
|
+
// ).toMatchSnapshot();
|
|
493
|
+
// });
|
|
494
|
+
});
|
|
495
|
+
describe("discriminator", () => {
|
|
496
|
+
it("should handle basic discriminator with oneOf", async () => {
|
|
497
|
+
const schema = {
|
|
498
|
+
type: "object",
|
|
499
|
+
discriminator: { propertyName: "type" },
|
|
500
|
+
properties: {
|
|
501
|
+
type: { type: "string" },
|
|
502
|
+
},
|
|
503
|
+
oneOf: [
|
|
504
|
+
{
|
|
505
|
+
type: "object",
|
|
506
|
+
properties: {
|
|
507
|
+
type: { type: "string", enum: ["typeA"] },
|
|
508
|
+
propA: { type: "string" },
|
|
509
|
+
},
|
|
510
|
+
required: ["type"],
|
|
511
|
+
},
|
|
512
|
+
{
|
|
513
|
+
type: "object",
|
|
514
|
+
properties: {
|
|
515
|
+
type: { type: "string", enum: ["typeB"] },
|
|
516
|
+
propB: { type: "number" },
|
|
517
|
+
},
|
|
518
|
+
required: ["type"],
|
|
519
|
+
},
|
|
520
|
+
],
|
|
521
|
+
};
|
|
522
|
+
expect(await Promise.all((0, createSchema_1.createNodes)(schema, "response").map(async (md) => await prettier.format(md, { parser: "babel" })))).toMatchSnapshot();
|
|
523
|
+
});
|
|
524
|
+
it("should handle discriminator with shared properties", async () => {
|
|
525
|
+
const schema = {
|
|
526
|
+
type: "object",
|
|
527
|
+
discriminator: { propertyName: "type" },
|
|
528
|
+
properties: {
|
|
529
|
+
type: { type: "string" },
|
|
530
|
+
sharedProp: { type: "string" },
|
|
531
|
+
},
|
|
532
|
+
oneOf: [
|
|
533
|
+
{
|
|
534
|
+
type: "object",
|
|
535
|
+
properties: {
|
|
536
|
+
type: { type: "string", enum: ["typeA"] },
|
|
537
|
+
propA: { type: "string" },
|
|
538
|
+
},
|
|
539
|
+
required: ["type"],
|
|
540
|
+
},
|
|
541
|
+
{
|
|
542
|
+
type: "object",
|
|
543
|
+
properties: {
|
|
544
|
+
type: { type: "string", enum: ["typeB"] },
|
|
545
|
+
propB: { type: "number" },
|
|
546
|
+
},
|
|
547
|
+
required: ["type"],
|
|
548
|
+
},
|
|
549
|
+
],
|
|
550
|
+
};
|
|
551
|
+
expect(await Promise.all((0, createSchema_1.createNodes)(schema, "response").map(async (md) => await prettier.format(md, { parser: "babel" })))).toMatchSnapshot();
|
|
552
|
+
});
|
|
553
|
+
it("should handle discriminator with nested schemas", async () => {
|
|
554
|
+
const schema = {
|
|
555
|
+
type: "object",
|
|
556
|
+
discriminator: { propertyName: "type" },
|
|
557
|
+
properties: {
|
|
558
|
+
type: { type: "string" },
|
|
559
|
+
},
|
|
560
|
+
oneOf: [
|
|
561
|
+
{
|
|
562
|
+
type: "object",
|
|
563
|
+
properties: {
|
|
564
|
+
type: { type: "string", enum: ["typeA"] },
|
|
565
|
+
nestedA: {
|
|
566
|
+
type: "object",
|
|
567
|
+
properties: {
|
|
568
|
+
propA1: { type: "string" },
|
|
569
|
+
propA2: { type: "number" },
|
|
570
|
+
},
|
|
571
|
+
},
|
|
572
|
+
},
|
|
573
|
+
required: ["type"],
|
|
574
|
+
},
|
|
575
|
+
{
|
|
576
|
+
type: "object",
|
|
577
|
+
properties: {
|
|
578
|
+
type: { type: "string", enum: ["typeB"] },
|
|
579
|
+
nestedB: {
|
|
580
|
+
type: "object",
|
|
581
|
+
properties: {
|
|
582
|
+
propB1: { type: "string" },
|
|
583
|
+
propB2: { type: "boolean" },
|
|
584
|
+
},
|
|
585
|
+
},
|
|
586
|
+
},
|
|
587
|
+
required: ["type"],
|
|
588
|
+
},
|
|
589
|
+
],
|
|
590
|
+
};
|
|
591
|
+
expect(await Promise.all((0, createSchema_1.createNodes)(schema, "response").map(async (md) => await prettier.format(md, { parser: "babel" })))).toMatchSnapshot();
|
|
592
|
+
});
|
|
593
|
+
it("should handle discriminator with additional properties", async () => {
|
|
594
|
+
const schema = {
|
|
595
|
+
type: "object",
|
|
596
|
+
discriminator: { propertyName: "type" },
|
|
597
|
+
properties: {
|
|
598
|
+
type: { type: "string" },
|
|
599
|
+
},
|
|
600
|
+
oneOf: [
|
|
601
|
+
{
|
|
602
|
+
type: "object",
|
|
603
|
+
properties: {
|
|
604
|
+
type: { type: "string", enum: ["typeA"] },
|
|
605
|
+
propA: { type: "string" },
|
|
606
|
+
},
|
|
607
|
+
additionalProperties: false,
|
|
608
|
+
required: ["type"],
|
|
609
|
+
},
|
|
610
|
+
{
|
|
611
|
+
type: "object",
|
|
612
|
+
properties: {
|
|
613
|
+
type: { type: "string", enum: ["typeB"] },
|
|
614
|
+
propB: { type: "number" },
|
|
615
|
+
},
|
|
616
|
+
additionalProperties: true,
|
|
617
|
+
required: ["type"],
|
|
618
|
+
},
|
|
619
|
+
],
|
|
620
|
+
};
|
|
621
|
+
expect(await Promise.all((0, createSchema_1.createNodes)(schema, "response").map(async (md) => await prettier.format(md, { parser: "babel" })))).toMatchSnapshot();
|
|
622
|
+
});
|
|
623
|
+
it("should handle discriminator with allOf", async () => {
|
|
624
|
+
const schema = {
|
|
625
|
+
type: "object",
|
|
626
|
+
discriminator: { propertyName: "type" },
|
|
627
|
+
properties: {
|
|
628
|
+
type: { type: "string" },
|
|
629
|
+
},
|
|
630
|
+
allOf: [
|
|
631
|
+
{
|
|
632
|
+
oneOf: [
|
|
633
|
+
{
|
|
634
|
+
type: "object",
|
|
635
|
+
properties: {
|
|
636
|
+
type: { type: "string", enum: ["typeA"] },
|
|
637
|
+
propA: { type: "string" },
|
|
638
|
+
},
|
|
639
|
+
required: ["type"],
|
|
640
|
+
},
|
|
641
|
+
{
|
|
642
|
+
type: "object",
|
|
643
|
+
properties: {
|
|
644
|
+
type: { type: "string", enum: ["typeB"] },
|
|
645
|
+
propB: { type: "number" },
|
|
646
|
+
},
|
|
647
|
+
required: ["type"],
|
|
648
|
+
},
|
|
649
|
+
],
|
|
650
|
+
},
|
|
651
|
+
{
|
|
652
|
+
type: "object",
|
|
653
|
+
properties: {
|
|
654
|
+
sharedProp: { type: "string" },
|
|
655
|
+
},
|
|
656
|
+
},
|
|
657
|
+
],
|
|
658
|
+
};
|
|
659
|
+
expect(await Promise.all((0, createSchema_1.createNodes)(schema, "response").map(async (md) => await prettier.format(md, { parser: "babel" })))).toMatchSnapshot();
|
|
660
|
+
});
|
|
661
|
+
it("should handle discriminator with required properties", async () => {
|
|
662
|
+
const schema = {
|
|
663
|
+
type: "object",
|
|
664
|
+
discriminator: { propertyName: "type" },
|
|
665
|
+
properties: {
|
|
666
|
+
type: { type: "string" },
|
|
667
|
+
},
|
|
668
|
+
oneOf: [
|
|
669
|
+
{
|
|
670
|
+
type: "object",
|
|
671
|
+
properties: {
|
|
672
|
+
type: { type: "string", enum: ["typeA"] },
|
|
673
|
+
propA: { type: "string" },
|
|
674
|
+
},
|
|
675
|
+
required: ["type", "propA"],
|
|
676
|
+
},
|
|
677
|
+
{
|
|
678
|
+
type: "object",
|
|
679
|
+
properties: {
|
|
680
|
+
type: { type: "string", enum: ["typeB"] },
|
|
681
|
+
propB: { type: "number" },
|
|
682
|
+
},
|
|
683
|
+
required: ["type", "propB"],
|
|
684
|
+
},
|
|
685
|
+
],
|
|
686
|
+
};
|
|
687
|
+
expect(await Promise.all((0, createSchema_1.createNodes)(schema, "response").map(async (md) => await prettier.format(md, { parser: "babel" })))).toMatchSnapshot();
|
|
688
|
+
});
|
|
689
|
+
it("should handle basic discriminator with mapping", async () => {
|
|
690
|
+
const schema = {
|
|
691
|
+
type: "object",
|
|
692
|
+
discriminator: {
|
|
693
|
+
propertyName: "type",
|
|
694
|
+
mapping: {
|
|
695
|
+
typeA: "#/definitions/TypeA",
|
|
696
|
+
typeB: "#/definitions/TypeB",
|
|
697
|
+
},
|
|
698
|
+
},
|
|
699
|
+
properties: {
|
|
700
|
+
type: { type: "string" },
|
|
701
|
+
},
|
|
702
|
+
oneOf: [
|
|
703
|
+
{
|
|
704
|
+
type: "object",
|
|
705
|
+
properties: {
|
|
706
|
+
type: { type: "string", enum: ["typeA"] },
|
|
707
|
+
propA: { type: "string" },
|
|
708
|
+
},
|
|
709
|
+
required: ["type"],
|
|
710
|
+
},
|
|
711
|
+
{
|
|
712
|
+
type: "object",
|
|
713
|
+
properties: {
|
|
714
|
+
type: { type: "string", enum: ["typeB"] },
|
|
715
|
+
propB: { type: "number" },
|
|
716
|
+
},
|
|
717
|
+
required: ["type"],
|
|
718
|
+
},
|
|
719
|
+
],
|
|
720
|
+
};
|
|
721
|
+
expect(await Promise.all((0, createSchema_1.createNodes)(schema, "response").map(async (md) => await prettier.format(md, { parser: "babel" })))).toMatchSnapshot();
|
|
722
|
+
});
|
|
723
|
+
it("should handle discriminator with shared properties and mapping", async () => {
|
|
724
|
+
const schema = {
|
|
725
|
+
type: "object",
|
|
726
|
+
discriminator: {
|
|
727
|
+
propertyName: "type",
|
|
728
|
+
mapping: {
|
|
729
|
+
typeA: "#/definitions/TypeA",
|
|
730
|
+
typeB: "#/definitions/TypeB",
|
|
731
|
+
},
|
|
732
|
+
},
|
|
733
|
+
properties: {
|
|
734
|
+
type: { type: "string" },
|
|
735
|
+
sharedProp: { type: "string" },
|
|
736
|
+
},
|
|
737
|
+
oneOf: [
|
|
738
|
+
{
|
|
739
|
+
type: "object",
|
|
740
|
+
properties: {
|
|
741
|
+
type: { type: "string", enum: ["typeA"] },
|
|
742
|
+
propA: { type: "string" },
|
|
743
|
+
},
|
|
744
|
+
required: ["type"],
|
|
745
|
+
},
|
|
746
|
+
{
|
|
747
|
+
type: "object",
|
|
748
|
+
properties: {
|
|
749
|
+
type: { type: "string", enum: ["typeB"] },
|
|
750
|
+
propB: { type: "number" },
|
|
751
|
+
},
|
|
752
|
+
required: ["type"],
|
|
753
|
+
},
|
|
754
|
+
],
|
|
755
|
+
};
|
|
756
|
+
expect(await Promise.all((0, createSchema_1.createNodes)(schema, "response").map(async (md) => await prettier.format(md, { parser: "babel" })))).toMatchSnapshot();
|
|
757
|
+
});
|
|
758
|
+
it("should handle discriminator with allOf and mapping", async () => {
|
|
759
|
+
const schema = {
|
|
760
|
+
type: "object",
|
|
761
|
+
discriminator: {
|
|
762
|
+
propertyName: "type",
|
|
763
|
+
mapping: {
|
|
764
|
+
typeA: "#/definitions/TypeA",
|
|
765
|
+
typeB: "#/definitions/TypeB",
|
|
766
|
+
},
|
|
767
|
+
},
|
|
768
|
+
properties: {
|
|
769
|
+
type: { type: "string" },
|
|
770
|
+
},
|
|
771
|
+
allOf: [
|
|
772
|
+
{
|
|
773
|
+
oneOf: [
|
|
774
|
+
{
|
|
775
|
+
type: "object",
|
|
776
|
+
properties: {
|
|
777
|
+
type: { type: "string", enum: ["typeA"] },
|
|
778
|
+
propA: { type: "string" },
|
|
779
|
+
},
|
|
780
|
+
required: ["type"],
|
|
781
|
+
},
|
|
782
|
+
{
|
|
783
|
+
type: "object",
|
|
784
|
+
properties: {
|
|
785
|
+
type: { type: "string", enum: ["typeB"] },
|
|
786
|
+
propB: { type: "number" },
|
|
787
|
+
},
|
|
788
|
+
required: ["type"],
|
|
789
|
+
},
|
|
790
|
+
],
|
|
791
|
+
},
|
|
792
|
+
{
|
|
793
|
+
type: "object",
|
|
794
|
+
properties: {
|
|
795
|
+
sharedProp: { type: "string" },
|
|
796
|
+
},
|
|
797
|
+
},
|
|
798
|
+
],
|
|
799
|
+
};
|
|
800
|
+
expect(await Promise.all((0, createSchema_1.createNodes)(schema, "response").map(async (md) => await prettier.format(md, { parser: "babel" })))).toMatchSnapshot();
|
|
801
|
+
});
|
|
802
|
+
it("should handle discriminator with required properties and mapping", async () => {
|
|
803
|
+
const schema = {
|
|
804
|
+
type: "object",
|
|
805
|
+
discriminator: {
|
|
806
|
+
propertyName: "type",
|
|
807
|
+
mapping: {
|
|
808
|
+
typeA: "#/definitions/TypeA",
|
|
809
|
+
typeB: "#/definitions/TypeB",
|
|
810
|
+
},
|
|
811
|
+
},
|
|
812
|
+
properties: {
|
|
813
|
+
type: { type: "string" },
|
|
814
|
+
},
|
|
815
|
+
oneOf: [
|
|
816
|
+
{
|
|
817
|
+
type: "object",
|
|
818
|
+
properties: {
|
|
819
|
+
type: { type: "string", enum: ["typeA"] },
|
|
820
|
+
propA: { type: "string" },
|
|
821
|
+
},
|
|
822
|
+
required: ["type", "propA"],
|
|
823
|
+
},
|
|
824
|
+
{
|
|
825
|
+
type: "object",
|
|
826
|
+
properties: {
|
|
827
|
+
type: { type: "string", enum: ["typeB"] },
|
|
828
|
+
propB: { type: "number" },
|
|
829
|
+
},
|
|
830
|
+
required: ["type", "propB"],
|
|
831
|
+
},
|
|
832
|
+
],
|
|
833
|
+
};
|
|
834
|
+
expect(await Promise.all((0, createSchema_1.createNodes)(schema, "response").map(async (md) => await prettier.format(md, { parser: "babel" })))).toMatchSnapshot();
|
|
835
|
+
});
|
|
836
|
+
});
|
|
837
|
+
describe("additionalProperties", () => {
|
|
838
|
+
it.each([
|
|
839
|
+
[
|
|
840
|
+
{
|
|
841
|
+
allOf: [
|
|
842
|
+
{
|
|
843
|
+
oneOf: [
|
|
844
|
+
{
|
|
845
|
+
type: "object",
|
|
846
|
+
properties: {
|
|
847
|
+
type: {
|
|
848
|
+
type: "string",
|
|
849
|
+
enum: ["nose"],
|
|
850
|
+
},
|
|
851
|
+
},
|
|
852
|
+
required: ["type"],
|
|
853
|
+
},
|
|
854
|
+
{
|
|
855
|
+
type: "object",
|
|
856
|
+
properties: {
|
|
857
|
+
type: {
|
|
858
|
+
type: "string",
|
|
859
|
+
enum: ["mouth"],
|
|
860
|
+
},
|
|
861
|
+
},
|
|
862
|
+
required: ["type"],
|
|
863
|
+
},
|
|
864
|
+
{
|
|
865
|
+
type: "object",
|
|
866
|
+
properties: {
|
|
867
|
+
type: {
|
|
868
|
+
type: "string",
|
|
869
|
+
enum: ["eyes"],
|
|
870
|
+
},
|
|
871
|
+
default: {
|
|
872
|
+
type: "string",
|
|
873
|
+
},
|
|
874
|
+
},
|
|
875
|
+
required: ["type"],
|
|
876
|
+
},
|
|
877
|
+
],
|
|
878
|
+
},
|
|
879
|
+
{
|
|
880
|
+
type: "object",
|
|
881
|
+
properties: {
|
|
882
|
+
description: {
|
|
883
|
+
type: "string",
|
|
884
|
+
description: "Description of the body part.",
|
|
885
|
+
},
|
|
886
|
+
},
|
|
887
|
+
required: ["description"],
|
|
888
|
+
},
|
|
889
|
+
],
|
|
890
|
+
},
|
|
891
|
+
],
|
|
892
|
+
[
|
|
893
|
+
{
|
|
894
|
+
type: "array",
|
|
895
|
+
items: { type: "object", properties: { a: "string", b: "number" } },
|
|
896
|
+
},
|
|
897
|
+
],
|
|
898
|
+
[{ type: "string" }],
|
|
899
|
+
[{ type: "number" }],
|
|
900
|
+
[{ type: "integer" }],
|
|
901
|
+
[{ type: "boolean" }],
|
|
902
|
+
[false],
|
|
903
|
+
[true],
|
|
904
|
+
[{}],
|
|
905
|
+
])("should handle additionalProperties: %p", async (additionalProperties) => {
|
|
906
|
+
const schema = {
|
|
907
|
+
type: "object",
|
|
908
|
+
additionalProperties,
|
|
909
|
+
};
|
|
910
|
+
expect(await Promise.all((0, createSchema_1.createNodes)(schema, "request").map(async (md) => await prettier.format(md, { parser: "babel" })))).toMatchSnapshot();
|
|
911
|
+
});
|
|
912
|
+
});
|
|
913
|
+
});
|