Skip to content

OpenAPIParser

reference
1 min readUpdated

Kind: Class

Source: atloria-monorepo/libs/parser-core/src/parsers/api-schema/openapi.parser.ts

OpenAPI Parser Implementation (Parser-Core Version)

Supports:

  • OpenAPI 3.0.x and 3.1.x
  • Swagger 2.0
  • JSON and YAML formats

Implements: IParser

Methods

MethodSignatureReturns
initializeinitialize(_config: ParserConfig)Promise<void>
canParsecanParse(filePath: string)boolean
parseFileparseFile(filePath: string, content: string)Promise<ParseResult>
parseFilesparseFiles(files: ParseFileInput[])Promise<ParseResult[]>
destroydestroy()Promise<void>

Properties

PropertyType
nameany
versionany
supportedPatternsany

Where it refuses work

  • OpenAPIParser stops the work with an early return when !pathItem, in 4 places.
  • OpenAPIParser stops the work with an early return when !operation, in 4 places.
  • OpenAPIParser stops the work with an early return when !/\.(json|ya?ml)$/i.test(filePath).
  • OpenAPIParser stops the work with an early return when schema === null || typeof schema !== 'object'.
  • OpenAPIParser stops the work with an early return when ancestors.includes(schema as object).
  • OpenAPIParser stops the work with an early return when Array.isArray(schema).

When something fails

  • OpenAPIParser handles failure in 2 places: it logs it and continues in 1, and turns it into a return value in 1.

Was this page helpful?

Download as PDF