Neurosis Prevention Mechanism
    Wondering what’s next for npm?Check out our public roadmap! »

    @asyncapi/openapi-schema-parser

    2.0.1 • Public • Published

    OpenAPI Schema Parser

    An AsyncAPI schema parser for OpenAPI 3.0.x and Swagger 2.x schemas.

    Installation

    npm install @asyncapi/openapi-schema-parser
    

    Usage

    const parser = require('asyncapi-parser')
    const openapiSchemaParser = require('@asyncapi/openapi-schema-parser')
    
    const asyncapiWithOpenAPI = `
    asyncapi: 2.0.0
    info:
      title: Example with OpenAPI
      version: 0.1.0
    channels:
      example:
        publish:
          message:
            schemaFormat: 'application/vnd.oai.openapi;version=3.0.0'
            payload: # The following is an OpenAPI schema
              type: object
              properties:
                title:
                  type: string
                  nullable: true
                author:
                  type: string
                  example: Jack Johnson
    `
    
    parser.registerSchemaParser(openapiSchemaParser);
    
    await parser.parse(asyncapiWithOpenAPI)

    It also supports referencing remote OpenAPI schemas:

    const parser = require('asyncapi-parser')
    const openapiSchemaParser = require('@asyncapi/openapi-schema-parser')
    
    const asyncapiWithOpenAPI = `
    asyncapi: 2.0.0
    info:
      title: Example with OpenAPI
      version: 0.1.0
    channels:
      example:
        publish:
          message:
            schemaFormat: 'application/vnd.oai.openapi;version=3.0.0'
            payload:
              $ref: 'yourserver.com/schemas#/Book'
    `
    
    parser.registerSchemaParser(openapiSchemaParser)
    
    await parser.parse(asyncapiWithOpenAPI)

    Install

    npm i @asyncapi/openapi-schema-parser

    DownloadsWeekly Downloads

    12,857

    Version

    2.0.1

    License

    Apache-2.0

    Unpacked Size

    50.1 kB

    Total Files

    23

    Last publish

    Collaborators

    • avatar
    • avatar
    • avatar