@speclynx/apidom-ns-openapi-2 3.2.1 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (219) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/apidom-ns-openapi-2.browser.js +24 -20
  3. package/package.json +7 -7
  4. package/src/elements/Contact.cjs +0 -33
  5. package/src/elements/Contact.mjs +0 -30
  6. package/src/elements/Definitions.cjs +0 -15
  7. package/src/elements/Definitions.mjs +0 -12
  8. package/src/elements/Example.cjs +0 -15
  9. package/src/elements/Example.mjs +0 -12
  10. package/src/elements/ExternalDocumentation.cjs +0 -27
  11. package/src/elements/ExternalDocumentation.mjs +0 -24
  12. package/src/elements/Header.cjs +0 -185
  13. package/src/elements/Header.mjs +0 -182
  14. package/src/elements/Headers.cjs +0 -15
  15. package/src/elements/Headers.mjs +0 -12
  16. package/src/elements/Info.cjs +0 -52
  17. package/src/elements/Info.mjs +0 -48
  18. package/src/elements/Items.cjs +0 -190
  19. package/src/elements/Items.mjs +0 -187
  20. package/src/elements/License.cjs +0 -27
  21. package/src/elements/License.mjs +0 -24
  22. package/src/elements/Operation.cjs +0 -78
  23. package/src/elements/Operation.mjs +0 -74
  24. package/src/elements/Parameter.cjs +0 -230
  25. package/src/elements/Parameter.mjs +0 -226
  26. package/src/elements/ParametersDefinitions.cjs +0 -15
  27. package/src/elements/ParametersDefinitions.mjs +0 -12
  28. package/src/elements/PathItem.cjs +0 -69
  29. package/src/elements/PathItem.mjs +0 -65
  30. package/src/elements/Paths.cjs +0 -15
  31. package/src/elements/Paths.mjs +0 -12
  32. package/src/elements/Reference.cjs +0 -22
  33. package/src/elements/Reference.mjs +0 -19
  34. package/src/elements/Response.cjs +0 -39
  35. package/src/elements/Response.mjs +0 -35
  36. package/src/elements/Responses.cjs +0 -21
  37. package/src/elements/Responses.mjs +0 -17
  38. package/src/elements/ResponsesDefinitions.cjs +0 -15
  39. package/src/elements/ResponsesDefinitions.mjs +0 -12
  40. package/src/elements/Schema.cjs +0 -151
  41. package/src/elements/Schema.mjs +0 -147
  42. package/src/elements/Scopes.cjs +0 -15
  43. package/src/elements/Scopes.mjs +0 -12
  44. package/src/elements/SecurityDefinitions.cjs +0 -15
  45. package/src/elements/SecurityDefinitions.mjs +0 -12
  46. package/src/elements/SecurityRequirement.cjs +0 -15
  47. package/src/elements/SecurityRequirement.mjs +0 -12
  48. package/src/elements/SecurityScheme.cjs +0 -63
  49. package/src/elements/SecurityScheme.mjs +0 -60
  50. package/src/elements/Swagger.cjs +0 -106
  51. package/src/elements/Swagger.mjs +0 -102
  52. package/src/elements/SwaggerVersion.cjs +0 -17
  53. package/src/elements/SwaggerVersion.mjs +0 -14
  54. package/src/elements/Tag.cjs +0 -33
  55. package/src/elements/Tag.mjs +0 -29
  56. package/src/elements/Xml.cjs +0 -45
  57. package/src/elements/Xml.mjs +0 -42
  58. package/src/elements/nces/OperationConsumes.cjs +0 -16
  59. package/src/elements/nces/OperationConsumes.mjs +0 -13
  60. package/src/elements/nces/OperationParameters.cjs +0 -17
  61. package/src/elements/nces/OperationParameters.mjs +0 -14
  62. package/src/elements/nces/OperationProduces.cjs +0 -16
  63. package/src/elements/nces/OperationProduces.mjs +0 -13
  64. package/src/elements/nces/OperationSchemes.cjs +0 -16
  65. package/src/elements/nces/OperationSchemes.mjs +0 -13
  66. package/src/elements/nces/OperationSecurity.cjs +0 -17
  67. package/src/elements/nces/OperationSecurity.mjs +0 -14
  68. package/src/elements/nces/OperationTags.cjs +0 -17
  69. package/src/elements/nces/OperationTags.mjs +0 -14
  70. package/src/elements/nces/PathItemParameters.cjs +0 -17
  71. package/src/elements/nces/PathItemParameters.mjs +0 -14
  72. package/src/elements/nces/SwaggerConsumes.cjs +0 -16
  73. package/src/elements/nces/SwaggerConsumes.mjs +0 -13
  74. package/src/elements/nces/SwaggerProduces.cjs +0 -16
  75. package/src/elements/nces/SwaggerProduces.mjs +0 -13
  76. package/src/elements/nces/SwaggerSchemes.cjs +0 -16
  77. package/src/elements/nces/SwaggerSchemes.mjs +0 -13
  78. package/src/elements/nces/SwaggerSecurity.cjs +0 -17
  79. package/src/elements/nces/SwaggerSecurity.mjs +0 -14
  80. package/src/elements/nces/SwaggerTags.cjs +0 -16
  81. package/src/elements/nces/SwaggerTags.mjs +0 -13
  82. package/src/index.cjs +0 -156
  83. package/src/index.mjs +0 -32
  84. package/src/media-types.cjs +0 -34
  85. package/src/media-types.mjs +0 -30
  86. package/src/namespace.cjs +0 -71
  87. package/src/namespace.mjs +0 -66
  88. package/src/predicates.cjs +0 -193
  89. package/src/predicates.mjs +0 -161
  90. package/src/refractor/index.cjs +0 -316
  91. package/src/refractor/index.mjs +0 -283
  92. package/src/refractor/inspect.cjs +0 -157
  93. package/src/refractor/inspect.mjs +0 -126
  94. package/src/refractor/plugins/replace-empty-element.cjs +0 -366
  95. package/src/refractor/plugins/replace-empty-element.mjs +0 -358
  96. package/src/refractor/predicates.cjs +0 -26
  97. package/src/refractor/predicates.mjs +0 -21
  98. package/src/refractor/specification.cjs +0 -519
  99. package/src/refractor/specification.mjs +0 -513
  100. package/src/refractor/toolbox.cjs +0 -28
  101. package/src/refractor/toolbox.mjs +0 -21
  102. package/src/refractor/visitors/FallbackVisitor.cjs +0 -24
  103. package/src/refractor/visitors/FallbackVisitor.mjs +0 -18
  104. package/src/refractor/visitors/SpecificationExtensionVisitor.cjs +0 -18
  105. package/src/refractor/visitors/SpecificationExtensionVisitor.mjs +0 -13
  106. package/src/refractor/visitors/SpecificationVisitor.cjs +0 -75
  107. package/src/refractor/visitors/SpecificationVisitor.mjs +0 -69
  108. package/src/refractor/visitors/Visitor.cjs +0 -36
  109. package/src/refractor/visitors/Visitor.mjs +0 -33
  110. package/src/refractor/visitors/generics/AlternatingVisitor.cjs +0 -42
  111. package/src/refractor/visitors/generics/AlternatingVisitor.mjs +0 -35
  112. package/src/refractor/visitors/generics/FixedFieldsVisitor.cjs +0 -73
  113. package/src/refractor/visitors/generics/FixedFieldsVisitor.mjs +0 -66
  114. package/src/refractor/visitors/generics/MapVisitor.cjs +0 -21
  115. package/src/refractor/visitors/generics/MapVisitor.mjs +0 -15
  116. package/src/refractor/visitors/generics/MixedFieldsVisitor.cjs +0 -67
  117. package/src/refractor/visitors/generics/MixedFieldsVisitor.mjs +0 -61
  118. package/src/refractor/visitors/generics/PatternedFieldsVisitor.cjs +0 -72
  119. package/src/refractor/visitors/generics/PatternedFieldsVisitor.mjs +0 -66
  120. package/src/refractor/visitors/open-api-2/BasePathVisitor.cjs +0 -16
  121. package/src/refractor/visitors/open-api-2/BasePathVisitor.mjs +0 -11
  122. package/src/refractor/visitors/open-api-2/ConsumesVisitor.cjs +0 -23
  123. package/src/refractor/visitors/open-api-2/ConsumesVisitor.mjs +0 -18
  124. package/src/refractor/visitors/open-api-2/HostVisitor.cjs +0 -16
  125. package/src/refractor/visitors/open-api-2/HostVisitor.mjs +0 -11
  126. package/src/refractor/visitors/open-api-2/ProducesVisitor.cjs +0 -23
  127. package/src/refractor/visitors/open-api-2/ProducesVisitor.mjs +0 -18
  128. package/src/refractor/visitors/open-api-2/SchemesVisitor.cjs +0 -23
  129. package/src/refractor/visitors/open-api-2/SchemesVisitor.mjs +0 -18
  130. package/src/refractor/visitors/open-api-2/SecurityVisitor.cjs +0 -27
  131. package/src/refractor/visitors/open-api-2/SecurityVisitor.mjs +0 -22
  132. package/src/refractor/visitors/open-api-2/SwaggerVisitor.cjs +0 -21
  133. package/src/refractor/visitors/open-api-2/SwaggerVisitor.mjs +0 -16
  134. package/src/refractor/visitors/open-api-2/TagsVisitor.cjs +0 -27
  135. package/src/refractor/visitors/open-api-2/TagsVisitor.mjs +0 -22
  136. package/src/refractor/visitors/open-api-2/bases.cjs +0 -72
  137. package/src/refractor/visitors/open-api-2/bases.mjs +0 -67
  138. package/src/refractor/visitors/open-api-2/contact/index.cjs +0 -20
  139. package/src/refractor/visitors/open-api-2/contact/index.mjs +0 -15
  140. package/src/refractor/visitors/open-api-2/definitions/index.cjs +0 -31
  141. package/src/refractor/visitors/open-api-2/definitions/index.mjs +0 -26
  142. package/src/refractor/visitors/open-api-2/example/index.cjs +0 -20
  143. package/src/refractor/visitors/open-api-2/example/index.mjs +0 -15
  144. package/src/refractor/visitors/open-api-2/external-documentation/index.cjs +0 -20
  145. package/src/refractor/visitors/open-api-2/external-documentation/index.mjs +0 -15
  146. package/src/refractor/visitors/open-api-2/header/index.cjs +0 -20
  147. package/src/refractor/visitors/open-api-2/header/index.mjs +0 -15
  148. package/src/refractor/visitors/open-api-2/headers/index.cjs +0 -20
  149. package/src/refractor/visitors/open-api-2/headers/index.mjs +0 -15
  150. package/src/refractor/visitors/open-api-2/index.cjs +0 -21
  151. package/src/refractor/visitors/open-api-2/index.mjs +0 -16
  152. package/src/refractor/visitors/open-api-2/info/VersionVisitor.cjs +0 -17
  153. package/src/refractor/visitors/open-api-2/info/VersionVisitor.mjs +0 -12
  154. package/src/refractor/visitors/open-api-2/info/index.cjs +0 -20
  155. package/src/refractor/visitors/open-api-2/info/index.mjs +0 -15
  156. package/src/refractor/visitors/open-api-2/items/index.cjs +0 -22
  157. package/src/refractor/visitors/open-api-2/items/index.mjs +0 -17
  158. package/src/refractor/visitors/open-api-2/license/index.cjs +0 -20
  159. package/src/refractor/visitors/open-api-2/license/index.mjs +0 -15
  160. package/src/refractor/visitors/open-api-2/operation/ConsumesVisitor.cjs +0 -23
  161. package/src/refractor/visitors/open-api-2/operation/ConsumesVisitor.mjs +0 -18
  162. package/src/refractor/visitors/open-api-2/operation/ParametersVisitor.cjs +0 -32
  163. package/src/refractor/visitors/open-api-2/operation/ParametersVisitor.mjs +0 -27
  164. package/src/refractor/visitors/open-api-2/operation/ProducesVisitor.cjs +0 -23
  165. package/src/refractor/visitors/open-api-2/operation/ProducesVisitor.mjs +0 -18
  166. package/src/refractor/visitors/open-api-2/operation/SchemesVisitor.cjs +0 -23
  167. package/src/refractor/visitors/open-api-2/operation/SchemesVisitor.mjs +0 -18
  168. package/src/refractor/visitors/open-api-2/operation/SecurityVisitor.cjs +0 -27
  169. package/src/refractor/visitors/open-api-2/operation/SecurityVisitor.mjs +0 -22
  170. package/src/refractor/visitors/open-api-2/operation/TagsVisitor.cjs +0 -23
  171. package/src/refractor/visitors/open-api-2/operation/TagsVisitor.mjs +0 -18
  172. package/src/refractor/visitors/open-api-2/operation/index.cjs +0 -19
  173. package/src/refractor/visitors/open-api-2/operation/index.mjs +0 -14
  174. package/src/refractor/visitors/open-api-2/parameter/index.cjs +0 -20
  175. package/src/refractor/visitors/open-api-2/parameter/index.mjs +0 -15
  176. package/src/refractor/visitors/open-api-2/parameters-definitions/index.cjs +0 -19
  177. package/src/refractor/visitors/open-api-2/parameters-definitions/index.mjs +0 -14
  178. package/src/refractor/visitors/open-api-2/path-item/$RefVisitor.cjs +0 -16
  179. package/src/refractor/visitors/open-api-2/path-item/$RefVisitor.mjs +0 -11
  180. package/src/refractor/visitors/open-api-2/path-item/ParametersVisitor.cjs +0 -32
  181. package/src/refractor/visitors/open-api-2/path-item/ParametersVisitor.mjs +0 -27
  182. package/src/refractor/visitors/open-api-2/path-item/index.cjs +0 -39
  183. package/src/refractor/visitors/open-api-2/path-item/index.mjs +0 -34
  184. package/src/refractor/visitors/open-api-2/paths/index.cjs +0 -37
  185. package/src/refractor/visitors/open-api-2/paths/index.mjs +0 -32
  186. package/src/refractor/visitors/open-api-2/reference/$RefVisitor.cjs +0 -16
  187. package/src/refractor/visitors/open-api-2/reference/$RefVisitor.mjs +0 -11
  188. package/src/refractor/visitors/open-api-2/reference/index.cjs +0 -29
  189. package/src/refractor/visitors/open-api-2/reference/index.mjs +0 -24
  190. package/src/refractor/visitors/open-api-2/response/index.cjs +0 -20
  191. package/src/refractor/visitors/open-api-2/response/index.mjs +0 -15
  192. package/src/refractor/visitors/open-api-2/responses/DefaultVisitor.cjs +0 -36
  193. package/src/refractor/visitors/open-api-2/responses/DefaultVisitor.mjs +0 -31
  194. package/src/refractor/visitors/open-api-2/responses/index.cjs +0 -45
  195. package/src/refractor/visitors/open-api-2/responses/index.mjs +0 -40
  196. package/src/refractor/visitors/open-api-2/responses-definitions/index.cjs +0 -19
  197. package/src/refractor/visitors/open-api-2/responses-definitions/index.mjs +0 -14
  198. package/src/refractor/visitors/open-api-2/schema/AllOfVisitor.cjs +0 -24
  199. package/src/refractor/visitors/open-api-2/schema/AllOfVisitor.mjs +0 -20
  200. package/src/refractor/visitors/open-api-2/schema/ItemsVisitor.cjs +0 -26
  201. package/src/refractor/visitors/open-api-2/schema/ItemsVisitor.mjs +0 -23
  202. package/src/refractor/visitors/open-api-2/schema/PropertiesVisitor.cjs +0 -24
  203. package/src/refractor/visitors/open-api-2/schema/PropertiesVisitor.mjs +0 -20
  204. package/src/refractor/visitors/open-api-2/schema/SchemaOrJSONReferenceVisitor.cjs +0 -23
  205. package/src/refractor/visitors/open-api-2/schema/SchemaOrJSONReferenceVisitor.mjs +0 -19
  206. package/src/refractor/visitors/open-api-2/schema/index.cjs +0 -20
  207. package/src/refractor/visitors/open-api-2/schema/index.mjs +0 -15
  208. package/src/refractor/visitors/open-api-2/scopes/index.cjs +0 -20
  209. package/src/refractor/visitors/open-api-2/scopes/index.mjs +0 -15
  210. package/src/refractor/visitors/open-api-2/security-definitions/index.cjs +0 -20
  211. package/src/refractor/visitors/open-api-2/security-definitions/index.mjs +0 -15
  212. package/src/refractor/visitors/open-api-2/security-requirement/index.cjs +0 -19
  213. package/src/refractor/visitors/open-api-2/security-requirement/index.mjs +0 -14
  214. package/src/refractor/visitors/open-api-2/security-scheme/index.cjs +0 -20
  215. package/src/refractor/visitors/open-api-2/security-scheme/index.mjs +0 -15
  216. package/src/refractor/visitors/open-api-2/tag/index.cjs +0 -20
  217. package/src/refractor/visitors/open-api-2/tag/index.mjs +0 -15
  218. package/src/refractor/visitors/open-api-2/xml/index.cjs +0 -20
  219. package/src/refractor/visitors/open-api-2/xml/index.mjs +0 -15
