@swagger-api/apidom-ns-json-schema-draft-6 0.68.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +156 -0
- package/LICENSES/Apache-2.0.txt +202 -0
- package/LICENSES/MIT.txt +9 -0
- package/NOTICE +57 -0
- package/README.md +189 -0
- package/cjs/elements/JSONSchema.cjs +115 -0
- package/cjs/elements/LinkDescription.cjs +57 -0
- package/cjs/index.cjs +52 -0
- package/cjs/media-types.cjs +24 -0
- package/cjs/namespace.cjs +22 -0
- package/cjs/predicates.cjs +27 -0
- package/cjs/refractor/index.cjs +49 -0
- package/cjs/refractor/plugins/replace-empty-element.cjs +223 -0
- package/cjs/refractor/registration.cjs +13 -0
- package/cjs/refractor/specification.cjs +21 -0
- package/cjs/refractor/toolbox.cjs +23 -0
- package/cjs/refractor/visitors/json-schema/$idVisitor.cjs +8 -0
- package/cjs/refractor/visitors/json-schema/ConstVisitor.cjs +8 -0
- package/cjs/refractor/visitors/json-schema/ExamplesVisitor.cjs +19 -0
- package/cjs/refractor/visitors/json-schema/ItemsVisitor.cjs +34 -0
- package/cjs/refractor/visitors/json-schema/index.cjs +30 -0
- package/cjs/refractor/visitors/json-schema/link-description/SubmissionEncTypeVisitor.cjs +8 -0
- package/cjs/refractor/visitors/json-schema/link-description/index.cjs +19 -0
- package/cjs/traversal/visitor.cjs +21 -0
- package/dist/apidom-ns-json-schema-draft-6.browser.js +1 -0
- package/es/elements/JSONSchema.js +111 -0
- package/es/elements/LinkDescription.js +52 -0
- package/es/index.js +14 -0
- package/es/media-types.js +18 -0
- package/es/namespace.js +16 -0
- package/es/predicates.js +18 -0
- package/es/refractor/index.js +44 -0
- package/es/refractor/plugins/replace-empty-element.js +215 -0
- package/es/refractor/registration.js +6 -0
- package/es/refractor/specification.js +15 -0
- package/es/refractor/toolbox.js +17 -0
- package/es/refractor/visitors/json-schema/$idVisitor.js +3 -0
- package/es/refractor/visitors/json-schema/ConstVisitor.js +3 -0
- package/es/refractor/visitors/json-schema/ExamplesVisitor.js +13 -0
- package/es/refractor/visitors/json-schema/ItemsVisitor.js +28 -0
- package/es/refractor/visitors/json-schema/index.js +24 -0
- package/es/refractor/visitors/json-schema/link-description/SubmissionEncTypeVisitor.js +3 -0
- package/es/refractor/visitors/json-schema/link-description/index.js +13 -0
- package/es/traversal/visitor.js +18 -0
- package/package.json +63 -0
- package/types/dist.d.ts +290 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.default = void 0;
|
|
5
|
+
var _apidomNsJsonSchemaDraft = require("@swagger-api/apidom-ns-json-schema-draft-4");
|
|
6
|
+
/* eslint-disable class-methods-use-this */
|
|
7
|
+
|
|
8
|
+
class JSONSchema extends _apidomNsJsonSchemaDraft.JSONSchemaElement {
|
|
9
|
+
constructor(content, meta, attributes) {
|
|
10
|
+
super(content, meta, attributes);
|
|
11
|
+
this.element = 'JSONSchemaDraft6';
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Core vocabulary
|
|
16
|
+
*
|
|
17
|
+
* URI: https://datatracker.ietf.org/doc/html/draft-wright-json-schema-01
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
get idProp() {
|
|
21
|
+
throw new Error('id keyword from Core vocabulary has been renamed to $id.');
|
|
22
|
+
}
|
|
23
|
+
set idProp(id) {
|
|
24
|
+
throw new Error('id keyword from Core vocabulary has been renamed to $id.');
|
|
25
|
+
}
|
|
26
|
+
get $id() {
|
|
27
|
+
return this.get('$id');
|
|
28
|
+
}
|
|
29
|
+
set $id($id) {
|
|
30
|
+
this.set('$id', $id);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Validation vocabulary
|
|
35
|
+
*
|
|
36
|
+
* URI: https://datatracker.ietf.org/doc/html/draft-wright-json-schema-validation-01
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Validation keywords for numeric instances (number and integer)
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
get exclusiveMaximum() {
|
|
44
|
+
return this.get('exclusiveMaximum');
|
|
45
|
+
}
|
|
46
|
+
set exclusiveMaximum(exclusiveMaximum) {
|
|
47
|
+
this.set('exclusiveMaximum', exclusiveMaximum);
|
|
48
|
+
}
|
|
49
|
+
get exclusiveMinimum() {
|
|
50
|
+
return this.get('exclusiveMinimum');
|
|
51
|
+
}
|
|
52
|
+
set exclusiveMinimum(exclusiveMinimum) {
|
|
53
|
+
this.set('exclusiveMinimum', exclusiveMinimum);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Validation keywords for arrays
|
|
58
|
+
*/
|
|
59
|
+
|
|
60
|
+
get containsProp() {
|
|
61
|
+
return this.get('contains');
|
|
62
|
+
}
|
|
63
|
+
set containsProp(contains) {
|
|
64
|
+
this.set('contains', contains);
|
|
65
|
+
}
|
|
66
|
+
get items() {
|
|
67
|
+
return this.get('items');
|
|
68
|
+
}
|
|
69
|
+
set items(items) {
|
|
70
|
+
this.set('items', items);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Validation keywords for objects
|
|
75
|
+
*/
|
|
76
|
+
|
|
77
|
+
get propertyNames() {
|
|
78
|
+
return this.get('propertyNames');
|
|
79
|
+
}
|
|
80
|
+
set propertyNames(propertyNames) {
|
|
81
|
+
this.set('propertyNames', propertyNames);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Validation keywords for any instance type
|
|
86
|
+
*/
|
|
87
|
+
|
|
88
|
+
get const() {
|
|
89
|
+
return this.get('const');
|
|
90
|
+
}
|
|
91
|
+
set const(constValue) {
|
|
92
|
+
this.set('const', constValue);
|
|
93
|
+
}
|
|
94
|
+
get not() {
|
|
95
|
+
return this.get('not');
|
|
96
|
+
}
|
|
97
|
+
set not(not) {
|
|
98
|
+
this.set('not', not);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Metadata keywords
|
|
103
|
+
*
|
|
104
|
+
* URI: https://datatracker.ietf.org/doc/html/draft-wright-json-schema-validation-01#section-7
|
|
105
|
+
*/
|
|
106
|
+
|
|
107
|
+
get examples() {
|
|
108
|
+
return this.get('examples');
|
|
109
|
+
}
|
|
110
|
+
set examples(examples) {
|
|
111
|
+
this.set('examples', examples);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
var _default = JSONSchema;
|
|
115
|
+
exports.default = _default;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.default = void 0;
|
|
5
|
+
var _apidomNsJsonSchemaDraft = require("@swagger-api/apidom-ns-json-schema-draft-4");
|
|
6
|
+
/* eslint-disable class-methods-use-this */
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* URI: https://datatracker.ietf.org/doc/html/draft-wright-json-schema-hyperschema-01#section-6
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
class LinkDescription extends _apidomNsJsonSchemaDraft.LinkDescriptionElement {
|
|
13
|
+
get hrefSchema() {
|
|
14
|
+
return this.get('hrefSchema');
|
|
15
|
+
}
|
|
16
|
+
set hrefSchema(hrefSchema) {
|
|
17
|
+
this.set('hrefSchema', hrefSchema);
|
|
18
|
+
}
|
|
19
|
+
get targetSchema() {
|
|
20
|
+
return this.get('targetSchema');
|
|
21
|
+
}
|
|
22
|
+
set targetSchema(targetSchema) {
|
|
23
|
+
this.set('targetSchema', targetSchema);
|
|
24
|
+
}
|
|
25
|
+
get schema() {
|
|
26
|
+
throw new Error('schema keyword from Hyper-Schema vocabulary has been renamed to submissionSchema.');
|
|
27
|
+
}
|
|
28
|
+
set schema(schema) {
|
|
29
|
+
throw new Error('schema keyword from Hyper-Schema vocabulary has been renamed to submissionSchema.');
|
|
30
|
+
}
|
|
31
|
+
get submissionSchema() {
|
|
32
|
+
return this.get('submissionSchema');
|
|
33
|
+
}
|
|
34
|
+
set submissionSchema(submissionSchema) {
|
|
35
|
+
this.set('submissionSchema', submissionSchema);
|
|
36
|
+
}
|
|
37
|
+
get method() {
|
|
38
|
+
throw new Error('method keyword from Hyper-Schema vocabulary has been removed.');
|
|
39
|
+
}
|
|
40
|
+
set method(method) {
|
|
41
|
+
throw new Error('method keyword from Hyper-Schema vocabulary has been removed.');
|
|
42
|
+
}
|
|
43
|
+
get encType() {
|
|
44
|
+
throw new Error('encType keyword from Hyper-Schema vocabulary has been renamed to submissionEncType.');
|
|
45
|
+
}
|
|
46
|
+
set encType(encType) {
|
|
47
|
+
throw new Error('encType keyword from Hyper-Schema vocabulary has been renamed to submissionEncType.');
|
|
48
|
+
}
|
|
49
|
+
get submissionEncType() {
|
|
50
|
+
return this.get('submissionEncType');
|
|
51
|
+
}
|
|
52
|
+
set submissionEncType(submissionEncType) {
|
|
53
|
+
this.set('submissionEncType', submissionEncType);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
var _default = LinkDescription;
|
|
57
|
+
exports.default = _default;
|
package/cjs/index.cjs
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
4
|
+
exports.__esModule = true;
|
|
5
|
+
exports.specificationObj = exports.refractorPluginReplaceEmptyElement = exports.refract = exports.mediaTypes = exports.keyMap = exports.isStringElement = exports.isRefElement = exports.isObjectElement = exports.isNumberElement = exports.isNullElement = exports.isMemberElement = exports.isMediaElement = exports.isLinkElement = exports.isLinkDescriptionElement = exports.isJSONSchemaElement = exports.isJSONReferenceLikeElement = exports.isJSONReferenceElement = exports.isElement = exports.isBooleanElement = exports.isArrayElement = exports.getNodeType = exports.default = exports.createRefractor = exports.SpecificationVisitor = exports.PatternedFieldsVisitor = exports.ParentSchemaAwareVisitor = exports.MediaElement = exports.MapVisitor = exports.LinkDescriptionElement = exports.JSONSchemaElement = exports.JSONSchemaDraft6MediaTypes = exports.JSONReferenceElement = exports.FixedFieldsVisitor = exports.FallbackVisitor = exports.AlternatingVisitor = void 0;
|
|
6
|
+
var _apidomCore = require("@swagger-api/apidom-core");
|
|
7
|
+
exports.isRefElement = _apidomCore.isRefElement;
|
|
8
|
+
exports.isLinkElement = _apidomCore.isLinkElement;
|
|
9
|
+
exports.isMemberElement = _apidomCore.isMemberElement;
|
|
10
|
+
exports.isObjectElement = _apidomCore.isObjectElement;
|
|
11
|
+
exports.isArrayElement = _apidomCore.isArrayElement;
|
|
12
|
+
exports.isBooleanElement = _apidomCore.isBooleanElement;
|
|
13
|
+
exports.isNullElement = _apidomCore.isNullElement;
|
|
14
|
+
exports.isElement = _apidomCore.isElement;
|
|
15
|
+
exports.isNumberElement = _apidomCore.isNumberElement;
|
|
16
|
+
exports.isStringElement = _apidomCore.isStringElement;
|
|
17
|
+
var _mediaTypes = _interopRequireWildcard(require("./media-types.cjs"));
|
|
18
|
+
exports.mediaTypes = _mediaTypes.default;
|
|
19
|
+
exports.JSONSchemaDraft6MediaTypes = _mediaTypes.JSONSchemaDraft6MediaTypes;
|
|
20
|
+
var _namespace = _interopRequireDefault(require("./namespace.cjs"));
|
|
21
|
+
exports.default = _namespace.default;
|
|
22
|
+
var _replaceEmptyElement = _interopRequireDefault(require("./refractor/plugins/replace-empty-element.cjs"));
|
|
23
|
+
exports.refractorPluginReplaceEmptyElement = _replaceEmptyElement.default;
|
|
24
|
+
var _index = _interopRequireWildcard(require("./refractor/index.cjs"));
|
|
25
|
+
exports.refract = _index.default;
|
|
26
|
+
exports.createRefractor = _index.createRefractor;
|
|
27
|
+
var _specification = _interopRequireDefault(require("./refractor/specification.cjs"));
|
|
28
|
+
exports.specificationObj = _specification.default;
|
|
29
|
+
var _predicates = require("./predicates.cjs");
|
|
30
|
+
exports.isJSONReferenceElement = _predicates.isJSONReferenceElement;
|
|
31
|
+
exports.isJSONSchemaElement = _predicates.isJSONSchemaElement;
|
|
32
|
+
exports.isLinkDescriptionElement = _predicates.isLinkDescriptionElement;
|
|
33
|
+
exports.isMediaElement = _predicates.isMediaElement;
|
|
34
|
+
var _apidomNsJsonSchemaDraft = require("@swagger-api/apidom-ns-json-schema-draft-4");
|
|
35
|
+
exports.isJSONReferenceLikeElement = _apidomNsJsonSchemaDraft.isJSONReferenceLikeElement;
|
|
36
|
+
exports.SpecificationVisitor = _apidomNsJsonSchemaDraft.SpecificationVisitor;
|
|
37
|
+
exports.FallbackVisitor = _apidomNsJsonSchemaDraft.FallbackVisitor;
|
|
38
|
+
exports.FixedFieldsVisitor = _apidomNsJsonSchemaDraft.FixedFieldsVisitor;
|
|
39
|
+
exports.PatternedFieldsVisitor = _apidomNsJsonSchemaDraft.PatternedFieldsVisitor;
|
|
40
|
+
exports.MapVisitor = _apidomNsJsonSchemaDraft.MapVisitor;
|
|
41
|
+
exports.AlternatingVisitor = _apidomNsJsonSchemaDraft.AlternatingVisitor;
|
|
42
|
+
exports.ParentSchemaAwareVisitor = _apidomNsJsonSchemaDraft.ParentSchemaAwareVisitor;
|
|
43
|
+
exports.JSONReferenceElement = _apidomNsJsonSchemaDraft.JSONReferenceElement;
|
|
44
|
+
exports.MediaElement = _apidomNsJsonSchemaDraft.MediaElement;
|
|
45
|
+
var _visitor = require("./traversal/visitor.cjs");
|
|
46
|
+
exports.keyMap = _visitor.keyMap;
|
|
47
|
+
exports.getNodeType = _visitor.getNodeType;
|
|
48
|
+
var _registration = require("./refractor/registration.cjs");
|
|
49
|
+
exports.JSONSchemaElement = _registration.JSONSchemaElement;
|
|
50
|
+
exports.LinkDescriptionElement = _registration.LinkDescriptionElement;
|
|
51
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
52
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.default = exports.JSONSchemaDraft6MediaTypes = void 0;
|
|
5
|
+
var _ramda = require("ramda");
|
|
6
|
+
var _apidomCore = require("@swagger-api/apidom-core");
|
|
7
|
+
class JSONSchemaDraft6MediaTypes extends _apidomCore.MediaTypes {
|
|
8
|
+
filterByFormat(format = 'generic') {
|
|
9
|
+
const effectiveFormat = format === 'generic' ? 'schema;version' : format;
|
|
10
|
+
return this.filter(mediaType => mediaType.includes(effectiveFormat));
|
|
11
|
+
}
|
|
12
|
+
findBy(version = 'draft-06', format = 'generic') {
|
|
13
|
+
const search = format === 'generic' ? `schema;version=${version}` : `schema+${format};version=${version}`;
|
|
14
|
+
const found = this.find(mediaType => mediaType.includes(search));
|
|
15
|
+
return found || this.unknownMediaType;
|
|
16
|
+
}
|
|
17
|
+
latest(format = 'generic') {
|
|
18
|
+
return (0, _ramda.last)(this.filterByFormat(format));
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.JSONSchemaDraft6MediaTypes = JSONSchemaDraft6MediaTypes;
|
|
22
|
+
const mediaTypes = new JSONSchemaDraft6MediaTypes('application/schema;version=draft-06', 'application/schema+json;version=draft-06', 'application/schema+yaml;version=draft-06');
|
|
23
|
+
var _default = mediaTypes;
|
|
24
|
+
exports.default = _default;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
4
|
+
exports.__esModule = true;
|
|
5
|
+
exports.default = void 0;
|
|
6
|
+
var _apidomNsJsonSchemaDraft = require("@swagger-api/apidom-ns-json-schema-draft-4");
|
|
7
|
+
var _JSONSchema = _interopRequireDefault(require("./elements/JSONSchema.cjs"));
|
|
8
|
+
var _LinkDescription = _interopRequireDefault(require("./elements/LinkDescription.cjs"));
|
|
9
|
+
const jsonSchemaDraft6 = {
|
|
10
|
+
namespace: options => {
|
|
11
|
+
const {
|
|
12
|
+
base
|
|
13
|
+
} = options;
|
|
14
|
+
base.register('jSONSchemaDraft6', _JSONSchema.default);
|
|
15
|
+
base.register('jSONReference', _apidomNsJsonSchemaDraft.JSONReferenceElement);
|
|
16
|
+
base.register('media', _apidomNsJsonSchemaDraft.MediaElement);
|
|
17
|
+
base.register('linkDescription', _LinkDescription.default);
|
|
18
|
+
return base;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
var _default = jsonSchemaDraft6;
|
|
22
|
+
exports.default = _default;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
4
|
+
exports.__esModule = true;
|
|
5
|
+
exports.isMediaElement = exports.isLinkDescriptionElement = exports.isJSONSchemaElement = exports.isJSONReferenceElement = void 0;
|
|
6
|
+
var _apidomCore = require("@swagger-api/apidom-core");
|
|
7
|
+
var _JSONSchema = _interopRequireDefault(require("./elements/JSONSchema.cjs"));
|
|
8
|
+
var _LinkDescription = _interopRequireDefault(require("./elements/LinkDescription.cjs"));
|
|
9
|
+
var _apidomNsJsonSchemaDraft = require("@swagger-api/apidom-ns-json-schema-draft-4");
|
|
10
|
+
exports.isJSONReferenceElement = _apidomNsJsonSchemaDraft.isJSONReferenceElement;
|
|
11
|
+
exports.isMediaElement = _apidomNsJsonSchemaDraft.isMediaElement;
|
|
12
|
+
const isJSONSchemaElement = (0, _apidomCore.createPredicate)(({
|
|
13
|
+
hasBasicElementProps,
|
|
14
|
+
isElementType,
|
|
15
|
+
primitiveEq
|
|
16
|
+
}) => {
|
|
17
|
+
return element => element instanceof _JSONSchema.default || hasBasicElementProps(element) && isElementType('JSONSchemaDraft6', element) && primitiveEq('object', element);
|
|
18
|
+
});
|
|
19
|
+
exports.isJSONSchemaElement = isJSONSchemaElement;
|
|
20
|
+
const isLinkDescriptionElement = (0, _apidomCore.createPredicate)(({
|
|
21
|
+
hasBasicElementProps,
|
|
22
|
+
isElementType,
|
|
23
|
+
primitiveEq
|
|
24
|
+
}) => {
|
|
25
|
+
return element => element instanceof _LinkDescription.default || hasBasicElementProps(element) && isElementType('linkDescription', element) && primitiveEq('object', element);
|
|
26
|
+
});
|
|
27
|
+
exports.isLinkDescriptionElement = isLinkDescriptionElement;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
4
|
+
exports.__esModule = true;
|
|
5
|
+
exports.default = exports.createRefractor = void 0;
|
|
6
|
+
var _ramdaAdjunct = require("ramda-adjunct");
|
|
7
|
+
var _apidomCore = require("@swagger-api/apidom-core");
|
|
8
|
+
var _specification = _interopRequireDefault(require("./specification.cjs"));
|
|
9
|
+
var _visitor = require("../traversal/visitor.cjs");
|
|
10
|
+
var _toolbox = _interopRequireDefault(require("./toolbox.cjs"));
|
|
11
|
+
const refract = (value, {
|
|
12
|
+
specPath = ['visitors', 'document', 'objects', 'JSONSchema', '$visitor'],
|
|
13
|
+
plugins = [],
|
|
14
|
+
specificationObj = _specification.default
|
|
15
|
+
} = {}) => {
|
|
16
|
+
const element = (0, _apidomCore.refract)(value);
|
|
17
|
+
const resolvedSpec = (0, _apidomCore.dereference)(specificationObj);
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* This is where generic ApiDOM becomes semantic (namespace applied).
|
|
21
|
+
* We don't allow consumers to hook into this translation.
|
|
22
|
+
* Though we allow consumers to define their onw plugins on already transformed ApiDOM.
|
|
23
|
+
*/
|
|
24
|
+
const rootVisitor = (0, _ramdaAdjunct.invokeArgs)(specPath, [], resolvedSpec);
|
|
25
|
+
// @ts-ignore
|
|
26
|
+
(0, _apidomCore.visit)(element, rootVisitor, {
|
|
27
|
+
state: {
|
|
28
|
+
specObj: resolvedSpec
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Running plugins visitors means extra single traversal === performance hit.
|
|
34
|
+
*/
|
|
35
|
+
return (0, _apidomCore.dispatchRefractorPlugins)(rootVisitor.element, plugins, {
|
|
36
|
+
toolboxCreator: _toolbox.default,
|
|
37
|
+
visitorOptions: {
|
|
38
|
+
keyMap: _visitor.keyMap,
|
|
39
|
+
nodeTypeGetter: _visitor.getNodeType
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
const createRefractor = specPath => (value, options = {}) => refract(value, {
|
|
44
|
+
specPath,
|
|
45
|
+
...options
|
|
46
|
+
});
|
|
47
|
+
exports.createRefractor = createRefractor;
|
|
48
|
+
var _default = refract;
|
|
49
|
+
exports.default = _default;
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
4
|
+
exports.__esModule = true;
|
|
5
|
+
exports.default = void 0;
|
|
6
|
+
var _apidomCore = require("@swagger-api/apidom-core");
|
|
7
|
+
var _apidomNsJsonSchemaDraft = require("@swagger-api/apidom-ns-json-schema-draft-4");
|
|
8
|
+
var _JSONSchema = _interopRequireDefault(require("../../elements/JSONSchema.cjs"));
|
|
9
|
+
var _LinkDescription = _interopRequireDefault(require("../../elements/LinkDescription.cjs"));
|
|
10
|
+
var _visitor = require("../../traversal/visitor.cjs");
|
|
11
|
+
/**
|
|
12
|
+
* JSON Schema Draft 6 specification elements.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* This plugin is specific to YAML 1.2 format, which allows defining key-value pairs
|
|
17
|
+
* with empty key, empty value, or both. If the value is not provided in YAML format,
|
|
18
|
+
* this plugin compensates for this missing value with the most appropriate semantic element type.
|
|
19
|
+
*
|
|
20
|
+
* https://yaml.org/spec/1.2.2/#72-empty-nodes
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
*
|
|
24
|
+
* ```yaml
|
|
25
|
+
* $schema: http://json-schema.org/draft-06/schema#
|
|
26
|
+
* items:
|
|
27
|
+
* ```
|
|
28
|
+
* Refracting result without this plugin:
|
|
29
|
+
*
|
|
30
|
+
* (JSONSchemaElement
|
|
31
|
+
* (MemberElement
|
|
32
|
+
* (StringElement)
|
|
33
|
+
* (StringElement))
|
|
34
|
+
* (MemberElement
|
|
35
|
+
* (StringElement)
|
|
36
|
+
* (StringElement))
|
|
37
|
+
*
|
|
38
|
+
* Refracting result with this plugin:
|
|
39
|
+
*
|
|
40
|
+
* (JSONSchemaElement
|
|
41
|
+
* (MemberElement
|
|
42
|
+
* (StringElement)
|
|
43
|
+
* (StringElement))
|
|
44
|
+
* (MemberElement
|
|
45
|
+
* (StringElement)
|
|
46
|
+
* (JSONSchemaElement))
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
const isEmptyElement = element => (0, _apidomCore.isStringElement)(element) && (0, _apidomCore.includesClasses)(['yaml-e-node', 'yaml-e-scalar'], element);
|
|
50
|
+
const schema = {
|
|
51
|
+
JSONSchemaDraft6Element: {
|
|
52
|
+
additionalItems(...args) {
|
|
53
|
+
return new _JSONSchema.default(...args);
|
|
54
|
+
},
|
|
55
|
+
items(...args) {
|
|
56
|
+
return new _JSONSchema.default(...args);
|
|
57
|
+
},
|
|
58
|
+
contains(...args) {
|
|
59
|
+
return new _JSONSchema.default(...args);
|
|
60
|
+
},
|
|
61
|
+
required(...args) {
|
|
62
|
+
const element = new _apidomCore.ArrayElement(...args);
|
|
63
|
+
element.classes.push('json-schema-required');
|
|
64
|
+
return element;
|
|
65
|
+
},
|
|
66
|
+
properties(...args) {
|
|
67
|
+
const element = new _apidomCore.ObjectElement(...args);
|
|
68
|
+
element.classes.push('json-schema-properties');
|
|
69
|
+
return element;
|
|
70
|
+
},
|
|
71
|
+
additionalProperties(...args) {
|
|
72
|
+
return new _JSONSchema.default(...args);
|
|
73
|
+
},
|
|
74
|
+
patternProperties(...args) {
|
|
75
|
+
const element = new _apidomCore.ObjectElement(...args);
|
|
76
|
+
element.classes.push('json-schema-patternProperties');
|
|
77
|
+
return element;
|
|
78
|
+
},
|
|
79
|
+
dependencies(...args) {
|
|
80
|
+
const element = new _apidomCore.ObjectElement(...args);
|
|
81
|
+
element.classes.push('json-schema-dependencies');
|
|
82
|
+
return element;
|
|
83
|
+
},
|
|
84
|
+
propertyNames(...args) {
|
|
85
|
+
return new _JSONSchema.default(...args);
|
|
86
|
+
},
|
|
87
|
+
enum(...args) {
|
|
88
|
+
const element = new _apidomCore.ArrayElement(...args);
|
|
89
|
+
element.classes.push('json-schema-enum');
|
|
90
|
+
return element;
|
|
91
|
+
},
|
|
92
|
+
allOf(...args) {
|
|
93
|
+
const element = new _apidomCore.ArrayElement(...args);
|
|
94
|
+
element.classes.push('json-schema-allOf');
|
|
95
|
+
return element;
|
|
96
|
+
},
|
|
97
|
+
anyOf(...args) {
|
|
98
|
+
const element = new _apidomCore.ArrayElement(...args);
|
|
99
|
+
element.classes.push('json-schema-anyOf');
|
|
100
|
+
return element;
|
|
101
|
+
},
|
|
102
|
+
oneOf(...args) {
|
|
103
|
+
const element = new _apidomCore.ArrayElement(...args);
|
|
104
|
+
element.classes.push('json-schema-oneOf');
|
|
105
|
+
return element;
|
|
106
|
+
},
|
|
107
|
+
not(...args) {
|
|
108
|
+
return new _JSONSchema.default(...args);
|
|
109
|
+
},
|
|
110
|
+
definitions(...args) {
|
|
111
|
+
const element = new _apidomCore.ObjectElement(...args);
|
|
112
|
+
element.classes.push('json-schema-definitions');
|
|
113
|
+
return element;
|
|
114
|
+
},
|
|
115
|
+
examples(...args) {
|
|
116
|
+
const element = new _apidomCore.ArrayElement(...args);
|
|
117
|
+
element.classes.push('json-schema-examples');
|
|
118
|
+
return element;
|
|
119
|
+
},
|
|
120
|
+
links(...args) {
|
|
121
|
+
const element = new _apidomCore.ArrayElement(...args);
|
|
122
|
+
element.classes.push('json-schema-links');
|
|
123
|
+
return element;
|
|
124
|
+
},
|
|
125
|
+
media(...args) {
|
|
126
|
+
return new _apidomNsJsonSchemaDraft.MediaElement(...args);
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
LinkDescriptionElement: {
|
|
130
|
+
hrefSchema(...args) {
|
|
131
|
+
return new _JSONSchema.default(...args);
|
|
132
|
+
},
|
|
133
|
+
targetSchema(...args) {
|
|
134
|
+
return new _JSONSchema.default(...args);
|
|
135
|
+
},
|
|
136
|
+
submissionSchema(...args) {
|
|
137
|
+
return new _JSONSchema.default(...args);
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
'json-schema-properties': {
|
|
141
|
+
'[key: *]': function key(...args) {
|
|
142
|
+
return new _JSONSchema.default(...args);
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
'json-schema-patternProperties': {
|
|
146
|
+
'[key: *]': function key(...args) {
|
|
147
|
+
return new _JSONSchema.default(...args);
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
'json-schema-dependencies': {
|
|
151
|
+
'[key: *]': function key(...args) {
|
|
152
|
+
return new _JSONSchema.default(...args);
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
'json-schema-allOf': {
|
|
156
|
+
'<*>': function asterisk(...args) {
|
|
157
|
+
return new _JSONSchema.default(...args);
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
'json-schema-anyOf': {
|
|
161
|
+
'<*>': function asterisk(...args) {
|
|
162
|
+
return new _JSONSchema.default(...args);
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
'json-schema-oneOf': {
|
|
166
|
+
'<*>': function asterisk(...args) {
|
|
167
|
+
return new _JSONSchema.default(...args);
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
'json-schema-definitions': {
|
|
171
|
+
'[key: *]': function key(...args) {
|
|
172
|
+
return new _JSONSchema.default(...args);
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
'json-schema-links': {
|
|
176
|
+
'<*>': function asterisk(...args) {
|
|
177
|
+
return new _LinkDescription.default(...args);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
const findElementFactory = (ancestor, keyName) => {
|
|
182
|
+
var _ancestor$classes$fir, _ancestor$classes$fir2;
|
|
183
|
+
const elementType = (0, _visitor.getNodeType)(ancestor); // @ts-ignore
|
|
184
|
+
const keyMapping = schema[elementType] || schema[(_ancestor$classes$fir = ancestor.classes.first) === null || _ancestor$classes$fir === void 0 ? void 0 : (_ancestor$classes$fir2 = _ancestor$classes$fir.toValue) === null || _ancestor$classes$fir2 === void 0 ? void 0 : _ancestor$classes$fir2.call(_ancestor$classes$fir)];
|
|
185
|
+
return typeof keyMapping === 'undefined' ? undefined : Object.prototype.hasOwnProperty.call(keyMapping, '[key: *]') ? keyMapping['[key: *]'] : keyMapping[keyName];
|
|
186
|
+
};
|
|
187
|
+
const plugin = () => () => {
|
|
188
|
+
return {
|
|
189
|
+
visitor: {
|
|
190
|
+
MemberElement(element, ...rest) {
|
|
191
|
+
// no empty Element, continue with next one
|
|
192
|
+
if (!isEmptyElement(element.value)) return undefined;
|
|
193
|
+
const [,,, ancestors] = rest;
|
|
194
|
+
const ancestor = ancestors[ancestors.length - 1]; // @ts-ignore
|
|
195
|
+
const elementFactory = findElementFactory(ancestor, element.key.toValue());
|
|
196
|
+
|
|
197
|
+
// no element factory found
|
|
198
|
+
if (typeof elementFactory === 'undefined') return undefined;
|
|
199
|
+
const originalValue = element.value;
|
|
200
|
+
return new _apidomCore.MemberElement(element.key, elementFactory.call({
|
|
201
|
+
context: ancestor
|
|
202
|
+
}, undefined, originalValue.meta.clone(), originalValue.attributes.clone()), element.meta.clone(), element.attributes.clone());
|
|
203
|
+
},
|
|
204
|
+
StringElement(element, ...rest) {
|
|
205
|
+
if (!isEmptyElement(element)) return undefined;
|
|
206
|
+
const [,,, ancestors] = rest;
|
|
207
|
+
const ancestor = ancestors[ancestors.length - 1];
|
|
208
|
+
|
|
209
|
+
// we're only interested in empty elements in ArrayElements
|
|
210
|
+
if (!(0, _apidomCore.isArrayElement)(ancestor)) return undefined;
|
|
211
|
+
const elementFactory = findElementFactory(ancestor, '<*>');
|
|
212
|
+
|
|
213
|
+
// no element factory found
|
|
214
|
+
if (typeof elementFactory === 'undefined') return undefined;
|
|
215
|
+
return elementFactory.call({
|
|
216
|
+
context: element
|
|
217
|
+
}, undefined, element.meta.clone(), element.attributes.clone());
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
};
|
|
222
|
+
var _default = plugin;
|
|
223
|
+
exports.default = _default;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
4
|
+
exports.__esModule = true;
|
|
5
|
+
var _JSONSchema = _interopRequireDefault(require("../elements/JSONSchema.cjs"));
|
|
6
|
+
exports.JSONSchemaElement = _JSONSchema.default;
|
|
7
|
+
var _LinkDescription = _interopRequireDefault(require("../elements/LinkDescription.cjs"));
|
|
8
|
+
exports.LinkDescriptionElement = _LinkDescription.default;
|
|
9
|
+
var _index = require("./index.cjs");
|
|
10
|
+
// register refractors specific to element types
|
|
11
|
+
|
|
12
|
+
_JSONSchema.default.refract = (0, _index.createRefractor)(['visitors', 'document', 'objects', 'JSONSchema', '$visitor']);
|
|
13
|
+
_LinkDescription.default.refract = (0, _index.createRefractor)(['visitors', 'document', 'objects', 'LinkDescription', '$visitor']);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
4
|
+
exports.__esModule = true;
|
|
5
|
+
exports.default = void 0;
|
|
6
|
+
var _ramda = require("ramda");
|
|
7
|
+
var _apidomNsJsonSchemaDraft = require("@swagger-api/apidom-ns-json-schema-draft-4");
|
|
8
|
+
var _index = _interopRequireDefault(require("./visitors/json-schema/index.cjs"));
|
|
9
|
+
var _$idVisitor = _interopRequireDefault(require("./visitors/json-schema/$idVisitor.cjs"));
|
|
10
|
+
var _ItemsVisitor = _interopRequireDefault(require("./visitors/json-schema/ItemsVisitor.cjs"));
|
|
11
|
+
var _ConstVisitor = _interopRequireDefault(require("./visitors/json-schema/ConstVisitor.cjs"));
|
|
12
|
+
var _ExamplesVisitor = _interopRequireDefault(require("./visitors/json-schema/ExamplesVisitor.cjs"));
|
|
13
|
+
var _index2 = _interopRequireDefault(require("./visitors/json-schema/link-description/index.cjs"));
|
|
14
|
+
var _SubmissionEncTypeVisitor = _interopRequireDefault(require("./visitors/json-schema/link-description/SubmissionEncTypeVisitor.cjs"));
|
|
15
|
+
const specification = (0, _ramda.pipe)(
|
|
16
|
+
// JSON Schema object modifications
|
|
17
|
+
(0, _ramda.assocPath)(['visitors', 'document', 'objects', 'JSONSchema', '$visitor'], _index.default), (0, _ramda.dissocPath)(['visitors', 'document', 'objects', 'JSONSchema', 'fixedFields', 'id']), (0, _ramda.assocPath)(['visitors', 'document', 'objects', 'JSONSchema', 'fixedFields', '$id'], _$idVisitor.default), (0, _ramda.assocPath)(['visitors', 'document', 'objects', 'JSONSchema', 'fixedFields', 'contains'], _apidomNsJsonSchemaDraft.specificationObj.visitors.JSONSchemaOrJSONReferenceVisitor), (0, _ramda.assocPath)(['visitors', 'document', 'objects', 'JSONSchema', 'fixedFields', 'items'], _ItemsVisitor.default), (0, _ramda.assocPath)(['visitors', 'document', 'objects', 'JSONSchema', 'fixedFields', 'propertyNames'], _apidomNsJsonSchemaDraft.specificationObj.visitors.JSONSchemaOrJSONReferenceVisitor), (0, _ramda.assocPath)(['visitors', 'document', 'objects', 'JSONSchema', 'fixedFields', 'const'], _ConstVisitor.default), (0, _ramda.assocPath)(['visitors', 'document', 'objects', 'JSONSchema', 'fixedFields', 'examples'], _ExamplesVisitor.default),
|
|
18
|
+
// Link Description object modifications
|
|
19
|
+
(0, _ramda.assocPath)(['visitors', 'document', 'objects', 'LinkDescription', '$visitor'], _index2.default), (0, _ramda.assocPath)(['visitors', 'document', 'objects', 'LinkDescription', 'fixedFields', 'hrefSchema'], _apidomNsJsonSchemaDraft.specificationObj.visitors.JSONSchemaOrJSONReferenceVisitor), (0, _ramda.dissocPath)(['visitors', 'document', 'objects', 'LinkDescription', 'fixedFields', 'schema']), (0, _ramda.assocPath)(['visitors', 'document', 'objects', 'LinkDescription', 'fixedFields', 'submissionSchema'], _apidomNsJsonSchemaDraft.specificationObj.visitors.JSONSchemaOrJSONReferenceVisitor), (0, _ramda.dissocPath)(['visitors', 'document', 'objects', 'LinkDescription', 'fixedFields', 'method']), (0, _ramda.dissocPath)(['visitors', 'document', 'objects', 'LinkDescription', 'fixedFields', 'encType']), (0, _ramda.assocPath)(['visitors', 'document', 'objects', 'LinkDescription', 'fixedFields', 'submissionEncType'], _SubmissionEncTypeVisitor.default))(_apidomNsJsonSchemaDraft.specificationObj);
|
|
20
|
+
var _default = specification;
|
|
21
|
+
exports.default = _default;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
4
|
+
exports.__esModule = true;
|
|
5
|
+
exports.default = void 0;
|
|
6
|
+
var _apidomCore = require("@swagger-api/apidom-core");
|
|
7
|
+
var jsonSchemaDraft6Predicates = _interopRequireWildcard(require("../predicates.cjs"));
|
|
8
|
+
var _namespace = _interopRequireDefault(require("../namespace.cjs"));
|
|
9
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
10
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
11
|
+
const createToolbox = () => {
|
|
12
|
+
const namespace = (0, _apidomCore.createNamespace)(_namespace.default);
|
|
13
|
+
const predicates = {
|
|
14
|
+
...jsonSchemaDraft6Predicates,
|
|
15
|
+
isStringElement: _apidomCore.isStringElement
|
|
16
|
+
};
|
|
17
|
+
return {
|
|
18
|
+
predicates,
|
|
19
|
+
namespace
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
var _default = createToolbox;
|
|
23
|
+
exports.default = _default;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.default = void 0;
|
|
5
|
+
var _apidomNsJsonSchemaDraft = require("@swagger-api/apidom-ns-json-schema-draft-4");
|
|
6
|
+
const $idVisitor = _apidomNsJsonSchemaDraft.FallbackVisitor;
|
|
7
|
+
var _default = $idVisitor;
|
|
8
|
+
exports.default = _default;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.default = void 0;
|
|
5
|
+
var _apidomNsJsonSchemaDraft = require("@swagger-api/apidom-ns-json-schema-draft-4");
|
|
6
|
+
const ConstVisitor = _apidomNsJsonSchemaDraft.FallbackVisitor;
|
|
7
|
+
var _default = ConstVisitor;
|
|
8
|
+
exports.default = _default;
|