-
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(OpenApi3.1-Yaml): add support for OpenApi.security field
Refs #1
- Loading branch information
Showing
7 changed files
with
73 additions
and
4 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
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
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
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
32 changes: 32 additions & 0 deletions
32
...apidom-parser-adapter-openapi3-1-yaml/src/parser/visitors/open-api-3-1/SecurityVisitor.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,32 @@ | ||
import stampit from 'stampit'; | ||
import { isYamlMapping, YamlSequence } from 'apidom-ast'; | ||
|
||
import { BREAK } from '..'; | ||
import SpecificationVisitor from '../SpecificationVisitor'; | ||
import { KindVisitor } from '../generics'; | ||
|
||
const SecurityVisitor = stampit(KindVisitor, SpecificationVisitor, { | ||
init() { | ||
this.element = new this.namespace.elements.Array(); | ||
this.element.classes.push('security'); | ||
}, | ||
methods: { | ||
sequence(sequenceNode: YamlSequence) { | ||
sequenceNode.content.forEach((item) => { | ||
if (isYamlMapping(item)) { | ||
const element = this.nodeToElement(['document', 'objects', 'SecurityRequirement'], item); | ||
this.element.push(element); | ||
} else { | ||
const element = this.nodeToElement(['kind'], item); | ||
this.element.push(element); | ||
} | ||
}); | ||
|
||
this.maybeAddSourceMap(sequenceNode, this.element); | ||
|
||
return BREAK; | ||
}, | ||
}, | ||
}); | ||
|
||
export default SecurityVisitor; |
16 changes: 16 additions & 0 deletions
16
...er-adapter-openapi3-1-yaml/src/parser/visitors/open-api-3-1/security-requirement/index.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,16 @@ | ||
import stampit from 'stampit'; | ||
import { always } from 'ramda'; | ||
|
||
import MapYamlMappingVisitor from '../../generics/MapYamlMappingVisitor'; | ||
import { KindVisitor } from '../../generics'; | ||
|
||
const SecurityRequirementVisitor = stampit(KindVisitor, MapYamlMappingVisitor, { | ||
props: { | ||
specPath: always(['kind']), | ||
}, | ||
init() { | ||
this.element = new this.namespace.elements.SecurityRequirement(); | ||
}, | ||
}); | ||
|
||
export default SecurityRequirementVisitor; |
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