UNPKG

fluid-oas

Version:

Build declarative OpenApiv3.* specifications.

72 lines (71 loc) 3.47 kB
import { withCallbacksComponent, withExamplesComponent, withHeadersComponent, withLinksComponent, withParametersComponent, withPathItemsComponent, withRequestBodiesComponent, withResponsesComponent, withSchemasComponent, withSecuritySchemesComponent, } from "../common"; import { Base } from "./base"; import { ReferenceObject, } from "./OpenApiReferenceObject"; const ComponentBase = withPathItemsComponent(withCallbacksComponent(withLinksComponent(withSecuritySchemesComponent(withHeadersComponent(withRequestBodiesComponent(withExamplesComponent(withParametersComponent(withResponsesComponent(withSchemasComponent(Base)))))))))); class _OpenApiComponent extends ComponentBase { createMappings() { const mappings = new Map(); if (this._schemas !== undefined) { for (const [key, val] of this._schemas) { const reference = ReferenceObject.add$Ref(`#/components/schemas/${key}`); mappings.set(val, reference); } } if (this._parameters !== undefined) { for (const [key, val] of this._parameters) { const reference = ReferenceObject.add$Ref(`#/components/parameters/${key}`); mappings.set(val, reference); } } if (this._examples !== undefined) { for (const [key, val] of this._examples) { const reference = ReferenceObject.add$Ref(`#/components/examples/${key}`); mappings.set(val, reference); } } if (this._examples !== undefined) { for (const [key, val] of this._examples) { const reference = ReferenceObject.add$Ref(`#/components/examples/${key}`); mappings.set(val, reference); } } if (this._requestBodies !== undefined) { for (const [key, val] of this._requestBodies) { const reference = ReferenceObject.add$Ref(`#/components/requestBodies/${key}`); mappings.set(val, reference); } } if (this._headers !== undefined) { for (const [key, val] of this._headers) { const reference = ReferenceObject.add$Ref(`#/components/headers/${key}`); mappings.set(val, reference); } } if (this._securitySchemes !== undefined) { for (const [key, val] of this._securitySchemes) { const reference = ReferenceObject.add$Ref(`#/components/securitySchemes/${key}`); mappings.set(val, reference); } } if (this._links !== undefined) { for (const [key, val] of this._links) { const reference = ReferenceObject.add$Ref(`#/components/links/${key}`); mappings.set(val, reference); } } if (this._callbacks !== undefined) { for (const [key, val] of this._callbacks) { const reference = ReferenceObject.add$Ref(`#/components/callbacks/${key}`); mappings.set(val, reference); } } if (this._pathItems !== undefined) { for (const [key, val] of this._pathItems) { const reference = ReferenceObject.add$Ref(`#/components/pathItems/${key}`); mappings.set(val, reference); } } return Object.freeze(mappings); } } export const Component = new _OpenApiComponent();