@scalar/openapi-types 0.3.1 → 0.3.3

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 (107) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/helpers/index.d.ts +2 -0
  3. package/dist/helpers/index.d.ts.map +1 -0
  4. package/dist/helpers/index.js +5 -0
  5. package/dist/helpers/index.js.map +7 -0
  6. package/dist/helpers/is-dereferenced.d.ts +7 -0
  7. package/dist/helpers/is-dereferenced.d.ts.map +1 -0
  8. package/dist/helpers/is-dereferenced.js +5 -0
  9. package/dist/helpers/is-dereferenced.js.map +7 -0
  10. package/dist/openapi-types.d.ts +9 -18
  11. package/dist/openapi-types.d.ts.map +1 -1
  12. package/dist/openapi-types.js +1 -16
  13. package/dist/openapi-types.js.map +3 -3
  14. package/dist/openapi-types.test-d.js.map +2 -2
  15. package/dist/schemas/3.1/processed/index.d.ts +1 -1
  16. package/dist/schemas/3.1/processed/index.d.ts.map +1 -1
  17. package/dist/schemas/3.1/processed/index.js.map +2 -2
  18. package/dist/schemas/3.1/processed/openapi-object.d.ts +30835 -22
  19. package/dist/schemas/3.1/processed/openapi-object.d.ts.map +1 -1
  20. package/dist/schemas/3.1/processed/openapi-object.js +1 -1
  21. package/dist/schemas/3.1/processed/openapi-object.js.map +2 -2
  22. package/dist/schemas/3.1/unprocessed/index.d.ts +1 -1
  23. package/dist/schemas/3.1/unprocessed/index.d.ts.map +1 -1
  24. package/dist/schemas/3.1/unprocessed/index.js.map +2 -2
  25. package/dist/schemas/3.1/unprocessed/openapi-object.d.ts +22 -23
  26. package/dist/schemas/3.1/unprocessed/openapi-object.d.ts.map +1 -1
  27. package/dist/schemas/3.1/unprocessed/openapi-object.js +55 -1
  28. package/dist/schemas/3.1/unprocessed/openapi-object.js.map +2 -2
  29. package/dist/schemas/3.1/unprocessed/paths-object.d.ts +2268 -265
  30. package/dist/schemas/3.1/unprocessed/paths-object.d.ts.map +1 -1
  31. package/dist/schemas/3.1/unprocessed/paths-object.js +14 -2
  32. package/dist/schemas/3.1/unprocessed/paths-object.js.map +2 -2
  33. package/package.json +8 -3
  34. package/dist/schemas/3.1/compliance/callback-object.test.js +0 -97
  35. package/dist/schemas/3.1/compliance/callback-object.test.js.map +0 -7
  36. package/dist/schemas/3.1/compliance/contact-object.test.js +0 -19
  37. package/dist/schemas/3.1/compliance/contact-object.test.js.map +0 -7
  38. package/dist/schemas/3.1/compliance/example-object.test.js +0 -91
  39. package/dist/schemas/3.1/compliance/example-object.test.js.map +0 -7
  40. package/dist/schemas/3.1/compliance/external-documentation-object.test.js +0 -17
  41. package/dist/schemas/3.1/compliance/external-documentation-object.test.js.map +0 -7
  42. package/dist/schemas/3.1/compliance/header-object.test.js +0 -47
  43. package/dist/schemas/3.1/compliance/header-object.test.js.map +0 -7
  44. package/dist/schemas/3.1/compliance/info-object.test.js +0 -41
  45. package/dist/schemas/3.1/compliance/info-object.test.js.map +0 -7
  46. package/dist/schemas/3.1/compliance/license-object.test.js +0 -17
  47. package/dist/schemas/3.1/compliance/license-object.test.js.map +0 -7
  48. package/dist/schemas/3.1/compliance/media-type-object.test.js +0 -69
  49. package/dist/schemas/3.1/compliance/media-type-object.test.js.map +0 -7
  50. package/dist/schemas/3.1/compliance/openapi-object.test.js +0 -381
  51. package/dist/schemas/3.1/compliance/openapi-object.test.js.map +0 -7
  52. package/dist/schemas/3.1/compliance/operation-object.test.js +0 -467
  53. package/dist/schemas/3.1/compliance/operation-object.test.js.map +0 -7
  54. package/dist/schemas/3.1/compliance/parameter-object.test.js +0 -155
  55. package/dist/schemas/3.1/compliance/parameter-object.test.js.map +0 -7
  56. package/dist/schemas/3.1/compliance/path-item-object.test.js +0 -103
  57. package/dist/schemas/3.1/compliance/path-item-object.test.js.map +0 -7
  58. package/dist/schemas/3.1/compliance/reference-object.test.js +0 -282
  59. package/dist/schemas/3.1/compliance/reference-object.test.js.map +0 -7
  60. package/dist/schemas/3.1/compliance/request-body-object.test.js +0 -97
  61. package/dist/schemas/3.1/compliance/request-body-object.test.js.map +0 -7
  62. package/dist/schemas/3.1/compliance/response-object.test.js +0 -131
  63. package/dist/schemas/3.1/compliance/response-object.test.js.map +0 -7
  64. package/dist/schemas/3.1/compliance/responses-object.test.js +0 -53
  65. package/dist/schemas/3.1/compliance/responses-object.test.js.map +0 -7
  66. package/dist/schemas/3.1/compliance/runtime-expression.test.js +0 -165
  67. package/dist/schemas/3.1/compliance/runtime-expression.test.js.map +0 -7
  68. package/dist/schemas/3.1/compliance/schema-object.test.js +0 -470
  69. package/dist/schemas/3.1/compliance/schema-object.test.js.map +0 -7
  70. package/dist/schemas/3.1/compliance/security-requirement-object.test.js +0 -54
  71. package/dist/schemas/3.1/compliance/security-requirement-object.test.js.map +0 -7
  72. package/dist/schemas/3.1/compliance/security-scheme-object.test.js +0 -123
  73. package/dist/schemas/3.1/compliance/security-scheme-object.test.js.map +0 -7
  74. package/dist/schemas/3.1/compliance/server-object.test.js +0 -17
  75. package/dist/schemas/3.1/compliance/server-object.test.js.map +0 -7
  76. package/dist/schemas/3.1/compliance/tag-object.test.js +0 -17
  77. package/dist/schemas/3.1/compliance/tag-object.test.js.map +0 -7
  78. package/dist/schemas/3.1/processed/schema-object.test.js +0 -310
  79. package/dist/schemas/3.1/processed/schema-object.test.js.map +0 -7
  80. package/dist/schemas/extensions/x-additional-properties-name.test.js +0 -28
  81. package/dist/schemas/extensions/x-additional-properties-name.test.js.map +0 -7
  82. package/dist/schemas/extensions/x-code-samples.test.js +0 -82
  83. package/dist/schemas/extensions/x-code-samples.test.js.map +0 -7
  84. package/dist/schemas/extensions/x-display-name.test.js +0 -28
  85. package/dist/schemas/extensions/x-display-name.test.js.map +0 -7
  86. package/dist/schemas/extensions/x-enum-descriptions.test.js +0 -36
  87. package/dist/schemas/extensions/x-enum-descriptions.test.js.map +0 -7
  88. package/dist/schemas/extensions/x-internal.test.js +0 -20
  89. package/dist/schemas/extensions/x-internal.test.js.map +0 -7
  90. package/dist/schemas/extensions/x-post-response.test.js +0 -24
  91. package/dist/schemas/extensions/x-post-response.test.js.map +0 -7
  92. package/dist/schemas/extensions/x-scalar-icon.test.js +0 -14
  93. package/dist/schemas/extensions/x-scalar-icon.test.js.map +0 -7
  94. package/dist/schemas/extensions/x-scalar-ignore.test.js +0 -20
  95. package/dist/schemas/extensions/x-scalar-ignore.test.js.map +0 -7
  96. package/dist/schemas/extensions/x-scalar-redirect-uri.test.js +0 -23
  97. package/dist/schemas/extensions/x-scalar-redirect-uri.test.js.map +0 -7
  98. package/dist/schemas/extensions/x-scalar-sdk-installation.test.js +0 -25
  99. package/dist/schemas/extensions/x-scalar-sdk-installation.test.js.map +0 -7
  100. package/dist/schemas/extensions/x-scalar-security-query.test.js +0 -35
  101. package/dist/schemas/extensions/x-scalar-security-query.test.js.map +0 -7
  102. package/dist/schemas/extensions/x-scalar-stability.test.js +0 -33
  103. package/dist/schemas/extensions/x-scalar-stability.test.js.map +0 -7
  104. package/dist/schemas/extensions/x-tag-groups.test.js +0 -55
  105. package/dist/schemas/extensions/x-tag-groups.test.js.map +0 -7
  106. package/dist/schemas/extensions/x-use-pkce.test.js +0 -34
  107. package/dist/schemas/extensions/x-use-pkce.test.js.map +0 -7
