Skip to content

OpenAPIParser

reference
1 min readUpdated

Kind: Class

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

OpenAPI Parser Implementation

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 schema.type === 'array' && schema.items.
  • OpenAPIParser stops the work with an early return when !schema.
  • OpenAPIParser stops the work with an early return when ref.
  • OpenAPIParser stops the work with an early return when !requestBody.

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