-
Notifications
You must be signed in to change notification settings - Fork 14
/
SecurityVisitor.ts
32 lines (25 loc) · 1.09 KB
/
SecurityVisitor.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { Mixin } from 'ts-mixer';
import { ArrayElement, Element, BREAK } from '@swagger-api/apidom-core';
import SwaggerSecurityElement from '../../../elements/nces/SwaggerSecurity';
import SpecificationVisitor, { SpecificationVisitorOptions } from '../SpecificationVisitor';
import FallbackVisitor, { FallbackVisitorOptions } from '../FallbackVisitor';
export interface SecurityVisitorOptions
extends SpecificationVisitorOptions,
FallbackVisitorOptions {}
class SecurityVisitor extends Mixin(SpecificationVisitor, FallbackVisitor) {
public declare readonly element: SwaggerSecurityElement;
constructor(options: SecurityVisitorOptions) {
super(options);
this.element = new SwaggerSecurityElement();
}
ArrayElement(arrayElement: ArrayElement) {
arrayElement.forEach((item: Element): void => {
const specPath = ['document', 'objects', 'SecurityRequirement'];
const element = this.toRefractedElement(specPath, item);
this.element.push(element);
});
this.copyMetaAndAttributes(arrayElement, this.element);
return BREAK;
}
}
export default SecurityVisitor;