@@ -1,467 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { OperationObjectSchema } from "../unprocessed/operation-object.js";
3
- describe("operation-object", () => {
4
- describe("OperationObjectSchema", () => {
5
- it("Operation Object Example", () => {
6
- const result = OperationObjectSchema.parse({
7
- tags: ["pet"],
8
- summary: "Updates a pet in the store with form data",
9
- operationId: "updatePetWithForm",
10
- parameters: [
11
- {
12
- name: "petId",
13
- in: "path",
14
- description: "ID of pet that needs to be updated",
15
- required: true,
16
- schema: {
17
- type: "string"
18
- }
19
- }
20
- ],
21
- requestBody: {
22
- content: {
23
- "application/x-www-form-urlencoded": {
24
- schema: {
25
- type: "object",
26
- properties: {
27
- name: {
28
- description: "Updated name of the pet",
29
- type: "string"
30
- },
31
- status: {
32
- description: "Updated status of the pet",
33
- type: "string"
34
- }
35
- },
36
- required: ["status"]
37
- }
38
- }
39
- }
40
- },
41
- responses: {
42
- 200: {
43
- description: "Pet updated.",
44
- content: {
45
- "application/json": {},
46
- "application/xml": {}
47
- }
48
- },
49
- 405: {
50
- description: "Method Not Allowed",
51
- content: {
52
- "application/json": {},
53
- "application/xml": {}
54
- }
55
- }
56
- },
57
- security: [
58
- {
59
- petstore_auth: ["write:pets", "read:pets"]
60
- }
61
- ]
62
- });
63
- expect(result).toEqual({
64
- tags: ["pet"],
65
- summary: "Updates a pet in the store with form data",
66
- operationId: "updatePetWithForm",
67
- parameters: [
68
- {
69
- name: "petId",
70
- in: "path",
71
- description: "ID of pet that needs to be updated",
72
- required: true,
73
- schema: {
74
- type: "string"
75
- }
76
- }
77
- ],
78
- requestBody: {
79
- content: {
80
- "application/x-www-form-urlencoded": {
81
- schema: {
82
- type: "object",
83
- properties: {
84
- name: {
85
- description: "Updated name of the pet",
86
- type: "string"
87
- },
88
- status: {
89
- description: "Updated status of the pet",
90
- type: "string"
91
- }
92
- },
93
- required: ["status"]
94
- }
95
- }
96
- }
97
- },
98
- responses: {
99
- 200: {
100
- description: "Pet updated.",
101
- content: {
102
- "application/json": {},
103
- "application/xml": {}
104
- }
105
- },
106
- 405: {
107
- description: "Method Not Allowed",
108
- content: {
109
- "application/json": {},
110
- "application/xml": {}
111
- }
112
- }
113
- },
114
- security: [
115
- {
116
- petstore_auth: ["write:pets", "read:pets"]
117
- }
118
- ]
119
- });
120
- });
121
- describe("Considerations for File Uploads", () => {
122
- it("PNG image as a binary file", () => {
123
- const result = OperationObjectSchema.parse({
124
- requestBody: {
125
- content: {
126
- "image/png": {}
127
- }
128
- }
129
- });
130
- expect(result).toEqual({
131
- requestBody: {
132
- content: {
133
- "image/png": {}
134
- }
135
- }
136
- });
137
- });
138
- it("arbitrary binary file", () => {
139
- const result = OperationObjectSchema.parse({
140
- requestBody: {
141
- content: {
142
- "application/octet-stream": {}
143
- }
144
- }
145
- });
146
- expect(result).toEqual({
147
- requestBody: {
148
- content: {
149
- "application/octet-stream": {}
150
- }
151
- }
152
- });
153
- });
154
- it("arbitrary JSON without constraints beyond being syntactically valid", () => {
155
- const result = OperationObjectSchema.parse({
156
- requestBody: {
157
- content: {
158
- "application/json": {}
159
- }
160
- }
161
- });
162
- expect(result).toEqual({
163
- requestBody: {
164
- content: {
165
- "application/json": {}
166
- }
167
- }
168
- });
169
- });
170
- });
171
- describe("Encoding the x-www-form-urlencoded Media Type", () => {
172
- it(`When there is no encoding field, the serialization strategy is based on the Encoding Object's default values`, () => {
173
- const result = OperationObjectSchema.parse({
174
- requestBody: {
175
- content: {
176
- "application/x-www-form-urlencoded": {
177
- schema: {
178
- type: "object",
179
- properties: {
180
- id: {
181
- type: "string",
182
- format: "uuid"
183
- },
184
- address: {
185
- // complex types are stringified to support RFC 1866
186
- type: "object",
187
- properties: {}
188
- }
189
- }
190
- }
191
- }
192
- }
193
- }
194
- });
195
- expect(result).toEqual({
196
- requestBody: {
197
- content: {
198
- "application/x-www-form-urlencoded": {
199
- schema: {
200
- type: "object",
201
- properties: {
202
- id: {
203
- type: "string",
204
- format: "uuid"
205
- },
206
- address: {
207
- // complex types are stringified to support RFC 1866
208
- type: "object",
209
- properties: {}
210
- }
211
- }
212
- }
213
- }
214
- }
215
- }
216
- });
217
- });
218
- it("Note that application/x-www-form-urlencoded is a text format, which requires base64-encoding any binary data", () => {
219
- const result = OperationObjectSchema.parse({
220
- requestBody: {
221
- content: {
222
- "application/x-www-form-urlencoded": {
223
- schema: {
224
- type: "object",
225
- properties: {
226
- name: {
227
- type: "string"
228
- },
229
- icon: {
230
- // The default with "contentEncoding" is application/octet-stream,
231
- // so we need to set image media type(s) in the Encoding Object.
232
- type: "string",
233
- contentEncoding: "base64url"
234
- }
235
- }
236
- }
237
- }
238
- },
239
- encoding: {
240
- icon: {
241
- contentType: "image/png, image/jpeg"
242
- }
243
- }
244
- }
245
- });
246
- expect(result).toEqual({
247
- requestBody: {
248
- content: {
249
- "application/x-www-form-urlencoded": {
250
- schema: {
251
- type: "object",
252
- properties: {
253
- name: {
254
- type: "string"
255
- },
256
- icon: {
257
- // The default with "contentEncoding" is application/octet-stream,
258
- // so we need to set image media type(s) in the Encoding Object.
259
- type: "string",
260
- contentEncoding: "base64url"
261
- }
262
- }
263
- }
264
- }
265
- },
266
- encoding: {
267
- icon: {
268
- contentType: "image/png, image/jpeg"
269
- }
270
- }
271
- }
272
- });
273
- });
274
- it("Example: Basic Multipart Form", () => {
275
- const result = OperationObjectSchema.parse({
276
- requestBody: {
277
- content: {
278
- "multipart/form-data": {
279
- schema: {
280
- type: "object",
281
- properties: {
282
- id: {
283
- // default for primitives without a special format is text/plain
284
- type: "string",
285
- format: "uuid"
286
- },
287
- profileImage: {
288
- // default for string with binary format is `application/octet-stream`
289
- type: "string",
290
- format: "binary"
291
- },
292
- addresses: {
293
- // default for arrays is based on the type in the `items`
294
- // subschema, which is an object, so `application/json`
295
- type: "array",
296
- items: {
297
- $ref: "#/components/schemas/Address"
298
- }
299
- }
300
- }
301
- }
302
- }
303
- }
304
- }
305
- });
306
- expect(result).toEqual({
307
- requestBody: {
308
- content: {
309
- "multipart/form-data": {
310
- schema: {
311
- type: "object",
312
- properties: {
313
- id: {
314
- // default for primitives without a special format is text/plain
315
- type: "string",
316
- format: "uuid"
317
- },
318
- profileImage: {
319
- // default for string with binary format is `application/octet-stream`
320
- type: "string",
321
- format: "binary"
322
- },
323
- addresses: {
324
- // default for arrays is based on the type in the `items`
325
- // subschema, which is an object, so `application/json`
326
- type: "array",
327
- items: {
328
- $ref: "#/components/schemas/Address"
329
- }
330
- }
331
- }
332
- }
333
- }
334
- }
335
- }
336
- });
337
- });
338
- it("Example: Multipart Form with Encoding Objects", () => {
339
- const result = OperationObjectSchema.parse({
340
- requestBody: {
341
- content: {
342
- "multipart/form-data": {
343
- schema: {
344
- type: "object",
345
- properties: {
346
- id: {
347
- type: "string",
348
- format: "uuid"
349
- },
350
- addresses: {
351
- description: "addresses in XML format",
352
- type: "array",
353
- items: {
354
- $ref: "#/components/schemas/Address"
355
- }
356
- },
357
- profileImage: {
358
- type: "string",
359
- format: "binary"
360
- }
361
- }
362
- },
363
- encoding: {
364
- addresses: {
365
- contentType: "application/xml; charset=utf-8"
366
- },
367
- profileImage: {
368
- contentType: "image/png, image/jpeg",
369
- headers: {
370
- "X-Rate-Limit-Limit": {
371
- description: "The number of allowed requests in the current period",
372
- schema: {
373
- type: "integer"
374
- }
375
- }
376
- }
377
- }
378
- }
379
- }
380
- }
381
- }
382
- });
383
- expect(result).toEqual({
384
- requestBody: {
385
- content: {
386
- "multipart/form-data": {
387
- schema: {
388
- type: "object",
389
- properties: {
390
- id: {
391
- type: "string",
392
- format: "uuid"
393
- },
394
- addresses: {
395
- description: "addresses in XML format",
396
- type: "array",
397
- items: {
398
- $ref: "#/components/schemas/Address"
399
- }
400
- },
401
- profileImage: {
402
- type: "string",
403
- format: "binary"
404
- }
405
- }
406
- },
407
- encoding: {
408
- addresses: {
409
- contentType: "application/xml; charset=utf-8"
410
- },
411
- profileImage: {
412
- contentType: "image/png, image/jpeg",
413
- headers: {
414
- "X-Rate-Limit-Limit": {
415
- description: "The number of allowed requests in the current period",
416
- schema: {
417
- type: "integer"
418
- }
419
- }
420
- }
421
- }
422
- }
423
- }
424
- }
425
- }
426
- });
427
- });
428
- it("Example: Multipart Form with Multiple Files", () => {
429
- const result = OperationObjectSchema.parse({
430
- requestBody: {
431
- content: {
432
- "multipart/form-data": {
433
- schema: {
434
- properties: {
435
- // The property name 'file' will be used for all files.
436
- file: {
437
- type: "array",
438
- items: {}
439
- }
440
- }
441
- }
442
- }
443
- }
444
- }
445
- });
446
- expect(result).toEqual({
447
- requestBody: {
448
- content: {
449
- "multipart/form-data": {
450
- schema: {
451
- properties: {
452
- // The property name 'file' will be used for all files.
453
- file: {
454
- type: "array",
455
- items: {}
456
- }
457
- }
458
- }
459
- }
460
- }
461
- }
462
- });
463
- });
464
- });
465
- });
466
- });
467
- //# sourceMappingURL=operation-object.test.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../src/schemas/3.1/compliance/operation-object.test.ts"],
4
- "sourcesContent": ["import { describe, expect, it } from 'vitest'\nimport { OperationObjectSchema } from '../unprocessed/operation-object'\n\ndescribe('operation-object', () => {\n describe('OperationObjectSchema', () => {\n // https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.1.md#operation-object-example\n it('Operation Object Example', () => {\n const result = OperationObjectSchema.parse({\n tags: ['pet'],\n summary: 'Updates a pet in the store with form data',\n operationId: 'updatePetWithForm',\n parameters: [\n {\n name: 'petId',\n in: 'path',\n description: 'ID of pet that needs to be updated',\n required: true,\n schema: {\n type: 'string',\n },\n },\n ],\n requestBody: {\n content: {\n 'application/x-www-form-urlencoded': {\n schema: {\n type: 'object',\n properties: {\n name: {\n description: 'Updated name of the pet',\n type: 'string',\n },\n status: {\n description: 'Updated status of the pet',\n type: 'string',\n },\n },\n required: ['status'],\n },\n },\n },\n },\n responses: {\n 200: {\n description: 'Pet updated.',\n content: {\n 'application/json': {},\n 'application/xml': {},\n },\n },\n 405: {\n description: 'Method Not Allowed',\n content: {\n 'application/json': {},\n 'application/xml': {},\n },\n },\n },\n security: [\n {\n petstore_auth: ['write:pets', 'read:pets'],\n },\n ],\n })\n expect(result).toEqual({\n tags: ['pet'],\n summary: 'Updates a pet in the store with form data',\n operationId: 'updatePetWithForm',\n parameters: [\n {\n name: 'petId',\n in: 'path',\n description: 'ID of pet that needs to be updated',\n required: true,\n schema: {\n type: 'string',\n },\n },\n ],\n requestBody: {\n content: {\n 'application/x-www-form-urlencoded': {\n schema: {\n type: 'object',\n properties: {\n name: {\n description: 'Updated name of the pet',\n type: 'string',\n },\n status: {\n description: 'Updated status of the pet',\n type: 'string',\n },\n },\n required: ['status'],\n },\n },\n },\n },\n responses: {\n 200: {\n description: 'Pet updated.',\n content: {\n 'application/json': {},\n 'application/xml': {},\n },\n },\n 405: {\n description: 'Method Not Allowed',\n content: {\n 'application/json': {},\n 'application/xml': {},\n },\n },\n },\n security: [\n {\n petstore_auth: ['write:pets', 'read:pets'],\n },\n ],\n })\n })\n\n describe('Considerations for File Uploads', () => {\n it('PNG image as a binary file', () => {\n const result = OperationObjectSchema.parse({\n requestBody: {\n content: {\n 'image/png': {},\n },\n },\n })\n\n expect(result).toEqual({\n requestBody: {\n content: {\n 'image/png': {},\n },\n },\n })\n })\n\n it('arbitrary binary file', () => {\n const result = OperationObjectSchema.parse({\n requestBody: {\n content: {\n 'application/octet-stream': {},\n },\n },\n })\n\n expect(result).toEqual({\n requestBody: {\n content: {\n 'application/octet-stream': {},\n },\n },\n })\n })\n\n it('arbitrary JSON without constraints beyond being syntactically valid', () => {\n const result = OperationObjectSchema.parse({\n requestBody: {\n content: {\n 'application/json': {},\n },\n },\n })\n\n expect(result).toEqual({\n requestBody: {\n content: {\n 'application/json': {},\n },\n },\n })\n })\n })\n\n describe('Encoding the x-www-form-urlencoded Media Type', () => {\n it(`When there is no encoding field, the serialization strategy is based on the Encoding Object's default values`, () => {\n const result = OperationObjectSchema.parse({\n requestBody: {\n content: {\n 'application/x-www-form-urlencoded': {\n schema: {\n type: 'object',\n properties: {\n id: {\n type: 'string',\n format: 'uuid',\n },\n address: {\n // complex types are stringified to support RFC 1866\n type: 'object',\n properties: {},\n },\n },\n },\n },\n },\n },\n })\n\n expect(result).toEqual({\n requestBody: {\n content: {\n 'application/x-www-form-urlencoded': {\n schema: {\n type: 'object',\n properties: {\n id: {\n type: 'string',\n format: 'uuid',\n },\n address: {\n // complex types are stringified to support RFC 1866\n type: 'object',\n properties: {},\n },\n },\n },\n },\n },\n },\n })\n })\n\n it('Note that application/x-www-form-urlencoded is a text format, which requires base64-encoding any binary data', () => {\n const result = OperationObjectSchema.parse({\n requestBody: {\n content: {\n 'application/x-www-form-urlencoded': {\n schema: {\n type: 'object',\n properties: {\n name: {\n type: 'string',\n },\n icon: {\n // The default with \"contentEncoding\" is application/octet-stream,\n // so we need to set image media type(s) in the Encoding Object.\n type: 'string',\n contentEncoding: 'base64url',\n },\n },\n },\n },\n },\n encoding: {\n icon: {\n contentType: 'image/png, image/jpeg',\n },\n },\n },\n })\n\n expect(result).toEqual({\n requestBody: {\n content: {\n 'application/x-www-form-urlencoded': {\n schema: {\n type: 'object',\n properties: {\n name: {\n type: 'string',\n },\n icon: {\n // The default with \"contentEncoding\" is application/octet-stream,\n // so we need to set image media type(s) in the Encoding Object.\n type: 'string',\n contentEncoding: 'base64url',\n },\n },\n },\n },\n },\n encoding: {\n icon: {\n contentType: 'image/png, image/jpeg',\n },\n },\n },\n })\n })\n\n it('Example: Basic Multipart Form', () => {\n const result = OperationObjectSchema.parse({\n requestBody: {\n content: {\n 'multipart/form-data': {\n schema: {\n type: 'object',\n properties: {\n id: {\n // default for primitives without a special format is text/plain\n type: 'string',\n format: 'uuid',\n },\n profileImage: {\n // default for string with binary format is `application/octet-stream`\n type: 'string',\n format: 'binary',\n },\n addresses: {\n // default for arrays is based on the type in the `items`\n // subschema, which is an object, so `application/json`\n type: 'array',\n items: {\n $ref: '#/components/schemas/Address',\n },\n },\n },\n },\n },\n },\n },\n })\n\n expect(result).toEqual({\n requestBody: {\n content: {\n 'multipart/form-data': {\n schema: {\n type: 'object',\n properties: {\n id: {\n // default for primitives without a special format is text/plain\n type: 'string',\n format: 'uuid',\n },\n profileImage: {\n // default for string with binary format is `application/octet-stream`\n type: 'string',\n format: 'binary',\n },\n addresses: {\n // default for arrays is based on the type in the `items`\n // subschema, which is an object, so `application/json`\n type: 'array',\n items: {\n $ref: '#/components/schemas/Address',\n },\n },\n },\n },\n },\n },\n },\n })\n })\n\n it('Example: Multipart Form with Encoding Objects', () => {\n const result = OperationObjectSchema.parse({\n requestBody: {\n content: {\n 'multipart/form-data': {\n schema: {\n type: 'object',\n properties: {\n id: {\n type: 'string',\n format: 'uuid',\n },\n addresses: {\n description: 'addresses in XML format',\n type: 'array',\n items: {\n $ref: '#/components/schemas/Address',\n },\n },\n profileImage: {\n type: 'string',\n format: 'binary',\n },\n },\n },\n encoding: {\n addresses: {\n contentType: 'application/xml; charset=utf-8',\n },\n profileImage: {\n contentType: 'image/png, image/jpeg',\n headers: {\n 'X-Rate-Limit-Limit': {\n description: 'The number of allowed requests in the current period',\n schema: {\n type: 'integer',\n },\n },\n },\n },\n },\n },\n },\n },\n })\n\n expect(result).toEqual({\n requestBody: {\n content: {\n 'multipart/form-data': {\n schema: {\n type: 'object',\n properties: {\n id: {\n type: 'string',\n format: 'uuid',\n },\n addresses: {\n description: 'addresses in XML format',\n type: 'array',\n items: {\n $ref: '#/components/schemas/Address',\n },\n },\n profileImage: {\n type: 'string',\n format: 'binary',\n },\n },\n },\n encoding: {\n addresses: {\n contentType: 'application/xml; charset=utf-8',\n },\n profileImage: {\n contentType: 'image/png, image/jpeg',\n headers: {\n 'X-Rate-Limit-Limit': {\n description: 'The number of allowed requests in the current period',\n schema: {\n type: 'integer',\n },\n },\n },\n },\n },\n },\n },\n },\n })\n })\n\n it('Example: Multipart Form with Multiple Files', () => {\n const result = OperationObjectSchema.parse({\n requestBody: {\n content: {\n 'multipart/form-data': {\n schema: {\n properties: {\n // The property name 'file' will be used for all files.\n file: {\n type: 'array',\n items: {},\n },\n },\n },\n },\n },\n },\n })\n\n expect(result).toEqual({\n requestBody: {\n content: {\n 'multipart/form-data': {\n schema: {\n properties: {\n // The property name 'file' will be used for all files.\n file: {\n type: 'array',\n items: {},\n },\n },\n },\n },\n },\n },\n })\n })\n })\n })\n})\n"],
5
- "mappings": "AAAA,SAAS,UAAU,QAAQ,UAAU;AACrC,SAAS,6BAA6B;AAEtC,SAAS,oBAAoB,MAAM;AACjC,WAAS,yBAAyB,MAAM;AAEtC,OAAG,4BAA4B,MAAM;AACnC,YAAM,SAAS,sBAAsB,MAAM;AAAA,QACzC,MAAM,CAAC,KAAK;AAAA,QACZ,SAAS;AAAA,QACT,aAAa;AAAA,QACb,YA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,YAAY;AAAA;AAAA,oBAEV,MAAM;AAAA,sBACJ,MAAM;AAAA,sBACN,OAAO,CAAC;AAAA,oBACV;AAAA,kBACF;AAAA,gBACF;AAAA,cACF;AAAA,YACF;AAAA,UACF;AAAA,QACF,CAAC;AAAA,MACH,CAAC;AAAA,IACH,CAAC;AAAA,EACH,CAAC;AACH,CAAC;",
6
- "names": []
7
- }
@@ -1,155 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { ParameterObjectSchema } from "../unprocessed/parameter-object.js";
3
- describe("parameter-object", () => {
4
- describe("ParameterObjectSchema", () => {
5
- describe("Parameter Object Examples", () => {
6
- it("A header parameter with an array of 64-bit integer numbers", () => {
7
- const result = ParameterObjectSchema.parse({
8
- name: "token",
9
- in: "header",
10
- description: "token to be passed as a header",
11
- required: true,
12
- schema: {
13
- type: "array",
14
- items: {
15
- type: "integer",
16
- format: "int64"
17
- }
18
- },
19
- style: "simple"
20
- });
21
- expect(result).toEqual({
22
- name: "token",
23
- in: "header",
24
- description: "token to be passed as a header",
25
- required: true,
26
- schema: {
27
- type: "array",
28
- items: {
29
- type: "integer",
30
- format: "int64"
31
- }
32
- },
33
- style: "simple"
34
- });
35
- });
36
- it("A path parameter of a string value", () => {
37
- const result = ParameterObjectSchema.parse({
38
- name: "username",
39
- in: "path",
40
- description: "username to fetch",
41
- required: true,
42
- schema: {
43
- type: "string"
44
- }
45
- });
46
- expect(result).toEqual({
47
- name: "username",
48
- in: "path",
49
- description: "username to fetch",
50
- required: true,
51
- schema: {
52
- type: "string"
53
- }
54
- });
55
- });
56
- it("An optional query parameter of a string value, allowing multiple values by repeating the query parameter", () => {
57
- const result = ParameterObjectSchema.parse({
58
- name: "id",
59
- in: "query",
60
- description: "ID of the object to fetch",
61
- required: false,
62
- schema: {
63
- type: "array",
64
- items: {
65
- type: "string"
66
- }
67
- },
68
- style: "form",
69
- explode: true
70
- });
71
- expect(result).toEqual({
72
- name: "id",
73
- in: "query",
74
- description: "ID of the object to fetch",
75
- required: false,
76
- schema: {
77
- type: "array",
78
- items: {
79
- type: "string"
80
- }
81
- },
82
- style: "form",
83
- explode: true
84
- });
85
- });
86
- it("A free-form query parameter, allowing undefined parameters of a specific type", () => {
87
- const result = ParameterObjectSchema.parse({
88
- in: "query",
89
- name: "freeForm",
90
- schema: {
91
- type: "object",
92
- additionalProperties: {
93
- type: "integer"
94
- }
95
- },
96
- style: "form"
97
- });
98
- expect(result).toEqual({
99
- in: "query",
100
- name: "freeForm",
101
- schema: {
102
- type: "object",
103
- additionalProperties: {
104
- type: "integer"
105
- }
106
- },
107
- style: "form"
108
- });
109
- });
110
- it("A complex parameter using content to define serialization", () => {
111
- const result = ParameterObjectSchema.parse({
112
- in: "query",
113
- name: "coordinates",
114
- content: {
115
- "application/json": {
116
- schema: {
117
- type: "object",
118
- required: ["lat", "long"],
119
- properties: {
120
- lat: {
121
- type: "number"
122
- },
123
- long: {
124
- type: "number"
125
- }
126
- }
127
- }
128
- }
129
- }
130
- });
131
- expect(result).toEqual({
132
- in: "query",
133
- name: "coordinates",
134
- content: {
135
- "application/json": {
136
- schema: {
137
- type: "object",
138
- required: ["lat", "long"],
139
- properties: {
140
- lat: {
141
- type: "number"
142
- },
143
- long: {
144
- type: "number"
145
- }
146
- }
147
- }
148
- }
149
- }
150
- });
151
- });
152
- });
153
- });
154
- });
155
- //# sourceMappingURL=parameter-object.test.js.map