Skip to content

Generate OpenAPI documents from multiple Swagger v2 or Open API v3 documents.

License

Notifications You must be signed in to change notification settings

dperez3/oapi-generator

Repository files navigation

oapi-generator

Conventional Commits buddy pipeline

Generate OpenAPI documents from multiple Swagger v2 or Open API v3 documents.

npm

Installation

Install

npm install --save-dev oapi-generator
npm install --save-dev openapi-types@1.3.4

Configure

Config File

Javascript

const v1GenDoc = { /*...*/ };

const v2GenDoc = { /*...*/ };

const config =
{
  genConfigs: [v1GenDoc, v2GenDoc]
};

Or TypeScript

import { Configuration } from "oapi-generator/configuration";
import { OpenAPIV3 } from "openapi-types";

const v1GenDoc: Configuration.IGenOpenAPIV3Config = { /*...*/ };

const v2GenDoc: Configuration.IGenOpenAPIV3Config = { /*...*/ };

const config: Configuration.IManyGenOpenAPIV3Configs =
{
  genConfigs: [v1GenDoc, v2GenDoc]
};

export = config;

openapi-types combined with TypesScript intellisense provides the easiest way to understand the configuration API.

package.json

{
  "scripts": {
    "oapi-gen:run": "oapi-generator --config {path_to_above_config_file}"
  }
}