@swagger-api/apidom-ns-openapi-3-1
Version:
OpenAPI 3.1.x namespace for ApiDOM.
32 lines • 1.07 kB
JavaScript
import { Mixin } from 'ts-mixer';
import { ArrayElement, isObjectElement, BREAK, cloneDeep } from '@swagger-api/apidom-core';
import { FallbackVisitor, SpecificationVisitor } from '@swagger-api/apidom-ns-openapi-3-0';
import ParentSchemaAwareVisitor from "./ParentSchemaAwareVisitor.mjs";
/**
* @public
*/
/**
* @public
*/
class AnyOfVisitor extends Mixin(SpecificationVisitor, ParentSchemaAwareVisitor, FallbackVisitor) {
constructor(options) {
super(options);
this.element = new ArrayElement();
this.element.classes.push('json-schema-anyOf');
this.passingOptionsNames.push('parent');
}
ArrayElement(arrayElement) {
arrayElement.forEach(item => {
if (isObjectElement(item)) {
const schemaElement = this.toRefractedElement(['document', 'objects', 'Schema'], item);
this.element.push(schemaElement);
} else {
const element = cloneDeep(item);
this.element.push(element);
}
});
this.copyMetaAndAttributes(arrayElement, this.element);
return BREAK;
}
}
export default AnyOfVisitor;