UNPKG

@typespec/openapi3

Version:

TypeSpec library for emitting OpenAPI 3.0 and OpenAPI 3.1 from the TypeSpec REST protocol binding and converting OpenAPI3 to TypeSpec

53 lines 2.24 kB
import { getExternalDocs, resolveInfo } from "@typespec/openapi"; import { applyEncoding as applyEncoding3_0, getRawBinarySchema as getRawBinarySchema3_0, isRawBinarySchema as isRawBinarySchema3_0, } from "./openapi-helpers-3-0.js"; import { applyEncoding as applyEncoding3_1, getRawBinarySchema as getRawBinarySchema3_1, isRawBinarySchema as isRawBinarySchema3_1, } from "./openapi-helpers-3-1.js"; import { createSchemaEmitter3_0 } from "./schema-emitter-3-0.js"; import { createSchemaEmitter3_1 } from "./schema-emitter-3-1.js"; export function getOpenApiSpecProps(specVersion) { switch (specVersion) { case "3.0.0": return { applyEncoding: applyEncoding3_0, createRootDoc(program, serviceType, serviceVersion) { return createRoot(program, serviceType, specVersion, serviceVersion); }, createSchemaEmitter: createSchemaEmitter3_0, getRawBinarySchema: getRawBinarySchema3_0, isRawBinarySchema: isRawBinarySchema3_0, }; case "3.1.0": return { applyEncoding: applyEncoding3_1, createRootDoc(program, serviceType, serviceVersion) { return createRoot(program, serviceType, specVersion, serviceVersion); }, createSchemaEmitter: createSchemaEmitter3_1, getRawBinarySchema: getRawBinarySchema3_1, isRawBinarySchema: isRawBinarySchema3_1, }; } } function createRoot(program, serviceType, specVersion, serviceVersion) { const info = resolveInfo(program, serviceType); return { openapi: specVersion, info: { title: "(title)", ...info, version: serviceVersion ?? info?.version ?? "0.0.0", }, externalDocs: getExternalDocs(program, serviceType), tags: [], paths: {}, security: undefined, components: { parameters: {}, requestBodies: {}, responses: {}, schemas: {}, examples: {}, securitySchemes: {}, }, }; } //# sourceMappingURL=openapi-spec-mappings.js.map