-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ns-openapi-3-1): make parameters plugin idempotent (#4150)
Refs #4134
- Loading branch information
Showing
7 changed files
with
406 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
...openapi-3-1/test/refractor/plugins/normalize-parameters/__snapshots__/idempotence.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`refractor plugins normalize-parameters should have idempotent characteristics 1`] = ` | ||
Object { | ||
openapi: 3.1.0, | ||
paths: Object { | ||
/: Object { | ||
get: Object { | ||
parameters: Array [ | ||
Object { | ||
in: query, | ||
name: param3, | ||
}, | ||
], | ||
}, | ||
parameters: Array [ | ||
Object { | ||
in: query, | ||
name: param1, | ||
}, | ||
Object { | ||
in: query, | ||
name: param2, | ||
}, | ||
], | ||
}, | ||
}, | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
packages/apidom-ns-openapi-3-1/test/refractor/plugins/normalize-parameters/idempotence.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { expect } from 'chai'; | ||
import dedent from 'dedent'; | ||
import { toValue, dispatchRefractorPlugins } from '@swagger-api/apidom-core'; | ||
import { parse } from '@swagger-api/apidom-parser-adapter-yaml-1-2'; | ||
|
||
import { | ||
createToolbox, | ||
OpenApi3_1Element, | ||
refractorPluginNormalizeParameters, | ||
keyMap, | ||
getNodeType, | ||
} from '../../../../src'; | ||
|
||
describe('refractor', function () { | ||
context('plugins', function () { | ||
context('normalize-parameters', function () { | ||
specify('should have idempotent characteristics', async function () { | ||
const yamlDefinition = dedent` | ||
openapi: 3.1.0 | ||
paths: | ||
/: | ||
parameters: | ||
- name: param1 | ||
in: query | ||
- name: param2 | ||
in: query | ||
get: | ||
parameters: | ||
- name: param3 | ||
in: query | ||
`; | ||
const apiDOM = await parse(yamlDefinition); | ||
const openApiElement = OpenApi3_1Element.refract(apiDOM.result) as OpenApi3_1Element; | ||
const options = { | ||
toolboxCreator: createToolbox, | ||
visitorOptions: { keyMap, nodeTypeGetter: getNodeType }, | ||
}; | ||
|
||
dispatchRefractorPlugins(openApiElement, [refractorPluginNormalizeParameters()], options); | ||
dispatchRefractorPlugins(openApiElement, [refractorPluginNormalizeParameters()], options); | ||
dispatchRefractorPlugins(openApiElement, [refractorPluginNormalizeParameters()], options); | ||
|
||
expect(toValue(apiDOM.result)).toMatchSnapshot(); | ||
}); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.