@e22m4u/js-openapi 0.0.5 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +226 -146
- package/dist/cjs/index.cjs +2025 -2092
- package/package.json +10 -8
- package/schema/openapi-3-1/dialect/base.js +21 -0
- package/schema/openapi-3-1/meta/base.js +76 -0
- package/schema/openapi-3-1/schema-base.js +32 -0
- package/schema/openapi-3-1/schema.js +1403 -0
- package/src/ajv.js +32 -0
- package/src/errors/index.d.ts +1 -1
- package/src/errors/index.js +1 -1
- package/src/errors/oa-document-object-validation-error.d.ts +6 -0
- package/src/errors/oa-document-object-validation-error.js +6 -0
- package/src/errors/oa-document-object-validation-error.spec.js +10 -0
- package/src/index.d.ts +1 -3
- package/src/index.js +1 -3
- package/src/json-pointer/resolve-json-pointer.js +1 -1
- package/src/json-pointer/unescape-json-pointer.d.ts +1 -2
- package/src/oa-document-builder.d.ts +302 -111
- package/src/oa-document-builder.js +208 -142
- package/src/oa-document-builder.spec.js +1411 -0
- package/src/oa-document-object/index.d.ts +1 -1
- package/src/oa-document-object/index.js +1 -1
- package/src/oa-document-object/validate-oa-document-object.d.ts +18 -0
- package/src/oa-document-object/validate-oa-document-object.js +53 -0
- package/src/oa-document-object/validate-oa-document-object.spec.js +122 -0
- package/src/{oa-document-scope.d.ts → oa-operation-group.d.ts} +7 -7
- package/src/{oa-document-scope.js → oa-operation-group.js} +101 -46
- package/src/oa-operation-group.spec.js +544 -0
- package/src/oa-reference-object/is-oa-reference-object.js +1 -1
- package/src/oa-reference-object/is-oa-reference-object.spec.js +1 -1
- package/src/oa-reference-object/oa-ref.js +7 -0
- package/src/oa-reference-object/resolve-oa-reference-object.js +1 -11
- package/src/oa-reference-object/resolve-oa-reference-object.spec.js +0 -10
- package/src/oa-specification.d.ts +55 -66
- package/src/oa-specification.js +11 -22
- package/src/data-type/index.d.ts +0 -1
- package/src/data-type/index.js +0 -1
- package/src/data-type/infer-openapi-data-type.d.ts +0 -30
- package/src/data-type/infer-openapi-data-type.js +0 -38
- package/src/data-validation/data-format-validator-map.d.ts +0 -13
- package/src/data-validation/data-format-validator-map.js +0 -36
- package/src/data-validation/data-format-validator-map.spec.js +0 -39
- package/src/data-validation/data-format-validators.d.ts +0 -84
- package/src/data-validation/data-format-validators.js +0 -217
- package/src/data-validation/index.d.ts +0 -3
- package/src/data-validation/index.js +0 -3
- package/src/data-validation/validate-data-with-openapi-schema.d.ts +0 -46
- package/src/data-validation/validate-data-with-openapi-schema.js +0 -1913
- package/src/data-validation/validate-data-with-openapi-schema.spec.js +0 -6953
- package/src/errors/oa-data-validation-error.d.ts +0 -6
- package/src/errors/oa-data-validation-error.js +0 -6
- package/src/errors/oa-data-validation-error.spec.js +0 -17
- package/src/oa-document-object/validate-shallow-oa-document.d.ts +0 -10
- package/src/oa-document-object/validate-shallow-oa-document.js +0 -209
- package/src/oa-document-object/validate-shallow-oa-document.spec.js +0 -362
- package/src/utils/count-unicode.d.ts +0 -11
- package/src/utils/count-unicode.js +0 -15
- package/src/utils/index.d.ts +0 -5
- package/src/utils/index.js +0 -5
- package/src/utils/join-path.d.ts +0 -6
- package/src/utils/join-path.js +0 -36
- package/src/utils/join-path.spec.js +0 -104
- package/src/utils/normalize-path.d.ts +0 -12
- package/src/utils/normalize-path.js +0 -22
- package/src/utils/normalize-path.spec.js +0 -56
- package/src/utils/to-pascal-case.d.ts +0 -6
- package/src/utils/to-pascal-case.js +0 -26
- package/src/utils/to-pascal-case.spec.js +0 -15
- package/src/utils/to-spaced-json.d.ts +0 -17
- package/src/utils/to-spaced-json.js +0 -27
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
// OpenApi version 3.1.
|
|
2
|
-
// https://spec.openapis.org/oas/v3.1.
|
|
1
|
+
// OpenApi version 3.1.2
|
|
2
|
+
// https://spec.openapis.org/oas/v3.1.2
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* OpenAPI version.
|
|
6
6
|
*/
|
|
7
|
-
export declare const OPENAPI_VERSION: '3.1.
|
|
7
|
+
export declare const OPENAPI_VERSION: '3.1.2';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* Document
|
|
11
|
-
* https://spec.openapis.org/oas/v3.1.
|
|
10
|
+
* Document Object.
|
|
11
|
+
* https://spec.openapis.org/oas/v3.1.2#openapi-object
|
|
12
12
|
*/
|
|
13
13
|
export type OADocumentObject = {
|
|
14
14
|
openapi: string;
|
|
@@ -25,7 +25,7 @@ export type OADocumentObject = {
|
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* Info Object.
|
|
28
|
-
* https://spec.openapis.org/oas/v3.1.
|
|
28
|
+
* https://spec.openapis.org/oas/v3.1.2#info-object
|
|
29
29
|
*/
|
|
30
30
|
export type OAInfoObject = {
|
|
31
31
|
title: string;
|
|
@@ -39,7 +39,7 @@ export type OAInfoObject = {
|
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
41
|
* Contact Object.
|
|
42
|
-
* https://spec.openapis.org/oas/v3.1.
|
|
42
|
+
* https://spec.openapis.org/oas/v3.1.2#contact-object
|
|
43
43
|
*/
|
|
44
44
|
export type OAContactObject = {
|
|
45
45
|
name?: string;
|
|
@@ -49,7 +49,7 @@ export type OAContactObject = {
|
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
51
|
* License Object.
|
|
52
|
-
* https://spec.openapis.org/oas/v3.1.
|
|
52
|
+
* https://spec.openapis.org/oas/v3.1.2#license-object
|
|
53
53
|
*/
|
|
54
54
|
export type OALicenseObject = {
|
|
55
55
|
name: string;
|
|
@@ -59,7 +59,7 @@ export type OALicenseObject = {
|
|
|
59
59
|
|
|
60
60
|
/**
|
|
61
61
|
* Server Object.
|
|
62
|
-
* https://spec.openapis.org/oas/v3.1.
|
|
62
|
+
* https://spec.openapis.org/oas/v3.1.2#server-object
|
|
63
63
|
*/
|
|
64
64
|
export type OAServerObject = {
|
|
65
65
|
url: string;
|
|
@@ -69,7 +69,7 @@ export type OAServerObject = {
|
|
|
69
69
|
|
|
70
70
|
/**
|
|
71
71
|
* Server variable object.
|
|
72
|
-
* https://spec.openapis.org/oas/v3.1.
|
|
72
|
+
* https://spec.openapis.org/oas/v3.1.2#server-variable-object
|
|
73
73
|
*/
|
|
74
74
|
export type OAServerVariableObject = {
|
|
75
75
|
enum?: string[];
|
|
@@ -79,7 +79,7 @@ export type OAServerVariableObject = {
|
|
|
79
79
|
|
|
80
80
|
/**
|
|
81
81
|
* Paths Object.
|
|
82
|
-
* https://spec.openapis.org/oas/v3.1.
|
|
82
|
+
* https://spec.openapis.org/oas/v3.1.2#paths-object
|
|
83
83
|
*/
|
|
84
84
|
export type OAPathsObject = {
|
|
85
85
|
[path: string]: OAPathItemObject | undefined;
|
|
@@ -87,7 +87,7 @@ export type OAPathsObject = {
|
|
|
87
87
|
|
|
88
88
|
/**
|
|
89
89
|
* Path Item Object
|
|
90
|
-
* https://spec.openapis.org/oas/v3.1.
|
|
90
|
+
* https://spec.openapis.org/oas/v3.1.2#path-item-object
|
|
91
91
|
*/
|
|
92
92
|
export type OAPathItemObject = {
|
|
93
93
|
$ref?: string;
|
|
@@ -107,7 +107,7 @@ export type OAPathItemObject = {
|
|
|
107
107
|
|
|
108
108
|
/**
|
|
109
109
|
* Operation Method.
|
|
110
|
-
* https://spec.openapis.org/oas/v3.1.
|
|
110
|
+
* https://spec.openapis.org/oas/v3.1.2#path-item-object
|
|
111
111
|
*/
|
|
112
112
|
export declare const OAOperationMethod: {
|
|
113
113
|
GET: 'get';
|
|
@@ -122,14 +122,14 @@ export declare const OAOperationMethod: {
|
|
|
122
122
|
|
|
123
123
|
/**
|
|
124
124
|
* Operation Method.
|
|
125
|
-
* https://spec.openapis.org/oas/v3.1.
|
|
125
|
+
* https://spec.openapis.org/oas/v3.1.2#path-item-object
|
|
126
126
|
*/
|
|
127
127
|
export type OAOperationMethod =
|
|
128
128
|
(typeof OAOperationMethod)[keyof typeof OAOperationMethod];
|
|
129
129
|
|
|
130
130
|
/**
|
|
131
131
|
* Parameter Object.
|
|
132
|
-
* https://spec.openapis.org/oas/v3.1.
|
|
132
|
+
* https://spec.openapis.org/oas/v3.1.2#parameter-object
|
|
133
133
|
*/
|
|
134
134
|
export type OAParameterObject = {
|
|
135
135
|
name: string;
|
|
@@ -149,7 +149,7 @@ export type OAParameterObject = {
|
|
|
149
149
|
|
|
150
150
|
/**
|
|
151
151
|
* Parameter Location.
|
|
152
|
-
* https://spec.openapis.org/oas/v3.1.
|
|
152
|
+
* https://spec.openapis.org/oas/v3.1.2#parameter-locations
|
|
153
153
|
*/
|
|
154
154
|
export declare const OAParameterLocation: {
|
|
155
155
|
QUERY: 'query';
|
|
@@ -160,14 +160,14 @@ export declare const OAParameterLocation: {
|
|
|
160
160
|
|
|
161
161
|
/**
|
|
162
162
|
* Parameter Location.
|
|
163
|
-
* https://spec.openapis.org/oas/v3.1.
|
|
163
|
+
* https://spec.openapis.org/oas/v3.1.2#parameter-locations
|
|
164
164
|
*/
|
|
165
165
|
export type OAParameterLocation =
|
|
166
166
|
(typeof OAParameterLocation)[keyof typeof OAParameterLocation];
|
|
167
167
|
|
|
168
168
|
/**
|
|
169
169
|
* Parameter Style.
|
|
170
|
-
* https://spec.openapis.org/oas/v3.1.
|
|
170
|
+
* https://spec.openapis.org/oas/v3.1.2#style-values
|
|
171
171
|
*/
|
|
172
172
|
export declare const OAParameterStyle: {
|
|
173
173
|
MATRIX: 'matrix';
|
|
@@ -181,14 +181,14 @@ export declare const OAParameterStyle: {
|
|
|
181
181
|
|
|
182
182
|
/**
|
|
183
183
|
* Parameter Style.
|
|
184
|
-
* https://spec.openapis.org/oas/v3.1.
|
|
184
|
+
* https://spec.openapis.org/oas/v3.1.2#style-values
|
|
185
185
|
*/
|
|
186
186
|
export type OAParameterStyle =
|
|
187
187
|
(typeof OAParameterStyle)[keyof typeof OAParameterStyle];
|
|
188
188
|
|
|
189
189
|
/**
|
|
190
190
|
* Reference Object.
|
|
191
|
-
* https://spec.openapis.org/oas/v3.1.
|
|
191
|
+
* https://spec.openapis.org/oas/v3.1.2#reference-object
|
|
192
192
|
*/
|
|
193
193
|
export type OAReferenceObject = {
|
|
194
194
|
$ref: string;
|
|
@@ -204,7 +204,7 @@ export type OABooleanSchema = boolean;
|
|
|
204
204
|
|
|
205
205
|
/**
|
|
206
206
|
* Schema Object.
|
|
207
|
-
* https://spec.openapis.org/oas/v3.1.
|
|
207
|
+
* https://spec.openapis.org/oas/v3.1.2#schema-object
|
|
208
208
|
* https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-01
|
|
209
209
|
* https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-validation-01#name-table-of-contents-2
|
|
210
210
|
*/
|
|
@@ -302,15 +302,9 @@ export declare const OADataType: {
|
|
|
302
302
|
*/
|
|
303
303
|
export type OADataType = (typeof OADataType)[keyof typeof OADataType];
|
|
304
304
|
|
|
305
|
-
/**
|
|
306
|
-
* Data type list.
|
|
307
|
-
* https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-00#section-4.2.1
|
|
308
|
-
*/
|
|
309
|
-
export declare const OA_DATA_TYPE_LIST: OADataType[];
|
|
310
|
-
|
|
311
305
|
/**
|
|
312
306
|
* Data format.
|
|
313
|
-
* https://spec.openapis.org/oas/v3.1.
|
|
307
|
+
* https://spec.openapis.org/oas/v3.1.2#dataTypeFormat
|
|
314
308
|
*/
|
|
315
309
|
export declare const OADataFormat: {
|
|
316
310
|
// number
|
|
@@ -347,13 +341,13 @@ export declare const OADataFormat: {
|
|
|
347
341
|
|
|
348
342
|
/**
|
|
349
343
|
* Data format.
|
|
350
|
-
* https://spec.openapis.org/oas/v3.1.
|
|
344
|
+
* https://spec.openapis.org/oas/v3.1.2#dataTypeFormat
|
|
351
345
|
*/
|
|
352
346
|
export type OADataFormat = (typeof OADataFormat)[keyof typeof OADataFormat];
|
|
353
347
|
|
|
354
348
|
/**
|
|
355
349
|
* Discriminator Object.
|
|
356
|
-
* https://spec.openapis.org/oas/v3.1.
|
|
350
|
+
* https://spec.openapis.org/oas/v3.1.2#discriminator-object
|
|
357
351
|
*/
|
|
358
352
|
export type OADiscriminatorObject = {
|
|
359
353
|
propertyName: string;
|
|
@@ -362,7 +356,7 @@ export type OADiscriminatorObject = {
|
|
|
362
356
|
|
|
363
357
|
/**
|
|
364
358
|
* Xml Object.
|
|
365
|
-
* https://spec.openapis.org/oas/v3.1.
|
|
359
|
+
* https://spec.openapis.org/oas/v3.1.2#xml-object
|
|
366
360
|
*/
|
|
367
361
|
export type OAXmlObject = {
|
|
368
362
|
name?: string;
|
|
@@ -374,7 +368,7 @@ export type OAXmlObject = {
|
|
|
374
368
|
|
|
375
369
|
/**
|
|
376
370
|
* External Documentation Object.
|
|
377
|
-
* https://spec.openapis.org/oas/v3.1.
|
|
371
|
+
* https://spec.openapis.org/oas/v3.1.2#external-documentation-object
|
|
378
372
|
*/
|
|
379
373
|
export type OAExternalDocumentationObject = {
|
|
380
374
|
description?: string;
|
|
@@ -383,7 +377,7 @@ export type OAExternalDocumentationObject = {
|
|
|
383
377
|
|
|
384
378
|
/**
|
|
385
379
|
* Operation Object.
|
|
386
|
-
* https://spec.openapis.org/oas/v3.1.
|
|
380
|
+
* https://spec.openapis.org/oas/v3.1.2#operation-object
|
|
387
381
|
*/
|
|
388
382
|
export type OAOperationObject = {
|
|
389
383
|
tags?: string[];
|
|
@@ -402,7 +396,7 @@ export type OAOperationObject = {
|
|
|
402
396
|
|
|
403
397
|
/**
|
|
404
398
|
* Callback Object.
|
|
405
|
-
* https://spec.openapis.org/oas/v3.1.
|
|
399
|
+
* https://spec.openapis.org/oas/v3.1.2#callback-object
|
|
406
400
|
*/
|
|
407
401
|
export type OACallbackObject = {
|
|
408
402
|
[expression: string]: OAPathItemObject | OAReferenceObject | undefined;
|
|
@@ -410,7 +404,7 @@ export type OACallbackObject = {
|
|
|
410
404
|
|
|
411
405
|
/**
|
|
412
406
|
* Request Body Object.
|
|
413
|
-
* https://spec.openapis.org/oas/v3.1.
|
|
407
|
+
* https://spec.openapis.org/oas/v3.1.2#request-body-object
|
|
414
408
|
*/
|
|
415
409
|
export type OARequestBodyObject = {
|
|
416
410
|
description?: string;
|
|
@@ -420,25 +414,26 @@ export type OARequestBodyObject = {
|
|
|
420
414
|
|
|
421
415
|
/**
|
|
422
416
|
* Media type.
|
|
423
|
-
* https://spec.openapis.org/oas/v3.1.
|
|
417
|
+
* https://spec.openapis.org/oas/v3.1.2#media-types
|
|
424
418
|
*/
|
|
425
419
|
export declare const OAMediaType: {
|
|
426
420
|
TEXT_PLAIN: 'text/plain';
|
|
427
421
|
TEXT_HTML: 'text/html';
|
|
428
422
|
APPLICATION_XML: 'application/xml';
|
|
429
423
|
APPLICATION_JSON: 'application/json';
|
|
424
|
+
APPLICATION_OCTET_STREAM: 'application/octet-stream';
|
|
430
425
|
MULTIPART_FORM_DATA: 'multipart/form-data';
|
|
431
426
|
};
|
|
432
427
|
|
|
433
428
|
/**
|
|
434
429
|
* Media type.
|
|
435
|
-
* https://spec.openapis.org/oas/v3.1.
|
|
430
|
+
* https://spec.openapis.org/oas/v3.1.2#media-types
|
|
436
431
|
*/
|
|
437
432
|
export type OAMediaType = (typeof OAMediaType)[keyof typeof OAMediaType];
|
|
438
433
|
|
|
439
434
|
/**
|
|
440
435
|
* Responses Object.
|
|
441
|
-
* https://spec.openapis.org/oas/v3.1.
|
|
436
|
+
* https://spec.openapis.org/oas/v3.1.2#responses-object
|
|
442
437
|
*/
|
|
443
438
|
export type OAResponsesObject = {
|
|
444
439
|
[httpStatusCode: string]: OAResponseObject | OAReferenceObject | undefined;
|
|
@@ -446,7 +441,7 @@ export type OAResponsesObject = {
|
|
|
446
441
|
|
|
447
442
|
/**
|
|
448
443
|
* Response Object.
|
|
449
|
-
* https://spec.openapis.org/oas/v3.1.
|
|
444
|
+
* https://spec.openapis.org/oas/v3.1.2#response-object
|
|
450
445
|
*/
|
|
451
446
|
export type OAResponseObject = {
|
|
452
447
|
description: string;
|
|
@@ -457,7 +452,7 @@ export type OAResponseObject = {
|
|
|
457
452
|
|
|
458
453
|
/**
|
|
459
454
|
* Media Type Object.
|
|
460
|
-
* https://spec.openapis.org/oas/v3.1.
|
|
455
|
+
* https://spec.openapis.org/oas/v3.1.2#media-type-object
|
|
461
456
|
*/
|
|
462
457
|
export type OAMediaTypeObject = {
|
|
463
458
|
schema?: OABooleanSchema | OASchemaObject | OAReferenceObject;
|
|
@@ -468,7 +463,7 @@ export type OAMediaTypeObject = {
|
|
|
468
463
|
|
|
469
464
|
/**
|
|
470
465
|
* Example Object.
|
|
471
|
-
* https://spec.openapis.org/oas/v3.1.
|
|
466
|
+
* https://spec.openapis.org/oas/v3.1.2#example-object
|
|
472
467
|
*/
|
|
473
468
|
export type OAExampleObject = {
|
|
474
469
|
summary?: string;
|
|
@@ -479,7 +474,7 @@ export type OAExampleObject = {
|
|
|
479
474
|
|
|
480
475
|
/**
|
|
481
476
|
* Encoding Object.
|
|
482
|
-
* https://spec.openapis.org/oas/v3.1.
|
|
477
|
+
* https://spec.openapis.org/oas/v3.1.2#encoding-object
|
|
483
478
|
*/
|
|
484
479
|
export type OAEncodingObject = {
|
|
485
480
|
contentType?: string;
|
|
@@ -491,7 +486,7 @@ export type OAEncodingObject = {
|
|
|
491
486
|
|
|
492
487
|
/**
|
|
493
488
|
* Header Object.
|
|
494
|
-
* https://spec.openapis.org/oas/v3.1.
|
|
489
|
+
* https://spec.openapis.org/oas/v3.1.2#header-object
|
|
495
490
|
*/
|
|
496
491
|
export type OAHeaderObject = Omit<
|
|
497
492
|
OAParameterObject,
|
|
@@ -500,7 +495,7 @@ export type OAHeaderObject = Omit<
|
|
|
500
495
|
|
|
501
496
|
/**
|
|
502
497
|
* Link Object.
|
|
503
|
-
* https://spec.openapis.org/oas/v3.1.
|
|
498
|
+
* https://spec.openapis.org/oas/v3.1.2#link-object
|
|
504
499
|
*/
|
|
505
500
|
export type OALinkObject = {
|
|
506
501
|
operationRef?: string;
|
|
@@ -513,7 +508,7 @@ export type OALinkObject = {
|
|
|
513
508
|
|
|
514
509
|
/**
|
|
515
510
|
* Components Object.
|
|
516
|
-
* https://spec.openapis.org/oas/v3.1.
|
|
511
|
+
* https://spec.openapis.org/oas/v3.1.2#components-object
|
|
517
512
|
*/
|
|
518
513
|
export type OAComponentsObject = {
|
|
519
514
|
schemas?: {[name: string]: OABooleanSchema | OASchemaObject | undefined};
|
|
@@ -548,7 +543,7 @@ export type OAComponentsObject = {
|
|
|
548
543
|
|
|
549
544
|
/**
|
|
550
545
|
* Security Scheme Object.
|
|
551
|
-
* https://spec.openapis.org/oas/v3.1.
|
|
546
|
+
* https://spec.openapis.org/oas/v3.1.2#security-scheme-object
|
|
552
547
|
*/
|
|
553
548
|
export type OASecuritySchemeObject = {
|
|
554
549
|
type: OASecuritySchemeType;
|
|
@@ -563,7 +558,7 @@ export type OASecuritySchemeObject = {
|
|
|
563
558
|
|
|
564
559
|
/**
|
|
565
560
|
* Security Scheme Type.
|
|
566
|
-
* https://spec.openapis.org/oas/v3.1.
|
|
561
|
+
* https://spec.openapis.org/oas/v3.1.2#security-scheme-object
|
|
567
562
|
*/
|
|
568
563
|
export declare const OASecuritySchemeType: {
|
|
569
564
|
API_KEY: 'apiKey';
|
|
@@ -575,14 +570,14 @@ export declare const OASecuritySchemeType: {
|
|
|
575
570
|
|
|
576
571
|
/**
|
|
577
572
|
* Security Scheme Type.
|
|
578
|
-
* https://spec.openapis.org/oas/v3.1.
|
|
573
|
+
* https://spec.openapis.org/oas/v3.1.2#security-scheme-object
|
|
579
574
|
*/
|
|
580
575
|
export type OASecuritySchemeType =
|
|
581
576
|
(typeof OASecuritySchemeType)[keyof typeof OASecuritySchemeType];
|
|
582
577
|
|
|
583
578
|
/**
|
|
584
579
|
* Api Key Location.
|
|
585
|
-
* https://spec.openapis.org/oas/v3.1.
|
|
580
|
+
* https://spec.openapis.org/oas/v3.1.2#security-scheme-object
|
|
586
581
|
*/
|
|
587
582
|
export declare const OAApiKeyLocation: {
|
|
588
583
|
QUERY: 'query';
|
|
@@ -592,14 +587,14 @@ export declare const OAApiKeyLocation: {
|
|
|
592
587
|
|
|
593
588
|
/**
|
|
594
589
|
* Api Key Location.
|
|
595
|
-
* https://spec.openapis.org/oas/v3.1.
|
|
590
|
+
* https://spec.openapis.org/oas/v3.1.2#security-scheme-object
|
|
596
591
|
*/
|
|
597
592
|
export type OAApiKeyLocation =
|
|
598
593
|
(typeof OAApiKeyLocation)[keyof typeof OAApiKeyLocation];
|
|
599
594
|
|
|
600
595
|
/**
|
|
601
596
|
* OAuth Flows Object.
|
|
602
|
-
* https://spec.openapis.org/oas/v3.1.
|
|
597
|
+
* https://spec.openapis.org/oas/v3.1.2#oauth-flows-object
|
|
603
598
|
*/
|
|
604
599
|
export type OAOAuthFlowsObject = {
|
|
605
600
|
implicit?: OAOAuthFlowObject;
|
|
@@ -610,7 +605,7 @@ export type OAOAuthFlowsObject = {
|
|
|
610
605
|
|
|
611
606
|
/**
|
|
612
607
|
* OAuth Flow Object.
|
|
613
|
-
* https://spec.openapis.org/oas/v3.1.
|
|
608
|
+
* https://spec.openapis.org/oas/v3.1.2#oauth-flow-object
|
|
614
609
|
*/
|
|
615
610
|
export type OAOAuthFlowObject = {
|
|
616
611
|
authorizationUrl?: string;
|
|
@@ -621,15 +616,15 @@ export type OAOAuthFlowObject = {
|
|
|
621
616
|
|
|
622
617
|
/**
|
|
623
618
|
* Security Requirement Object.
|
|
624
|
-
* https://spec.openapis.org/oas/v3.1.
|
|
619
|
+
* https://spec.openapis.org/oas/v3.1.2#security-requirement-object
|
|
625
620
|
*/
|
|
626
621
|
export type OASecurityRequirementObject = {
|
|
627
622
|
[name: string]: string[] | undefined;
|
|
628
623
|
};
|
|
629
624
|
|
|
630
625
|
/**
|
|
631
|
-
* Tag
|
|
632
|
-
* https://spec.openapis.org/oas/v3.1.
|
|
626
|
+
* Tag Object.
|
|
627
|
+
* https://spec.openapis.org/oas/v3.1.2#tag-object
|
|
633
628
|
*/
|
|
634
629
|
export type OATagObject = {
|
|
635
630
|
name: string;
|
|
@@ -685,10 +680,12 @@ export declare const OAAccessMode: {
|
|
|
685
680
|
export type OAAccessMode = (typeof OAAccessMode)[keyof typeof OAAccessMode];
|
|
686
681
|
|
|
687
682
|
/**
|
|
688
|
-
*
|
|
689
|
-
* https://
|
|
683
|
+
* Webhooks Object.
|
|
684
|
+
* https://spec.openapis.org/oas/v3.1.2#oasWebhooks
|
|
690
685
|
*/
|
|
691
|
-
export
|
|
686
|
+
export type OAWebhooksObject = {
|
|
687
|
+
[name: string]: OAPathItemObject | OAReferenceObject | undefined;
|
|
688
|
+
};
|
|
692
689
|
|
|
693
690
|
/**
|
|
694
691
|
* Server Variables Object.
|
|
@@ -710,14 +707,6 @@ export type OASchemaPropertiesObject = {
|
|
|
710
707
|
| undefined;
|
|
711
708
|
};
|
|
712
709
|
|
|
713
|
-
/**
|
|
714
|
-
* Webhooks Object.
|
|
715
|
-
* (non-spec type)
|
|
716
|
-
*/
|
|
717
|
-
export type OAWebhooksObject = {
|
|
718
|
-
[name: string]: OAPathItemObject | OAReferenceObject | undefined;
|
|
719
|
-
};
|
|
720
|
-
|
|
721
710
|
/**
|
|
722
711
|
* Callbacks Object.
|
|
723
712
|
* (non-spec type)
|
package/src/oa-specification.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
// OpenApi version 3.1.
|
|
2
|
-
// https://spec.openapis.org/oas/v3.1.
|
|
1
|
+
// OpenApi version 3.1.2
|
|
2
|
+
// https://spec.openapis.org/oas/v3.1.2
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* OpenAPI version.
|
|
6
6
|
*/
|
|
7
|
-
export const OPENAPI_VERSION = '3.1.
|
|
7
|
+
export const OPENAPI_VERSION = '3.1.2';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Operation Method.
|
|
11
|
-
* https://spec.openapis.org/oas/v3.1.
|
|
11
|
+
* https://spec.openapis.org/oas/v3.1.2#path-item-object
|
|
12
12
|
*/
|
|
13
13
|
export const OAOperationMethod = {
|
|
14
14
|
GET: 'get',
|
|
@@ -23,7 +23,7 @@ export const OAOperationMethod = {
|
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* Parameter Location.
|
|
26
|
-
* https://spec.openapis.org/oas/v3.1.
|
|
26
|
+
* https://spec.openapis.org/oas/v3.1.2#parameter-locations
|
|
27
27
|
*/
|
|
28
28
|
export const OAParameterLocation = {
|
|
29
29
|
QUERY: 'query',
|
|
@@ -34,7 +34,7 @@ export const OAParameterLocation = {
|
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
* Parameter Style.
|
|
37
|
-
* https://spec.openapis.org/oas/v3.1.
|
|
37
|
+
* https://spec.openapis.org/oas/v3.1.2#style-values
|
|
38
38
|
*/
|
|
39
39
|
export const OAParameterStyle = {
|
|
40
40
|
MATRIX: 'matrix',
|
|
@@ -60,15 +60,9 @@ export const OADataType = {
|
|
|
60
60
|
NULL: 'null',
|
|
61
61
|
};
|
|
62
62
|
|
|
63
|
-
/**
|
|
64
|
-
* Data type list.
|
|
65
|
-
* https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-00#section-4.2.1
|
|
66
|
-
*/
|
|
67
|
-
export const OA_DATA_TYPE_LIST = Object.values(OADataType);
|
|
68
|
-
|
|
69
63
|
/**
|
|
70
64
|
* Data format.
|
|
71
|
-
* https://spec.openapis.org/oas/v3.1.
|
|
65
|
+
* https://spec.openapis.org/oas/v3.1.2#dataTypeFormat
|
|
72
66
|
*/
|
|
73
67
|
export const OADataFormat = {
|
|
74
68
|
// number
|
|
@@ -105,19 +99,20 @@ export const OADataFormat = {
|
|
|
105
99
|
|
|
106
100
|
/**
|
|
107
101
|
* Media type.
|
|
108
|
-
* https://spec.openapis.org/oas/v3.1.
|
|
102
|
+
* https://spec.openapis.org/oas/v3.1.2#media-types
|
|
109
103
|
*/
|
|
110
104
|
export const OAMediaType = {
|
|
111
105
|
TEXT_PLAIN: 'text/plain',
|
|
112
106
|
TEXT_HTML: 'text/html',
|
|
113
107
|
APPLICATION_XML: 'application/xml',
|
|
114
108
|
APPLICATION_JSON: 'application/json',
|
|
109
|
+
APPLICATION_OCTET_STREAM: 'application/octet-stream',
|
|
115
110
|
MULTIPART_FORM_DATA: 'multipart/form-data',
|
|
116
111
|
};
|
|
117
112
|
|
|
118
113
|
/**
|
|
119
114
|
* Security Scheme Type.
|
|
120
|
-
* https://spec.openapis.org/oas/v3.1.
|
|
115
|
+
* https://spec.openapis.org/oas/v3.1.2#security-scheme-object
|
|
121
116
|
*/
|
|
122
117
|
export const OASecuritySchemeType = {
|
|
123
118
|
API_KEY: 'apiKey',
|
|
@@ -129,7 +124,7 @@ export const OASecuritySchemeType = {
|
|
|
129
124
|
|
|
130
125
|
/**
|
|
131
126
|
* Api Key Location.
|
|
132
|
-
* https://spec.openapis.org/oas/v3.1.
|
|
127
|
+
* https://spec.openapis.org/oas/v3.1.2#security-scheme-object
|
|
133
128
|
*/
|
|
134
129
|
export const OAApiKeyLocation = {
|
|
135
130
|
QUERY: 'query',
|
|
@@ -145,9 +140,3 @@ export const OAAccessMode = {
|
|
|
145
140
|
READ: 'read',
|
|
146
141
|
WRITE: 'write',
|
|
147
142
|
};
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* Access mode list.
|
|
151
|
-
* https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-validation-01#name-readonly-and-writeonly
|
|
152
|
-
*/
|
|
153
|
-
export const ACCESS_MODE_LIST = Object.values(OAAccessMode);
|
package/src/data-type/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './infer-openapi-data-type.js';
|
package/src/data-type/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './infer-openapi-data-type.js';
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import {OADataType} from '../oa-specification.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Infer OpenAPI data type.
|
|
5
|
-
*
|
|
6
|
-
* @param data
|
|
7
|
-
*/
|
|
8
|
-
export function inferOpenApiDataType(data: unknown): OADataType;
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Infer OpenAPI data type.
|
|
12
|
-
*
|
|
13
|
-
* @param data
|
|
14
|
-
* @param returnJsTypeOnFail
|
|
15
|
-
*/
|
|
16
|
-
export function inferOpenApiDataType(
|
|
17
|
-
data: unknown,
|
|
18
|
-
returnJsTypeOnFail: true,
|
|
19
|
-
): OADataType | string;
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Infer OpenAPI data type.
|
|
23
|
-
*
|
|
24
|
-
* @param data
|
|
25
|
-
* @param returnJsTypeOnFail
|
|
26
|
-
*/
|
|
27
|
-
export function inferOpenApiDataType(
|
|
28
|
-
data: unknown,
|
|
29
|
-
returnJsTypeOnFail?: boolean,
|
|
30
|
-
): OADataType | string;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import {InvalidArgumentError} from '@e22m4u/js-format';
|
|
2
|
-
import {OADataType} from '../oa-specification.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Infer OpenAPI data type.
|
|
6
|
-
*
|
|
7
|
-
* @param {*} data
|
|
8
|
-
* @param {boolean} [returnJsTypeOnFail]
|
|
9
|
-
* @returns {OADataType}
|
|
10
|
-
*/
|
|
11
|
-
export function inferOpenApiDataType(data, returnJsTypeOnFail = false) {
|
|
12
|
-
if (data === null) {
|
|
13
|
-
return OADataType.NULL;
|
|
14
|
-
}
|
|
15
|
-
if (Array.isArray(data)) {
|
|
16
|
-
return OADataType.ARRAY;
|
|
17
|
-
}
|
|
18
|
-
const jsType = typeof data;
|
|
19
|
-
switch (jsType) {
|
|
20
|
-
case 'string':
|
|
21
|
-
return OADataType.STRING;
|
|
22
|
-
case 'boolean':
|
|
23
|
-
return OADataType.BOOLEAN;
|
|
24
|
-
case 'number':
|
|
25
|
-
return Number.isInteger(data) ? OADataType.INTEGER : OADataType.NUMBER;
|
|
26
|
-
case 'bigint':
|
|
27
|
-
return OADataType.INTEGER;
|
|
28
|
-
case 'object':
|
|
29
|
-
return OADataType.OBJECT;
|
|
30
|
-
}
|
|
31
|
-
if (returnJsTypeOnFail === true) {
|
|
32
|
-
return jsType;
|
|
33
|
-
}
|
|
34
|
-
throw new InvalidArgumentError(
|
|
35
|
-
'Unable to infer the data type from %v value.',
|
|
36
|
-
data,
|
|
37
|
-
);
|
|
38
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import {OADataFormatValidator} from './data-format-validators.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Data format validator map.
|
|
5
|
-
*/
|
|
6
|
-
export type OADataFormatValidatorMap = {
|
|
7
|
-
[format: string]: OADataFormatValidator | undefined;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Built-in data format validator map.
|
|
12
|
-
*/
|
|
13
|
-
export declare const OA_BUILT_IN_DATA_FORMAT_VALIDATOR_MAP: OADataFormatValidatorMap;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import {OADataFormat} from '../oa-specification.js';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
validateUriFormat,
|
|
5
|
-
validateIpv4Format,
|
|
6
|
-
validateIpv6Format,
|
|
7
|
-
validateUuidFormat,
|
|
8
|
-
validateByteFormat,
|
|
9
|
-
validateDateFormat,
|
|
10
|
-
validateInt32Format,
|
|
11
|
-
validateFloatFormat,
|
|
12
|
-
validateInt64Format,
|
|
13
|
-
validateEmailFormat,
|
|
14
|
-
validateDoubleFormat,
|
|
15
|
-
validateDateTimeFormat,
|
|
16
|
-
validateHostnameFormat,
|
|
17
|
-
} from './data-format-validators.js';
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Built-in data format validator map.
|
|
21
|
-
*/
|
|
22
|
-
export const OA_BUILT_IN_DATA_FORMAT_VALIDATOR_MAP = {
|
|
23
|
-
[OADataFormat.INT32]: validateInt32Format,
|
|
24
|
-
[OADataFormat.INT64]: validateInt64Format,
|
|
25
|
-
[OADataFormat.FLOAT]: validateFloatFormat,
|
|
26
|
-
[OADataFormat.DOUBLE]: validateDoubleFormat,
|
|
27
|
-
[OADataFormat.DATE]: validateDateFormat,
|
|
28
|
-
[OADataFormat.DATE_TIME]: validateDateTimeFormat,
|
|
29
|
-
[OADataFormat.BYTE]: validateByteFormat,
|
|
30
|
-
[OADataFormat.EMAIL]: validateEmailFormat,
|
|
31
|
-
[OADataFormat.UUID]: validateUuidFormat,
|
|
32
|
-
[OADataFormat.HOSTNAME]: validateHostnameFormat,
|
|
33
|
-
[OADataFormat.IPV4]: validateIpv4Format,
|
|
34
|
-
[OADataFormat.IPV6]: validateIpv6Format,
|
|
35
|
-
[OADataFormat.URI]: validateUriFormat,
|
|
36
|
-
};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import {expect} from 'chai';
|
|
2
|
-
import {OADataFormat} from '../oa-specification.js';
|
|
3
|
-
import {OA_BUILT_IN_DATA_FORMAT_VALIDATOR_MAP} from './data-format-validator-map.js';
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
validateUriFormat,
|
|
7
|
-
validateIpv4Format,
|
|
8
|
-
validateIpv6Format,
|
|
9
|
-
validateUuidFormat,
|
|
10
|
-
validateByteFormat,
|
|
11
|
-
validateDateFormat,
|
|
12
|
-
validateInt32Format,
|
|
13
|
-
validateFloatFormat,
|
|
14
|
-
validateInt64Format,
|
|
15
|
-
validateEmailFormat,
|
|
16
|
-
validateDoubleFormat,
|
|
17
|
-
validateDateTimeFormat,
|
|
18
|
-
validateHostnameFormat,
|
|
19
|
-
} from './data-format-validators.js';
|
|
20
|
-
|
|
21
|
-
describe('OA_BUILT_IN_DATA_FORMAT_VALIDATOR_MAP', function () {
|
|
22
|
-
it('should map data formats to its corresponding validator function', function () {
|
|
23
|
-
expect(OA_BUILT_IN_DATA_FORMAT_VALIDATOR_MAP).to.be.eql({
|
|
24
|
-
[OADataFormat.INT32]: validateInt32Format,
|
|
25
|
-
[OADataFormat.INT64]: validateInt64Format,
|
|
26
|
-
[OADataFormat.FLOAT]: validateFloatFormat,
|
|
27
|
-
[OADataFormat.DOUBLE]: validateDoubleFormat,
|
|
28
|
-
[OADataFormat.DATE]: validateDateFormat,
|
|
29
|
-
[OADataFormat.DATE_TIME]: validateDateTimeFormat,
|
|
30
|
-
[OADataFormat.BYTE]: validateByteFormat,
|
|
31
|
-
[OADataFormat.EMAIL]: validateEmailFormat,
|
|
32
|
-
[OADataFormat.UUID]: validateUuidFormat,
|
|
33
|
-
[OADataFormat.HOSTNAME]: validateHostnameFormat,
|
|
34
|
-
[OADataFormat.IPV4]: validateIpv4Format,
|
|
35
|
-
[OADataFormat.IPV6]: validateIpv6Format,
|
|
36
|
-
[OADataFormat.URI]: validateUriFormat,
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
});
|