@speclynx/apidom-ns-openapi-2 4.1.0 → 4.2.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.
- package/CHANGELOG.md +6 -0
- package/README.md +122 -0
- package/dist/apidom-ns-openapi-2.browser.js +538 -166
- package/dist/apidom-ns-openapi-2.browser.min.js +1 -1
- package/package.json +8 -7
- package/src/index.cjs +8 -2
- package/src/index.mjs +3 -0
- package/src/refractor/plugins/normalize-parameters.cjs +108 -0
- package/src/refractor/plugins/normalize-parameters.mjs +102 -0
- package/src/refractor/plugins/normalize-security-requirements.cjs +87 -0
- package/src/refractor/plugins/normalize-security-requirements.mjs +81 -0
- package/src/refractor/plugins/normalize-storage/index.cjs +38 -0
- package/src/refractor/plugins/normalize-storage/index.mjs +34 -0
- package/src/refractor/toolbox.cjs +6 -1
- package/src/refractor/toolbox.mjs +7 -2
- package/types/apidom-ns-openapi-2.d.ts +73 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [4.2.0](https://github.com/speclynx/apidom/compare/v4.1.0...v4.2.0) (2026-03-17)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- **ns-openapi-2-0:** add normalization refractor plugins ([#170](https://github.com/speclynx/apidom/issues/170)) ([315b5c6](https://github.com/speclynx/apidom/commit/315b5c620f752941749df13c0a5ab4bd14d41597))
|
|
11
|
+
|
|
6
12
|
# [4.1.0](https://github.com/speclynx/apidom/compare/v4.0.5...v4.1.0) (2026-03-16)
|
|
7
13
|
|
|
8
14
|
**Note:** Version bump only for package @speclynx/apidom-ns-openapi-2
|
package/README.md
CHANGED
|
@@ -185,6 +185,128 @@ const swaggerElement = SwaggerElement.refract(apiDOM.result, {
|
|
|
185
185
|
// (StringElement)))
|
|
186
186
|
```
|
|
187
187
|
|
|
188
|
+
#### Normalize Parameter Objects plugin
|
|
189
|
+
|
|
190
|
+
Duplicates Parameters from Path Items to Operation Objects using following rules:
|
|
191
|
+
|
|
192
|
+
- An Operation-level parameter with the same name and location overrides the inherited Path Item parameter, but Path Item parameters can never be removed at the Operation level
|
|
193
|
+
- The list MUST NOT include duplicated parameters
|
|
194
|
+
- A unique parameter is defined by a combination of a name and location.
|
|
195
|
+
|
|
196
|
+
```js
|
|
197
|
+
import { toValue } from '@speclynx/apidom-core';
|
|
198
|
+
import { parse } from '@speclynx/apidom-parser-adapter-yaml-1-2';
|
|
199
|
+
import { refractorPluginNormalizeParameters, SwaggerElement } from '@speclynx/apidom-ns-openapi-2';
|
|
200
|
+
|
|
201
|
+
const yamlDefinition = `
|
|
202
|
+
swagger: "2.0"
|
|
203
|
+
paths:
|
|
204
|
+
/:
|
|
205
|
+
parameters:
|
|
206
|
+
- name: param1
|
|
207
|
+
in: query
|
|
208
|
+
type: string
|
|
209
|
+
- name: param2
|
|
210
|
+
in: query
|
|
211
|
+
type: string
|
|
212
|
+
get: {}
|
|
213
|
+
`;
|
|
214
|
+
const apiDOM = await parse(yamlDefinition);
|
|
215
|
+
const swaggerElement = SwaggerElement.refract(apiDOM.result, {
|
|
216
|
+
plugins: [refractorPluginNormalizeParameters()],
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
toValue(swaggerElement);
|
|
220
|
+
// =>
|
|
221
|
+
// {
|
|
222
|
+
// "swagger": "2.0",
|
|
223
|
+
// "paths": {
|
|
224
|
+
// "/": {
|
|
225
|
+
// "parameters": [
|
|
226
|
+
// {
|
|
227
|
+
// "name": "param1",
|
|
228
|
+
// "in": "query",
|
|
229
|
+
// "type": "string"
|
|
230
|
+
// },
|
|
231
|
+
// {
|
|
232
|
+
// "name": "param2",
|
|
233
|
+
// "in": "query",
|
|
234
|
+
// "type": "string"
|
|
235
|
+
// }
|
|
236
|
+
// ],
|
|
237
|
+
// "get": {
|
|
238
|
+
// "parameters": [
|
|
239
|
+
// {
|
|
240
|
+
// "name": "param1",
|
|
241
|
+
// "in": "query",
|
|
242
|
+
// "type": "string"
|
|
243
|
+
// },
|
|
244
|
+
// {
|
|
245
|
+
// "name": "param2",
|
|
246
|
+
// "in": "query",
|
|
247
|
+
// "type": "string"
|
|
248
|
+
// }
|
|
249
|
+
// ]
|
|
250
|
+
// }
|
|
251
|
+
// }
|
|
252
|
+
// }
|
|
253
|
+
// }
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
#### Normalize Security Requirements Objects plugin
|
|
257
|
+
|
|
258
|
+
`Operation.security` definition overrides any declared top-level security from Swagger.security field.
|
|
259
|
+
If Operation.security field is not defined, this field will inherit security from Swagger.security field.
|
|
260
|
+
|
|
261
|
+
```js
|
|
262
|
+
import { toValue } from '@speclynx/apidom-core';
|
|
263
|
+
import { parse } from '@speclynx/apidom-parser-adapter-yaml-1-2';
|
|
264
|
+
import { refractorPluginNormalizeSecurityRequirements, SwaggerElement } from '@speclynx/apidom-ns-openapi-2';
|
|
265
|
+
|
|
266
|
+
const yamlDefinition = `
|
|
267
|
+
swagger: "2.0"
|
|
268
|
+
security:
|
|
269
|
+
- petstore_auth:
|
|
270
|
+
- write:pets
|
|
271
|
+
- read:pets
|
|
272
|
+
paths:
|
|
273
|
+
/:
|
|
274
|
+
get: {}
|
|
275
|
+
`;
|
|
276
|
+
const apiDOM = await parse(yamlDefinition);
|
|
277
|
+
const swaggerElement = SwaggerElement.refract(apiDOM.result, {
|
|
278
|
+
plugins: [refractorPluginNormalizeSecurityRequirements()],
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
toValue(swaggerElement);
|
|
282
|
+
// =>
|
|
283
|
+
// {
|
|
284
|
+
// "swagger": "2.0",
|
|
285
|
+
// "security": [
|
|
286
|
+
// {
|
|
287
|
+
// "petstore_auth": [
|
|
288
|
+
// "write:pets",
|
|
289
|
+
// "read:pets"
|
|
290
|
+
// ]
|
|
291
|
+
// }
|
|
292
|
+
// ],
|
|
293
|
+
// "paths": {
|
|
294
|
+
// "/": {
|
|
295
|
+
// "get": {
|
|
296
|
+
// "security": [
|
|
297
|
+
// {
|
|
298
|
+
// "petstore_auth": [
|
|
299
|
+
// "write:pets",
|
|
300
|
+
// "read:pets"
|
|
301
|
+
// ]
|
|
302
|
+
// }
|
|
303
|
+
// ]
|
|
304
|
+
// }
|
|
305
|
+
// }
|
|
306
|
+
// }
|
|
307
|
+
// }
|
|
308
|
+
```
|
|
309
|
+
|
|
188
310
|
## Implementation progress
|
|
189
311
|
|
|
190
312
|
Only fully implemented specification objects should be checked here.
|