@scalar/openapi-parser 0.12.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +134 -0
  3. package/dist/configuration/index.d.ts +2 -2
  4. package/dist/configuration/index.js +2 -2
  5. package/dist/configuration/index.js.map +1 -1
  6. package/dist/index.d.ts +1 -0
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +4 -0
  9. package/dist/index.js.map +2 -2
  10. package/dist/types/index.d.ts +1 -0
  11. package/dist/types/index.d.ts.map +1 -1
  12. package/dist/utils/bundle/bundle.d.ts +193 -0
  13. package/dist/utils/bundle/bundle.d.ts.map +1 -0
  14. package/dist/utils/bundle/bundle.js +197 -0
  15. package/dist/utils/bundle/bundle.js.map +7 -0
  16. package/dist/utils/bundle/create-limiter.d.ts +21 -0
  17. package/dist/utils/bundle/create-limiter.d.ts.map +1 -0
  18. package/dist/utils/bundle/create-limiter.js +31 -0
  19. package/dist/utils/bundle/create-limiter.js.map +7 -0
  20. package/dist/utils/bundle/index.d.ts +4 -0
  21. package/dist/utils/bundle/index.d.ts.map +1 -0
  22. package/dist/utils/bundle/index.js +9 -0
  23. package/dist/utils/bundle/index.js.map +7 -0
  24. package/dist/utils/bundle/plugins/fetch-urls.d.ts +38 -0
  25. package/dist/utils/bundle/plugins/fetch-urls.d.ts.map +1 -0
  26. package/dist/utils/bundle/plugins/fetch-urls.js +40 -0
  27. package/dist/utils/bundle/plugins/fetch-urls.js.map +7 -0
  28. package/dist/utils/bundle/plugins/read-files.d.ts +29 -0
  29. package/dist/utils/bundle/plugins/read-files.d.ts.map +1 -0
  30. package/dist/utils/bundle/plugins/read-files.js +30 -0
  31. package/dist/utils/bundle/plugins/read-files.js.map +7 -0
  32. package/dist/utils/details.d.ts +1 -2
  33. package/dist/utils/details.d.ts.map +1 -1
  34. package/dist/utils/details.js +12 -9
  35. package/dist/utils/details.js.map +2 -2
  36. package/dist/utils/normalize.d.ts +1 -1
  37. package/dist/utils/normalize.d.ts.map +1 -1
  38. package/dist/utils/normalize.js +16 -11
  39. package/dist/utils/normalize.js.map +2 -2
  40. package/dist/utils/resolve-references.d.ts.map +1 -1
  41. package/dist/utils/resolve-references.js +11 -0
  42. package/dist/utils/resolve-references.js.map +2 -2
  43. package/package.json +5 -5
  44. package/dist/lib/Validator/Validator.test.js +0 -8
  45. package/dist/lib/Validator/Validator.test.js.map +0 -7
  46. package/dist/plugins/fetch-urls/fetch-urls.test.js +0 -50
  47. package/dist/plugins/fetch-urls/fetch-urls.test.js.map +0 -7
  48. package/dist/plugins/read-files/read-files.test.js +0 -20
  49. package/dist/plugins/read-files/read-files.test.js.map +0 -7
  50. package/dist/utils/dereference.test.js +0 -300
  51. package/dist/utils/dereference.test.js.map +0 -7
  52. package/dist/utils/errors.test.js +0 -48
  53. package/dist/utils/errors.test.js.map +0 -7
  54. package/dist/utils/escape-json-pointer.test.js +0 -11
  55. package/dist/utils/escape-json-pointer.test.js.map +0 -7
  56. package/dist/utils/get-entrypoint.test.js +0 -18
  57. package/dist/utils/get-entrypoint.test.js.map +0 -7
  58. package/dist/utils/get-segments-from-path.test.js +0 -13
  59. package/dist/utils/get-segments-from-path.test.js.map +0 -7
  60. package/dist/utils/is-filesystem.test.js +0 -15
  61. package/dist/utils/is-filesystem.test.js.map +0 -7
  62. package/dist/utils/is-object.test.js +0 -23
  63. package/dist/utils/is-object.test.js.map +0 -7
  64. package/dist/utils/load/load.test.js +0 -361
  65. package/dist/utils/load/load.test.js.map +0 -7
  66. package/dist/utils/normalize.test.js +0 -88
  67. package/dist/utils/normalize.test.js.map +0 -7
  68. package/dist/utils/resolve-references.test.js +0 -567
  69. package/dist/utils/resolve-references.test.js.map +0 -7
  70. package/dist/utils/transform/sanitize.test.js +0 -148
  71. package/dist/utils/transform/sanitize.test.js.map +0 -7
  72. package/dist/utils/transform-errors.test.js +0 -17
  73. package/dist/utils/transform-errors.test.js.map +0 -7
  74. package/dist/utils/traverse.test.js +0 -68
  75. package/dist/utils/traverse.test.js.map +0 -7
  76. package/dist/utils/unescape-json-pointer.test.js +0 -19
  77. package/dist/utils/unescape-json-pointer.test.js.map +0 -7
  78. package/dist/utils/upgrade-from-three-to-three-one.test.js +0 -462
  79. package/dist/utils/upgrade-from-three-to-three-one.test.js.map +0 -7
  80. package/dist/utils/upgrade-from-two-to-three.test.js +0 -589
  81. package/dist/utils/upgrade-from-two-to-three.test.js.map +0 -7
  82. package/dist/utils/upgrade.test.js +0 -57
  83. package/dist/utils/upgrade.test.js.map +0 -7
  84. package/dist/utils/validate.test.js +0 -64
  85. package/dist/utils/validate.test.js.map +0 -7
