import { OpenAPIV3 } from 'openapi-types' ; import { OpenApiDocument , OpenApiPersistedSchema } from '../openapi-types' ; import { ServiceOptions } from '../options' ; import { parseSchema , parseSchemaProperties } from './schema' ; import { parseApis } from './api' ; import { createRefs , OpenApiDocumentRefs } from './refs' ; import { ParserOptions } from './options' ; import { parseBound } from './swagger-parser-workaround' ; param fileContent param serviceOptions param options returns internal export async function parseOpenApiDocument ( fileContent , serviceOptions , options ) { const clonedContent = JSON . parse ( JSON . stringify ( fileContent ) ) ; const document = ( await parseBound ( clonedContent ) ) as OpenAPIV3 . Document ; const refs = await createRefs ( document , options ) ; return { apis : parseApis ( document , refs , options ) , serviceName : serviceOptions . serviceName , serviceDescription : document . info . description , serviceOptions , schemas : parseSchemas ( document , refs , options ) } ; } internal export function parseSchemas ( document , refs , options ) { return Object . entries ( document . components ?. schemas || { } ) . map ( ( [ name , schema ] ) => ( { ... refs . getSchemaNaming ( `#/components/schemas/${ name }` ) , schema : parseSchema ( schema , refs , options ) , description : refs . resolveObject ( schema ) . description , schemaProperties : parseSchemaProperties ( schema ) } ) ) ; }