Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/asyncapi/openapi-schema-parser
An AsyncAPI schema parser for OpenAPI 3.0.x and Swagger 2.x schemas.
https://github.com/asyncapi/openapi-schema-parser
get-global-node-release-workflows get-global-releaserc nodejs openapi parser
Last synced: 19 days ago
JSON representation
An AsyncAPI schema parser for OpenAPI 3.0.x and Swagger 2.x schemas.
- Host: GitHub
- URL: https://github.com/asyncapi/openapi-schema-parser
- Owner: asyncapi
- License: apache-2.0
- Created: 2020-03-11T16:50:55.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-06-12T12:48:57.000Z (7 months ago)
- Last Synced: 2024-10-29T22:38:04.565Z (2 months ago)
- Topics: get-global-node-release-workflows, get-global-releaserc, nodejs, openapi, parser
- Language: TypeScript
- Homepage:
- Size: 1.96 MB
- Stars: 13
- Watchers: 6
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Codeowners: CODEOWNERS
Awesome Lists containing this project
README
# OpenAPI Schema Parser
An AsyncAPI schema parser for OpenAPI 3.0.x and Swagger 2.x schemas.
> **Note**
> Version >= `3.0.0` of package is only supported by `@asyncapi/parser` version >= `2.0.0`.- [Installation](#installation)
- [Usage](#usage)## Installation
```bash
npm install @asyncapi/openapi-schema-parser
// OR
yarn add @asyncapi/openapi-schema-parser
```## Usage
```ts
import { Parser } from '@asyncapi/parser';
import { OpenAPISchemaParser } from '@asyncapi/openapi-schema-parser';const parser = new Parser();
parser.registerSchemaParser(OpenAPISchemaParser());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
`;const { document } = await parser.parse(asyncapiWithOpenAPI);
``````js
const { Parser } = require('@asyncapi/parser');
const { OpenAPISchemaParser } = require('@asyncapi/openapi-schema-parser');const parser = new Parser();
parser.registerSchemaParser(OpenAPISchemaParser());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
`;const { document } = await parser.parse(asyncapiWithOpenAPI);
```It also supports referencing remote OpenAPI schemas:
```ts
import { Parser } from '@asyncapi/parser';
import { OpenAPISchemaParser } from '@asyncapi/openapi-schema-parser';const parser = new Parser();
parser.registerSchemaParser(OpenAPISchemaParser());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'
`;const { document } = await parser.parse(asyncapiWithOpenAPI);
```