@@ -1,462 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { isSchemaPath, upgradeFromThreeToThreeOne } from "./upgrade-from-three-to-three-one.js";
3
- describe("isSchemaPath", () => {
4
- it("correctly identifies schema paths", () => {
5
- expect(isSchemaPath(["components", "schemas", "User"])).toBe(true);
6
- expect(isSchemaPath(["paths", "/users", "get", "responses", "200", "content", "application/json", "schema"])).toBe(
7
- true
8
- );
9
- expect(isSchemaPath(["paths", "/users", "post", "requestBody", "content", "application/json", "schema"])).toBe(true);
10
- expect(isSchemaPath(["components", "schemas", "User", "properties", "address"])).toBe(true);
11
- expect(isSchemaPath(["components", "schemas", "User", "allOf", "0"])).toBe(true);
12
- expect(isSchemaPath(["paths", "/users", "get", "parameters", "0", "schema"])).toBe(true);
13
- });
14
- it("correctly identifies non-schema paths", () => {
15
- expect(isSchemaPath(["info"])).toBe(false);
16
- expect(isSchemaPath(["paths", "/users", "get", "summary"])).toBe(false);
17
- expect(isSchemaPath(["components", "parameters", "userId"])).toBe(false);
18
- });
19
- });
20
- describe("upgradeFromThreeToThreeOne", () => {
21
- describe("version", () => {
22
- it("doesn\u2019t modify Swagger 2.0 files", async () => {
23
- const result = upgradeFromThreeToThreeOne({
24
- swagger: "2.0",
25
- info: {
26
- title: "Hello World",
27
- version: "1.0.0"
28
- },
29
- paths: {}
30
- });
31
- expect(result.swagger).toBe("2.0");
32
- });
33
- it("changes the version to from 3.0.0 to 3.1.1", async () => {
34
- const result = upgradeFromThreeToThreeOne({
35
- openapi: "3.0.0",
36
- info: {
37
- title: "Hello World",
38
- version: "1.0.0"
39
- },
40
- paths: {}
41
- });
42
- expect(result.openapi).toBe("3.1.1");
43
- });
44
- it("changes the version to 3.0.3 to 3.1.1", async () => {
45
- const result = upgradeFromThreeToThreeOne({
46
- openapi: "3.0.3",
47
- info: {
48
- title: "Hello World",
49
- version: "1.0.0"
50
- },
51
- paths: {}
52
- });
53
- expect(result.openapi).toBe("3.1.1");
54
- });
55
- });
56
- describe("nullable types", () => {
57
- it("migrates nullable types", async () => {
58
- const result = upgradeFromThreeToThreeOne({
59
- openapi: "3.0.0",
60
- info: {
61
- title: "Hello World",
62
- version: "1.0.0"
63
- },
64
- paths: {
65
- "/test": {
66
- get: {
67
- responses: {
68
- "200": {
69
- description: "foobar",
70
- content: {
71
- "application/json": {
72
- schema: {
73
- type: "string",
74
- nullable: true
75
- }
76
- }
77
- }
78
- }
79
- }
80
- }
81
- }
82
- }
83
- });
84
- expect(result.paths["/test"].get.responses["200"].content["application/json"].schema).toEqual({
85
- type: ["string", "null"]
86
- });
87
- });
88
- });
89
- describe("exclusiveMinimum and exclusiveMaximum", () => {
90
- it("migrate exclusiveMinimum and exclusiveMaximum", async () => {
91
- const result = upgradeFromThreeToThreeOne({
92
- openapi: "3.0.0",
93
- info: {
94
- title: "Hello World",
95
- version: "1.0.0"
96
- },
97
- paths: {
98
- "/test": {
99
- get: {
100
- responses: {
101
- "200": {
102
- description: "foobar",
103
- content: {
104
- "application/json": {
105
- schema: {
106
- type: "integer",
107
- minimum: 1,
108
- exclusiveMinimum: true,
109
- maximum: 100,
110
- exclusiveMaximum: true
111
- }
112
- }
113
- }
114
- }
115
- }
116
- }
117
- }
118
- }
119
- });
120
- expect(result.paths["/test"].get.responses["200"].content["application/json"].schema).toEqual({
121
- type: "integer",
122
- exclusiveMinimum: 1,
123
- exclusiveMaximum: 100
124
- });
125
- });
126
- });
127
- describe("migrates example to examples", () => {
128
- it("uses arrays in schemas", async () => {
129
- const result = upgradeFromThreeToThreeOne({
130
- openapi: "3.0.0",
131
- info: {
132
- title: "Hello World",
133
- version: "1.0.0"
134
- },
135
- paths: {
136
- "/test": {
137
- get: {
138
- responses: {
139
- "200": {
140
- description: "foobar",
141
- content: {
142
- "application/json": {
143
- schema: {
144
- type: "integer",
145
- example: 1
146
- }
147
- }
148
- }
149
- }
150
- }
151
- }
152
- }
153
- }
154
- });
155
- expect(result.paths["/test"].get.responses["200"].content["application/json"].schema).toEqual({
156
- type: "integer",
157
- examples: [1]
158
- });
159
- });
160
- it("uses example objects everywhere else", async () => {
161
- const result = upgradeFromThreeToThreeOne({
162
- openapi: "3.0.0",
163
- info: {
164
- title: "Hello World",
165
- version: "1.0.0"
166
- },
167
- paths: {
168
- "/test": {
169
- get: {
170
- parameters: [
171
- {
172
- name: "limit",
173
- in: "query",
174
- schema: {
175
- type: "integer",
176
- example: 10
177
- },
178
- example: 10
179
- }
180
- ]
181
- }
182
- }
183
- }
184
- });
185
- expect(result.paths["/test"].get.parameters[0]).toEqual({
186
- name: "limit",
187
- in: "query",
188
- schema: {
189
- type: "integer",
190
- // array, because it’s in a schema
191
- examples: [10]
192
- },
193
- // object, because it’s not in a schema
194
- examples: {
195
- default: {
196
- value: 10
197
- }
198
- }
199
- });
200
- });
201
- it("doesn\u2019t transform arrays into objects", () => {
202
- const result = upgradeFromThreeToThreeOne({
203
- openapi: "3.0.0",
204
- info: {
205
- title: "Sample API",
206
- version: "1.0.0",
207
- description: "A simple example API"
208
- },
209
- tags: [
210
- {
211
- "name": "users",
212
- "description": "Operations about users",
213
- "x-internal": true
214
- }
215
- ],
216
- paths: {
217
- "/users": {
218
- post: {
219
- tags: ["users"],
220
- summary: "hello",
221
- description: "Returns a list of users",
222
- operationId: "getUsers",
223
- requestBody: {
224
- content: {
225
- "application/json": {
226
- schema: {
227
- type: "object",
228
- properties: {
229
- foobar: {
230
- type: "array",
231
- example: ["Portfolio1", "Portfolio2"],
232
- items: {
233
- type: "string"
234
- }
235
- }
236
- }
237
- }
238
- }
239
- }
240
- }
241
- }
242
- }
243
- }
244
- });
245
- expect(
246
- result.paths["/users"].post.requestBody.content["application/json"].schema.properties.foobar
247
- ).toStrictEqual({
248
- type: "array",
249
- examples: [["Portfolio1", "Portfolio2"]],
250
- items: {
251
- type: "string"
252
- }
253
- });
254
- });
255
- });
256
- describe("describing File Upload Payloads", () => {
257
- it("removes schema for binary file uploads", async () => {
258
- const result = upgradeFromThreeToThreeOne({
259
- openapi: "3.0.0",
260
- info: {
261
- title: "Hello World",
262
- version: "1.0.0"
263
- },
264
- paths: {
265
- "/upload": {
266
- post: {
267
- requestBody: {
268
- content: {
269
- "application/octet-stream": {
270
- schema: {
271
- type: "string",
272
- format: "binary"
273
- }
274
- }
275
- }
276
- }
277
- }
278
- }
279
- }
280
- });
281
- expect(result.paths["/upload"].post.requestBody.content["application/octet-stream"]).toEqual({});
282
- });
283
- it("migrates base64 format to contentEncoding for image uploads", async () => {
284
- const result = upgradeFromThreeToThreeOne({
285
- openapi: "3.0.0",
286
- info: {
287
- title: "Hello World",
288
- version: "1.0.0"
289
- },
290
- paths: {
291
- "/upload": {
292
- post: {
293
- requestBody: {
294
- content: {
295
- "image/png": {
296
- schema: {
297
- type: "string",
298
- format: "base64"
299
- }
300
- }
301
- }
302
- }
303
- }
304
- }
305
- }
306
- });
307
- expect(result.paths["/upload"].post.requestBody.content["image/png"]).toEqual({
308
- schema: {
309
- type: "string",
310
- contentEncoding: "base64"
311
- }
312
- });
313
- });
314
- it("migrates binary format for multipart file uploads", async () => {
315
- const result = upgradeFromThreeToThreeOne({
316
- openapi: "3.0.0",
317
- info: {
318
- title: "Hello World",
319
- version: "1.0.0"
320
- },
321
- paths: {
322
- "/upload": {
323
- post: {
324
- requestBody: {
325
- content: {
326
- "multipart/form-data": {
327
- schema: {
328
- type: "object",
329
- properties: {
330
- orderId: {
331
- type: "integer"
332
- },
333
- fileName: {
334
- type: "string",
335
- format: "binary"
336
- }
337
- }
338
- }
339
- }
340
- }
341
- }
342
- }
343
- }
344
- }
345
- });
346
- expect(result.paths["/upload"].post.requestBody.content["multipart/form-data"]).toEqual({
347
- schema: {
348
- type: "object",
349
- properties: {
350
- orderId: {
351
- type: "integer"
352
- },
353
- fileName: {
354
- type: "string",
355
- contentMediaType: "application/octet-stream"
356
- }
357
- }
358
- }
359
- });
360
- });
361
- });
362
- it("migrates byte format", async () => {
363
- const result = upgradeFromThreeToThreeOne({
364
- openapi: "3.0.0",
365
- info: {
366
- title: "Hello World",
367
- version: "1.0.0"
368
- },
369
- paths: {
370
- "/upload": {
371
- post: {
372
- requestBody: {
373
- content: {
374
- "image/png": {
375
- schema: {
376
- type: "string",
377
- format: "byte"
378
- }
379
- }
380
- }
381
- }
382
- }
383
- }
384
- }
385
- });
386
- expect(result.paths["/upload"].post.requestBody.content["image/png"]).toEqual({
387
- schema: {
388
- type: "string",
389
- contentMediaType: "image/png",
390
- contentEncoding: "base64"
391
- }
392
- });
393
- });
394
- describe.skip("declaring $schema", () => {
395
- it("adds a $schema", async () => {
396
- const result = upgradeFromThreeToThreeOne({
397
- openapi: "3.0.0",
398
- info: {
399
- title: "Hello World",
400
- version: "1.0.0"
401
- },
402
- paths: {}
403
- });
404
- expect(result.$schema).toBe("http://json-schema.org/draft-07/schema#");
405
- });
406
- });
407
- describe("binary format handling with oneOf", () => {
408
- it("correctly handles format: binary in oneOf schemas", async () => {
409
- const result = upgradeFromThreeToThreeOne({
410
- openapi: "3.0.0",
411
- info: {
412
- title: "Hello World",
413
- version: "1.0.0"
414
- },
415
- paths: {
416
- "/images/edits": {
417
- post: {
418
- requestBody: {
419
- required: true,
420
- content: {
421
- "multipart/form-data": {
422
- schema: {
423
- type: "object",
424
- required: ["model", "prompt"],
425
- properties: {
426
- model: {
427
- type: "string",
428
- enum: ["Kolors"]
429
- },
430
- image: {
431
- oneOf: [
432
- {
433
- type: "string",
434
- format: "binary"
435
- },
436
- {
437
- type: "string"
438
- }
439
- ]
440
- },
441
- prompt: {
442
- type: "string"
443
- }
444
- }
445
- }
446
- }
447
- }
448
- }
449
- }
450
- }
451
- }
452
- });
453
- expect(
454
- result.paths["/images/edits"].post.requestBody.content["multipart/form-data"].schema.properties.image.oneOf[0]
455
- ).toEqual({
456
- type: "string",
457
- contentMediaType: "application/octet-stream"
458
- });
459
- });
460
- });
461
- });
462
- //# sourceMappingURL=upgrade-from-three-to-three-one.test.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/utils/upgrade-from-three-to-three-one.test.ts"],
4
- "sourcesContent": ["import { describe, expect, it } from 'vitest'\n\nimport { isSchemaPath, upgradeFromThreeToThreeOne } from './upgrade-from-three-to-three-one'\n\ndescribe('isSchemaPath', () => {\n it('correctly identifies schema paths', () => {\n expect(isSchemaPath(['components', 'schemas', 'User'])).toBe(true)\n expect(isSchemaPath(['paths', '/users', 'get', 'responses', '200', 'content', 'application/json', 'schema'])).toBe(\n true,\n )\n expect(isSchemaPath(['paths', '/users', 'post', 'requestBody', 'content', 'application/json', 'schema'])).toBe(true)\n expect(isSchemaPath(['components', 'schemas', 'User', 'properties', 'address'])).toBe(true)\n expect(isSchemaPath(['components', 'schemas', 'User', 'allOf', '0'])).toBe(true)\n expect(isSchemaPath(['paths', '/users', 'get', 'parameters', '0', 'schema'])).toBe(true)\n })\n\n it('correctly identifies non-schema paths', () => {\n expect(isSchemaPath(['info'])).toBe(false)\n expect(isSchemaPath(['paths', '/users', 'get', 'summary'])).toBe(false)\n expect(isSchemaPath(['components', 'parameters', 'userId'])).toBe(false)\n })\n})\n\ndescribe('upgradeFromThreeToThreeOne', () => {\n describe('version', () => {\n it('doesn\u2019t modify Swagger 2.0 files', async () => {\n const result = upgradeFromThreeToThreeOne({\n swagger: '2.0',\n info: {\n title: 'Hello World',\n version: '1.0.0',\n },\n paths: {},\n })\n\n expect(result.swagger).toBe('2.0')\n })\n\n it('changes the version to from 3.0.0 to 3.1.1', async () => {\n const result = upgradeFromThreeToThreeOne({\n openapi: '3.0.0',\n info: {\n title: 'Hello World',\n version: '1.0.0',\n },\n paths: {},\n })\n\n expect(result.openapi).toBe('3.1.1')\n })\n\n it('changes the version to 3.0.3 to 3.1.1', async () => {\n const result = upgradeFromThreeToThreeOne({\n openapi: '3.0.3',\n info: {\n title: 'Hello World',\n version: '1.0.0',\n },\n paths: {},\n })\n\n expect(result.openapi).toBe('3.1.1')\n })\n })\n\n describe('nullable types', () => {\n it('migrates nullable types', async () => {\n const result = upgradeFromThreeToThreeOne({\n openapi: '3.0.0',\n info: {\n title: 'Hello World',\n version: '1.0.0',\n },\n paths: {\n '/test': {\n get: {\n responses: {\n '200': {\n description: 'foobar',\n content: {\n 'application/json': {\n schema: {\n type: 'string',\n nullable: true,\n },\n },\n },\n },\n },\n },\n },\n },\n })\n\n expect(result.paths['/test'].get.responses['200'].content['application/json'].schema).toEqual({\n type: ['string', 'null'],\n })\n })\n })\n\n describe('exclusiveMinimum and exclusiveMaximum', () => {\n it('migrate exclusiveMinimum and exclusiveMaximum', async () => {\n const result = upgradeFromThreeToThreeOne({\n openapi: '3.0.0',\n info: {\n title: 'Hello World',\n version: '1.0.0',\n },\n paths: {\n '/test': {\n get: {\n responses: {\n '200': {\n description: 'foobar',\n content: {\n 'application/json': {\n schema: {\n type: 'integer',\n minimum: 1,\n exclusiveMinimum: true,\n maximum: 100,\n exclusiveMaximum: true,\n },\n },\n },\n },\n },\n },\n },\n },\n })\n\n expect(result.paths['/test'].get.responses['200'].content['application/json'].schema).toEqual({\n type: 'integer',\n exclusiveMinimum: 1,\n exclusiveMaximum: 100,\n })\n })\n })\n\n describe('migrates example to examples', () => {\n it('uses arrays in schemas', async () => {\n const result = upgradeFromThreeToThreeOne({\n openapi: '3.0.0',\n info: {\n title: 'Hello World',\n version: '1.0.0',\n },\n paths: {\n '/test': {\n get: {\n responses: {\n '200': {\n description: 'foobar',\n content: {\n 'application/json': {\n schema: {\n type: 'integer',\n example: 1,\n },\n },\n },\n },\n },\n },\n },\n },\n })\n\n expect(result.paths['/test'].get.responses['200'].content['application/json'].schema).toEqual({\n type: 'integer',\n examples: [1],\n })\n })\n\n it('uses example objects everywhere else', async () => {\n const result = upgradeFromThreeToThreeOne({\n openapi: '3.0.0',\n info: {\n title: 'Hello World',\n version: '1.0.0',\n },\n paths: {\n '/test': {\n get: {\n parameters: [\n {\n name: 'limit',\n in: 'query',\n schema: {\n type: 'integer',\n example: 10,\n },\n example: 10,\n },\n ],\n },\n },\n },\n })\n\n expect(result.paths['/test'].get.parameters[0]).toEqual({\n name: 'limit',\n in: 'query',\n schema: {\n type: 'integer',\n // array, because it\u2019s in a schema\n examples: [10],\n },\n // object, because it\u2019s not in a schema\n examples: {\n default: {\n value: 10,\n },\n },\n })\n })\n\n it('doesn\u2019t transform arrays into objects', () => {\n const result = upgradeFromThreeToThreeOne({\n openapi: '3.0.0',\n info: {\n title: 'Sample API',\n version: '1.0.0',\n description: 'A simple example API',\n },\n tags: [\n {\n 'name': 'users',\n 'description': 'Operations about users',\n 'x-internal': true,\n },\n ],\n paths: {\n '/users': {\n post: {\n tags: ['users'],\n summary: 'hello',\n description: 'Returns a list of users',\n operationId: 'getUsers',\n requestBody: {\n content: {\n 'application/json': {\n schema: {\n type: 'object',\n properties: {\n foobar: {\n type: 'array',\n example: ['Portfolio1', 'Portfolio2'],\n items: {\n type: 'string',\n },\n },\n },\n },\n },\n },\n },\n },\n },\n },\n })\n\n expect(\n result.paths['/users'].post.requestBody.content['application/json'].schema.properties.foobar,\n ).toStrictEqual({\n type: 'array',\n examples: [['Portfolio1', 'Portfolio2']],\n items: {\n type: 'string',\n },\n })\n })\n })\n\n describe('describing File Upload Payloads', () => {\n it('removes schema for binary file uploads', async () => {\n const result = upgradeFromThreeToThreeOne({\n openapi: '3.0.0',\n info: {\n title: 'Hello World',\n version: '1.0.0',\n },\n paths: {\n '/upload': {\n post: {\n requestBody: {\n content: {\n 'application/octet-stream': {\n schema: {\n type: 'string',\n format: 'binary',\n },\n },\n },\n },\n },\n },\n },\n })\n\n expect(result.paths['/upload'].post.requestBody.content['application/octet-stream']).toEqual({})\n })\n\n it('migrates base64 format to contentEncoding for image uploads', async () => {\n const result = upgradeFromThreeToThreeOne({\n openapi: '3.0.0',\n info: {\n title: 'Hello World',\n version: '1.0.0',\n },\n paths: {\n '/upload': {\n post: {\n requestBody: {\n content: {\n 'image/png': {\n schema: {\n type: 'string',\n format: 'base64',\n },\n },\n },\n },\n },\n },\n },\n })\n\n expect(result.paths['/upload'].post.requestBody.content['image/png']).toEqual({\n schema: {\n type: 'string',\n contentEncoding: 'base64',\n },\n })\n })\n\n it('migrates binary format for multipart file uploads', async () => {\n const result = upgradeFromThreeToThreeOne({\n openapi: '3.0.0',\n info: {\n title: 'Hello World',\n version: '1.0.0',\n },\n paths: {\n '/upload': {\n post: {\n requestBody: {\n content: {\n 'multipart/form-data': {\n schema: {\n type: 'object',\n properties: {\n orderId: {\n type: 'integer',\n },\n fileName: {\n type: 'string',\n format: 'binary',\n },\n },\n },\n },\n },\n },\n },\n },\n },\n })\n\n expect(result.paths['/upload'].post.requestBody.content['multipart/form-data']).toEqual({\n schema: {\n type: 'object',\n properties: {\n orderId: {\n type: 'integer',\n },\n fileName: {\n type: 'string',\n contentMediaType: 'application/octet-stream',\n },\n },\n },\n })\n })\n })\n\n it('migrates byte format', async () => {\n const result = upgradeFromThreeToThreeOne({\n openapi: '3.0.0',\n info: {\n title: 'Hello World',\n version: '1.0.0',\n },\n paths: {\n '/upload': {\n post: {\n requestBody: {\n content: {\n 'image/png': {\n schema: {\n type: 'string',\n format: 'byte',\n },\n },\n },\n },\n },\n },\n },\n })\n\n expect(result.paths['/upload'].post.requestBody.content['image/png']).toEqual({\n schema: {\n type: 'string',\n contentMediaType: 'image/png',\n contentEncoding: 'base64',\n },\n })\n })\n\n describe.skip('declaring $schema', () => {\n it('adds a $schema', async () => {\n const result = upgradeFromThreeToThreeOne({\n openapi: '3.0.0',\n info: {\n title: 'Hello World',\n version: '1.0.0',\n },\n paths: {},\n })\n\n expect(result.$schema).toBe('http://json-schema.org/draft-07/schema#')\n })\n })\n\n describe('binary format handling with oneOf', () => {\n it('correctly handles format: binary in oneOf schemas', async () => {\n const result = upgradeFromThreeToThreeOne({\n openapi: '3.0.0',\n info: {\n title: 'Hello World',\n version: '1.0.0',\n },\n paths: {\n '/images/edits': {\n post: {\n requestBody: {\n required: true,\n content: {\n 'multipart/form-data': {\n schema: {\n type: 'object',\n required: ['model', 'prompt'],\n properties: {\n model: {\n type: 'string',\n enum: ['Kolors'],\n },\n image: {\n oneOf: [\n {\n type: 'string',\n format: 'binary',\n },\n {\n type: 'string',\n },\n ],\n },\n prompt: {\n type: 'string',\n },\n },\n },\n },\n },\n },\n },\n },\n },\n })\n\n expect(\n result.paths['/images/edits'].post.requestBody.content['multipart/form-data'].schema.properties.image.oneOf[0],\n ).toEqual({\n type: 'string',\n contentMediaType: 'application/octet-stream',\n })\n })\n })\n})\n"],
5
- "mappings": "AAAA,SAAS,UAAU,QAAQ,UAAU;AAErC,SAAS,cAAc,kCAAkC;AAEzD,SAAS,gBAAgB,MAAM;AAC7B,KAAG,qCAAqC,MAAM;AAC5C,WAAO,aAAa,CAAC,cAAc,WAAW,MAAM,CAAC,CAAC,EAAE,KAAK,IAAI;AACjE,WAAO,aAAa,CAAC,SAAS,UAAU,OAAO,aAAa,OAAO,WAAW,oBAAoB,QAAQ,CAAC,CAAC,EAAE;AAAA,MAC5G;AAAA,IACF;AACA,WAAO,aAAa,CAAC,SAAS,UAAU,QAAQ,eAAe,WAAW,oBAAoB,QAAQ,CAAC,CAAC,EAAE,KAAK,IAAI;AACnH,WAAO,aAAa,CAAC,cAAc,WAAW,QAAQ,cAAc,SAAS,CAAC,CAAC,EAAE,KAAK,IAAI;AAC1F,WAA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