@@ -1,316 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
4
- exports.__esModule = true;
5
- exports.refractXml = exports.refractTag = exports.refractSwagger = exports.refractSecurityScheme = exports.refractSecurityRequirement = exports.refractSecurityDefinitions = exports.refractScopes = exports.refractSchema = exports.refractResponsesDefinitions = exports.refractResponses = exports.refractResponse = exports.refractReference = exports.refractPaths = exports.refractPathItem = exports.refractParametersDefinitions = exports.refractParameter = exports.refractOperation = exports.refractLicense = exports.refractItems = exports.refractInfo = exports.refractHeaders = exports.refractHeader = exports.refractExternalDocumentation = exports.refractExample = exports.refractDefinitions = exports.refractContact = exports.default = void 0;
6
- var _apidomCore = require("@speclynx/apidom-core");
7
- var _apidomDatamodel = require("@speclynx/apidom-datamodel");
8
- var _apidomTraverse = require("@speclynx/apidom-traverse");
9
- var _ramda = require("ramda");
10
- var _specification = _interopRequireDefault(require("./specification.cjs"));
11
- var _toolbox = _interopRequireDefault(require("./toolbox.cjs"));
12
- /**
13
- * @public
14
- */
15
-
16
- /**
17
- * @public
18
- */
19
-
20
- /**
21
- * @public
22
- */
23
- const refract = (value, {
24
- element = 'swagger',
25
- plugins = [],
26
- specificationObj = _specification.default,
27
- consume = false
28
- } = {}) => {
29
- const genericElement = (0, _apidomDatamodel.refract)(value);
30
- const resolvedSpec = (0, _apidomCore.resolveSpecification)(specificationObj);
31
- const elementMap = resolvedSpec.elementMap;
32
- const specPath = elementMap[element];
33
- if (!specPath) {
34
- throw new Error(`Unknown element type: "${element}"`);
35
- }
36
-
37
- /**
38
- * This is where generic ApiDOM becomes semantic (namespace applied).
39
- * We don't allow consumers to hook into this translation.
40
- * Though we allow consumers to define their own plugins on already transformed ApiDOM.
41
- */
42
- const RootVisitorClass = (0, _ramda.path)(specPath, resolvedSpec);
43
- const rootVisitor = new RootVisitorClass({
44
- specObj: resolvedSpec,
45
- consume
46
- });
47
- (0, _apidomTraverse.traverse)(genericElement, rootVisitor);
48
-
49
- /**
50
- * Running plugins visitors means extra single traversal === performance hit.
51
- */
52
- return (0, _apidomCore.dispatchRefractorPlugins)(rootVisitor.element, plugins, {
53
- toolboxCreator: _toolbox.default
54
- });
55
- };
56
-
57
- /**
58
- * Refracts a value into a SwaggerElement.
59
- * @public
60
- */
61
- const refractSwagger = (value, options = {}) => refract(value, {
62
- ...options,
63
- element: 'swagger'
64
- });
65
-
66
- /**
67
- * Refracts a value into an InfoElement.
68
- * @public
69
- */
70
- exports.refractSwagger = refractSwagger;
71
- const refractInfo = (value, options = {}) => refract(value, {
72
- ...options,
73
- element: 'info'
74
- });
75
-
76
- /**
77
- * Refracts a value into a ContactElement.
78
- * @public
79
- */
80
- exports.refractInfo = refractInfo;
81
- const refractContact = (value, options = {}) => refract(value, {
82
- ...options,
83
- element: 'contact'
84
- });
85
-
86
- /**
87
- * Refracts a value into a LicenseElement.
88
- * @public
89
- */
90
- exports.refractContact = refractContact;
91
- const refractLicense = (value, options = {}) => refract(value, {
92
- ...options,
93
- element: 'license'
94
- });
95
-
96
- /**
97
- * Refracts a value into a PathsElement.
98
- * @public
99
- */
100
- exports.refractLicense = refractLicense;
101
- const refractPaths = (value, options = {}) => refract(value, {
102
- ...options,
103
- element: 'paths'
104
- });
105
-
106
- /**
107
- * Refracts a value into a PathItemElement.
108
- * @public
109
- */
110
- exports.refractPaths = refractPaths;
111
- const refractPathItem = (value, options = {}) => refract(value, {
112
- ...options,
113
- element: 'pathItem'
114
- });
115
-
116
- /**
117
- * Refracts a value into an OperationElement.
118
- * @public
119
- */
120
- exports.refractPathItem = refractPathItem;
121
- const refractOperation = (value, options = {}) => refract(value, {
122
- ...options,
123
- element: 'operation'
124
- });
125
-
126
- /**
127
- * Refracts a value into an ExternalDocumentationElement.
128
- * @public
129
- */
130
- exports.refractOperation = refractOperation;
131
- const refractExternalDocumentation = (value, options = {}) => refract(value, {
132
- ...options,
133
- element: 'externalDocumentation'
134
- });
135
-
136
- /**
137
- * Refracts a value into a ParameterElement.
138
- * @public
139
- */
140
- exports.refractExternalDocumentation = refractExternalDocumentation;
141
- const refractParameter = (value, options = {}) => refract(value, {
142
- ...options,
143
- element: 'parameter'
144
- });
145
-
146
- /**
147
- * Refracts a value into an ItemsElement.
148
- * @public
149
- */
150
- exports.refractParameter = refractParameter;
151
- const refractItems = (value, options = {}) => refract(value, {
152
- ...options,
153
- element: 'items'
154
- });
155
-
156
- /**
157
- * Refracts a value into a ResponsesElement.
158
- * @public
159
- */
160
- exports.refractItems = refractItems;
161
- const refractResponses = (value, options = {}) => refract(value, {
162
- ...options,
163
- element: 'responses'
164
- });
165
-
166
- /**
167
- * Refracts a value into a ResponseElement.
168
- * @public
169
- */
170
- exports.refractResponses = refractResponses;
171
- const refractResponse = (value, options = {}) => refract(value, {
172
- ...options,
173
- element: 'response'
174
- });
175
-
176
- /**
177
- * Refracts a value into a HeadersElement.
178
- * @public
179
- */
180
- exports.refractResponse = refractResponse;
181
- const refractHeaders = (value, options = {}) => refract(value, {
182
- ...options,
183
- element: 'headers'
184
- });
185
-
186
- /**
187
- * Refracts a value into an ExampleElement.
188
- * @public
189
- */
190
- exports.refractHeaders = refractHeaders;
191
- const refractExample = (value, options = {}) => refract(value, {
192
- ...options,
193
- element: 'example'
194
- });
195
-
196
- /**
197
- * Refracts a value into a HeaderElement.
198
- * @public
199
- */
200
- exports.refractExample = refractExample;
201
- const refractHeader = (value, options = {}) => refract(value, {
202
- ...options,
203
- element: 'header'
204
- });
205
-
206
- /**
207
- * Refracts a value into a TagElement.
208
- * @public
209
- */
210
- exports.refractHeader = refractHeader;
211
- const refractTag = (value, options = {}) => refract(value, {
212
- ...options,
213
- element: 'tag'
214
- });
215
-
216
- /**
217
- * Refracts a value into a ReferenceElement.
218
- * @public
219
- */
220
- exports.refractTag = refractTag;
221
- const refractReference = (value, options = {}) => refract(value, {
222
- ...options,
223
- element: 'reference'
224
- });
225
-
226
- /**
227
- * Refracts a value into a SchemaElement.
228
- * @public
229
- */
230
- exports.refractReference = refractReference;
231
- const refractSchema = (value, options = {}) => refract(value, {
232
- ...options,
233
- element: 'schema'
234
- });
235
-
236
- /**
237
- * Refracts a value into an XmlElement.
238
- * @public
239
- */
240
- exports.refractSchema = refractSchema;
241
- const refractXml = (value, options = {}) => refract(value, {
242
- ...options,
243
- element: 'xml'
244
- });
245
-
246
- /**
247
- * Refracts a value into a DefinitionsElement.
248
- * @public
249
- */
250
- exports.refractXml = refractXml;
251
- const refractDefinitions = (value, options = {}) => refract(value, {
252
- ...options,
253
- element: 'definitions'
254
- });
255
-
256
- /**
257
- * Refracts a value into a ParametersDefinitionsElement.
258
- * @public
259
- */
260
- exports.refractDefinitions = refractDefinitions;
261
- const refractParametersDefinitions = (value, options = {}) => refract(value, {
262
- ...options,
263
- element: 'parametersDefinitions'
264
- });
265
-
266
- /**
267
- * Refracts a value into a ResponsesDefinitionsElement.
268
- * @public
269
- */
270
- exports.refractParametersDefinitions = refractParametersDefinitions;
271
- const refractResponsesDefinitions = (value, options = {}) => refract(value, {
272
- ...options,
273
- element: 'responsesDefinitions'
274
- });
275
-
276
- /**
277
- * Refracts a value into a SecurityDefinitionsElement.
278
- * @public
279
- */
280
- exports.refractResponsesDefinitions = refractResponsesDefinitions;
281
- const refractSecurityDefinitions = (value, options = {}) => refract(value, {
282
- ...options,
283
- element: 'securityDefinitions'
284
- });
285
-
286
- /**
287
- * Refracts a value into a SecuritySchemeElement.
288
- * @public
289
- */
290
- exports.refractSecurityDefinitions = refractSecurityDefinitions;
291
- const refractSecurityScheme = (value, options = {}) => refract(value, {
292
- ...options,
293
- element: 'securityScheme'
294
- });
295
-
296
- /**
297
- * Refracts a value into a ScopesElement.
298
- * @public
299
- */
300
- exports.refractSecurityScheme = refractSecurityScheme;
301
- const refractScopes = (value, options = {}) => refract(value, {
302
- ...options,
303
- element: 'scopes'
304
- });
305
-
306
- /**
307
- * Refracts a value into a SecurityRequirementElement.
308
- * @public
309
- */
310
- exports.refractScopes = refractScopes;
311
- const refractSecurityRequirement = (value, options = {}) => refract(value, {
312
- ...options,
313
- element: 'securityRequirement'
314
- });
315
- exports.refractSecurityRequirement = refractSecurityRequirement;
316
- var _default = exports.default = refract;
@@ -1,283 +0,0 @@
1
- import { resolveSpecification, dispatchRefractorPlugins } from '@speclynx/apidom-core';
2
- import { refract as baseRefract } from '@speclynx/apidom-datamodel';
3
- import { traverse } from '@speclynx/apidom-traverse';
4
- import { path } from 'ramda';
5
- import specification from "./specification.mjs";
6
- import createToolbox from "./toolbox.mjs";
7
- /**
8
- * @public
9
- */
10
- /**
11
- * @public
12
- */
13
- /**
14
- * @public
15
- */
16
- const refract = (value, {
17
- element = 'swagger',
18
- plugins = [],
19
- specificationObj = specification,
20
- consume = false
21
- } = {}) => {
22
- const genericElement = baseRefract(value);
23
- const resolvedSpec = resolveSpecification(specificationObj);
24
- const elementMap = resolvedSpec.elementMap;
25
- const specPath = elementMap[element];
26
- if (!specPath) {
27
- throw new Error(`Unknown element type: "${element}"`);
28
- }
29
-
30
- /**
31
- * This is where generic ApiDOM becomes semantic (namespace applied).
32
- * We don't allow consumers to hook into this translation.
33
- * Though we allow consumers to define their own plugins on already transformed ApiDOM.
34
- */
35
- const RootVisitorClass = path(specPath, resolvedSpec);
36
- const rootVisitor = new RootVisitorClass({
37
- specObj: resolvedSpec,
38
- consume
39
- });
40
- traverse(genericElement, rootVisitor);
41
-
42
- /**
43
- * Running plugins visitors means extra single traversal === performance hit.
44
- */
45
- return dispatchRefractorPlugins(rootVisitor.element, plugins, {
46
- toolboxCreator: createToolbox
47
- });
48
- };
49
-
50
- /**
51
- * Refracts a value into a SwaggerElement.
52
- * @public
53
- */
54
- export const refractSwagger = (value, options = {}) => refract(value, {
55
- ...options,
56
- element: 'swagger'
57
- });
58
-
59
- /**
60
- * Refracts a value into an InfoElement.
61
- * @public
62
- */
63
- export const refractInfo = (value, options = {}) => refract(value, {
64
- ...options,
65
- element: 'info'
66
- });
67
-
68
- /**
69
- * Refracts a value into a ContactElement.
70
- * @public
71
- */
72
- export const refractContact = (value, options = {}) => refract(value, {
73
- ...options,
74
- element: 'contact'
75
- });
76
-
77
- /**
78
- * Refracts a value into a LicenseElement.
79
- * @public
80
- */
81
- export const refractLicense = (value, options = {}) => refract(value, {
82
- ...options,
83
- element: 'license'
84
- });
85
-
86
- /**
87
- * Refracts a value into a PathsElement.
88
- * @public
89
- */
90
- export const refractPaths = (value, options = {}) => refract(value, {
91
- ...options,
92
- element: 'paths'
93
- });
94
-
95
- /**
96
- * Refracts a value into a PathItemElement.
97
- * @public
98
- */
99
- export const refractPathItem = (value, options = {}) => refract(value, {
100
- ...options,
101
- element: 'pathItem'
102
- });
103
-
104
- /**
105
- * Refracts a value into an OperationElement.
106
- * @public
107
- */
108
- export const refractOperation = (value, options = {}) => refract(value, {
109
- ...options,
110
- element: 'operation'
111
- });
112
-
113
- /**
114
- * Refracts a value into an ExternalDocumentationElement.
115
- * @public
116
- */
117
- export const refractExternalDocumentation = (value, options = {}) => refract(value, {
118
- ...options,
119
- element: 'externalDocumentation'
120
- });
121
-
122
- /**
123
- * Refracts a value into a ParameterElement.
124
- * @public
125
- */
126
- export const refractParameter = (value, options = {}) => refract(value, {
127
- ...options,
128
- element: 'parameter'
129
- });
130
-
131
- /**
132
- * Refracts a value into an ItemsElement.
133
- * @public
134
- */
135
- export const refractItems = (value, options = {}) => refract(value, {
136
- ...options,
137
- element: 'items'
138
- });
139
-
140
- /**
141
- * Refracts a value into a ResponsesElement.
142
- * @public
143
- */
144
- export const refractResponses = (value, options = {}) => refract(value, {
145
- ...options,
146
- element: 'responses'
147
- });
148
-
149
- /**
150
- * Refracts a value into a ResponseElement.
151
- * @public
152
- */
153
- export const refractResponse = (value, options = {}) => refract(value, {
154
- ...options,
155
- element: 'response'
156
- });
157
-
158
- /**
159
- * Refracts a value into a HeadersElement.
160
- * @public
161
- */
162
- export const refractHeaders = (value, options = {}) => refract(value, {
163
- ...options,
164
- element: 'headers'
165
- });
166
-
167
- /**
168
- * Refracts a value into an ExampleElement.
169
- * @public
170
- */
171
- export const refractExample = (value, options = {}) => refract(value, {
172
- ...options,
173
- element: 'example'
174
- });
175
-
176
- /**
177
- * Refracts a value into a HeaderElement.
178
- * @public
179
- */
180
- export const refractHeader = (value, options = {}) => refract(value, {
181
- ...options,
182
- element: 'header'
183
- });
184
-
185
- /**
186
- * Refracts a value into a TagElement.
187
- * @public
188
- */
189
- export const refractTag = (value, options = {}) => refract(value, {
190
- ...options,
191
- element: 'tag'
192
- });
193
-
194
- /**
195
- * Refracts a value into a ReferenceElement.
196
- * @public
197
- */
198
- export const refractReference = (value, options = {}) => refract(value, {
199
- ...options,
200
- element: 'reference'
201
- });
202
-
203
- /**
204
- * Refracts a value into a SchemaElement.
205
- * @public
206
- */
207
- export const refractSchema = (value, options = {}) => refract(value, {
208
- ...options,
209
- element: 'schema'
210
- });
211
-
212
- /**
213
- * Refracts a value into an XmlElement.
214
- * @public
215
- */
216
- export const refractXml = (value, options = {}) => refract(value, {
217
- ...options,
218
- element: 'xml'
219
- });
220
-
221
- /**
222
- * Refracts a value into a DefinitionsElement.
223
- * @public
224
- */
225
- export const refractDefinitions = (value, options = {}) => refract(value, {
226
- ...options,
227
- element: 'definitions'
228
- });
229
-
230
- /**
231
- * Refracts a value into a ParametersDefinitionsElement.
232
- * @public
233
- */
234
- export const refractParametersDefinitions = (value, options = {}) => refract(value, {
235
- ...options,
236
- element: 'parametersDefinitions'
237
- });
238
-
239
- /**
240
- * Refracts a value into a ResponsesDefinitionsElement.
241
- * @public
242
- */
243
- export const refractResponsesDefinitions = (value, options = {}) => refract(value, {
244
- ...options,
245
- element: 'responsesDefinitions'
246
- });
247
-
248
- /**
249
- * Refracts a value into a SecurityDefinitionsElement.
250
- * @public
251
- */
252
- export const refractSecurityDefinitions = (value, options = {}) => refract(value, {
253
- ...options,
254
- element: 'securityDefinitions'
255
- });
256
-
257
- /**
258
- * Refracts a value into a SecuritySchemeElement.
259
- * @public
260
- */
261
- export const refractSecurityScheme = (value, options = {}) => refract(value, {
262
- ...options,
263
- element: 'securityScheme'
264
- });
265
-
266
- /**
267
- * Refracts a value into a ScopesElement.
268
- * @public
269
- */
270
- export const refractScopes = (value, options = {}) => refract(value, {
271
- ...options,
272
- element: 'scopes'
273
- });
274
-
275
- /**
276
- * Refracts a value into a SecurityRequirementElement.
277
- * @public
278
- */
279
- export const refractSecurityRequirement = (value, options = {}) => refract(value, {
280
- ...options,
281
- element: 'securityRequirement'
282
- });
283
- export default refract;