@speclynx/apidom-ns-openapi-3-0 4.0.5 → 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 CHANGED
@@ -3,6 +3,17 @@
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
+ - **ns-openapi-3-0:** add normalization refractor plugins ([#169](https://github.com/speclynx/apidom/issues/169)) ([fb0ec23](https://github.com/speclynx/apidom/commit/fb0ec23dd8c933a9a4d72762f3fb643e3e11d037))
12
+
13
+ # [4.1.0](https://github.com/speclynx/apidom/compare/v4.0.5...v4.1.0) (2026-03-16)
14
+
15
+ **Note:** Version bump only for package @speclynx/apidom-ns-openapi-3-0
16
+
6
17
  ## [4.0.5](https://github.com/speclynx/apidom/compare/v4.0.4...v4.0.5) (2026-03-13)
7
18
 
8
19
  **Note:** Version bump only for package @speclynx/apidom-ns-openapi-3-0
package/README.md CHANGED
@@ -180,6 +180,183 @@ const openApiElement = OpenApi3_0Element.refract(apiDOM.result, {
180
180
  // (StringElement)))
181
181
  ```
182
182
 
183
+ #### Normalize Parameter Objects plugin
184
+
185
+ Duplicates Parameters from Path Items to Operation Objects using following rules:
186
+
187
+ - 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
188
+ - The list MUST NOT include duplicated parameters
189
+ - A unique parameter is defined by a combination of a name and location.
190
+
191
+ ```js
192
+ import { toValue } from '@speclynx/apidom-core';
193
+ import { parse } from '@speclynx/apidom-parser-adapter-yaml-1-2';
194
+ import { refractorPluginNormalizeParameters, OpenApi3_0Element } from '@speclynx/apidom-ns-openapi-3-0';
195
+
196
+ const yamlDefinition = `
197
+ openapi: 3.0.4
198
+ paths:
199
+ /:
200
+ parameters:
201
+ - name: param1
202
+ in: query
203
+ - name: param2
204
+ in: query
205
+ get: {}
206
+ `;
207
+ const apiDOM = await parse(yamlDefinition);
208
+ const openApiElement = OpenApi3_0Element.refract(apiDOM.result, {
209
+ plugins: [refractorPluginNormalizeParameters()],
210
+ });
211
+
212
+ toValue(openApiElement);
213
+ // =>
214
+ // {
215
+ // "openapi": "3.0.4",
216
+ // "paths": {
217
+ // "/": {
218
+ // "parameters": [
219
+ // {
220
+ // "name": "param1",
221
+ // "in": "query"
222
+ // },
223
+ // {
224
+ // "name": "param2",
225
+ // "in": "query"
226
+ // }
227
+ // ],
228
+ // "get": {
229
+ // "parameters": [
230
+ // {
231
+ // "name": "param1",
232
+ // "in": "query"
233
+ // },
234
+ // {
235
+ // "name": "param2",
236
+ // "in": "query"
237
+ // }
238
+ // ]
239
+ // }
240
+ // }
241
+ // }
242
+ // }
243
+ ```
244
+
245
+ #### Normalize Security Requirements Objects plugin
246
+
247
+ `Operation.security` definition overrides any declared top-level security from OpenAPI.security field.
248
+ If Operation.security field is not defined, this field will inherit security from OpenAPI.security field.
249
+
250
+ ```js
251
+ import { toValue } from '@speclynx/apidom-core';
252
+ import { parse } from '@speclynx/apidom-parser-adapter-yaml-1-2';
253
+ import { refractorPluginNormalizeSecurityRequirements, OpenApi3_0Element } from '@speclynx/apidom-ns-openapi-3-0';
254
+
255
+ const yamlDefinition = `
256
+ openapi: 3.0.4
257
+ security:
258
+ - petstore_auth:
259
+ - write:pets
260
+ - read:pets
261
+ paths:
262
+ /:
263
+ get: {}
264
+ `;
265
+ const apiDOM = await parse(yamlDefinition);
266
+ const openApiElement = OpenApi3_0Element.refract(apiDOM.result, {
267
+ plugins: [refractorPluginNormalizeSecurityRequirements()],
268
+ });
269
+
270
+ toValue(openApiElement);
271
+ // =>
272
+ // {
273
+ // "openapi": "3.0.4",
274
+ // "security": [
275
+ // {
276
+ // "petstore_auth": [
277
+ // "write:pets",
278
+ // "read:pets"
279
+ // ]
280
+ // }
281
+ // ],
282
+ // "paths": {
283
+ // "/": {
284
+ // "get": {
285
+ // "security": [
286
+ // {
287
+ // "petstore_auth": [
288
+ // "write:pets",
289
+ // "read:pets"
290
+ // ]
291
+ // }
292
+ // ]
293
+ // }
294
+ // }
295
+ // }
296
+ // }
297
+ ```
298
+
299
+ #### Normalize Server Objects plugin
300
+
301
+ List of Server Objects can be defined in OpenAPI 3.0 on multiple levels:
302
+
303
+ - OpenAPI.servers
304
+ - PathItem.servers
305
+ - Operation.servers
306
+
307
+ If an alternative server object is specified at the Path Item Object level, it will override OpenAPI.servers.
308
+ If an alternative server object is specified at the Operation Object level, it will override PathItem.servers and OpenAPI.servers respectively.
309
+
310
+ ```js
311
+ import { toValue } from '@speclynx/apidom-core';
312
+ import { parse } from '@speclynx/apidom-parser-adapter-yaml-1-2';
313
+ import { refractorPluginNormalizeServers, OpenApi3_0Element } from '@speclynx/apidom-ns-openapi-3-0';
314
+
315
+ const yamlDefinition = `
316
+ openapi: 3.0.4
317
+ servers:
318
+ - url: https://example.com/
319
+ description: production server
320
+ paths:
321
+ /:
322
+ get: {}
323
+ `;
324
+ const apiDOM = await parse(yamlDefinition);
325
+ const openApiElement = OpenApi3_0Element.refract(apiDOM.result, {
326
+ plugins: [refractorPluginNormalizeServers()],
327
+ });
328
+
329
+ toValue(openApiElement);
330
+ // =>
331
+ // {
332
+ // "openapi": "3.0.4",
333
+ // "servers": [
334
+ // {
335
+ // "url": "https://example.com/",
336
+ // "description": "production server"
337
+ // }
338
+ // ],
339
+ // "paths": {
340
+ // "/": {
341
+ // "servers": [
342
+ // {
343
+ // "url": "https://example.com/",
344
+ // "description": "production server"
345
+ // }
346
+ // ],
347
+ // "get": {
348
+ // "servers": [
349
+ // {
350
+ // "url": "https://example.com/",
351
+ // "description": "production server"
352
+ // }
353
+ // ]
354
+ // }
355
+ // }
356
+ // }
357
+ // }
358
+ ```
359
+
183
360
  ## Implementation progress
184
361
 
185
362
  Only fully implemented specification objects should be checked here.