Open API V3 Merger gradle plugin

A gradle plugin to merge open api v3 specification files

License

License

Categories

Categories

Gradle Build Tools
GroupId

GroupId

com.rameshkp
ArtifactId

ArtifactId

openapi-merger-gradle-plugin
Last Version

Last Version

1.0.4
Release Date

Release Date

Type

Type

pom.sha512
Description

Description

Open API V3 Merger gradle plugin
A gradle plugin to merge open api v3 specification files
Project URL

Project URL

https://github.com/kpramesh2212/openapi-merger-plugin
Source Code Management

Source Code Management

https://github.com/kpramesh2212/openapi-merger-plugin

Download openapi-merger-gradle-plugin

Dependencies

runtime (2)

Group / Artifact Type Version
org.jetbrains.kotlin : kotlin-stdlib jar 1.3.72
com.rameshkp : openapi-merger-app jar 1.0.4

Project Modules

There are no modules declared in this project.

openapi-merger-plugin

A plugin to merge OpenAPI-3 specification files into a single file

what does the plugin do

Consider the following open api v3 schema files color.yaml and book.yaml

color.yaml

openapi: 3.0.1
info:
  title: OpenAPI definition
  version: v0
servers:
- url: http://localhost:8080
  description: Generated server url
paths:
  /api/color/{name}:
    get:
      tags:
      - color-controller
      operationId: getColor
      parameters:
      - name: name
        in: path
        required: true
        schema:
          type: string
      responses:
        "200":
          description: OK
          content:
            '*/*':
              schema:
                $ref: '#/components/schemas/Color'
components:
  schemas:
    Color:
      type: object
      properties:
        name:
          type: string
        red:
          type: integer
          format: int32
        green:
          type: integer
          format: int32
        blue:
          type: integer
          format: int32

book.yaml

openapi: 3.0.1
info:
  title: OpenAPI definition
  version: v0
servers:
- url: http://localhost:8080
  description: Generated server url
paths:
  /api/book/{name}:
    get:
      tags:
      - book-controller
      operationId: getBook
      parameters:
      - name: name
        in: path
        required: true
        schema:
          type: string
      responses:
        "200":
          description: OK
          content:
            '*/*':
              schema:
                $ref: '#/components/schemas/Book'
components:
  schemas:
    Book:
      type: object
      properties:
        name:
          type: string
        iban:
          type: string

Using the plugin user can merge these files into a single file

merged.yaml

openapi: 3.0.1
info:
  title: My title
  version: 1.0.0-SNAPSHOT
servers:
- url: http://localhost:8080
  description: Generated server url
paths:
  /api/book/{name}:
    get:
      tags:
      - book-controller
      operationId: getBook
      parameters:
      - name: name
        in: path
        required: true
        style: simple
        explode: false
        schema:
          type: string
      responses:
        "200":
          description: OK
          content:
            '*/*':
              schema:
                $ref: '#/components/schemas/Book'
  /api/color/{name}:
    get:
      tags:
      - color-controller
      operationId: getColor
      parameters:
      - name: name
        in: path
        required: true
        style: simple
        explode: false
        schema:
          type: string
      responses:
        "200":
          description: OK
          content:
            '*/*':
              schema:
                $ref: '#/components/schemas/Color'
components:
  schemas:
    Book:
      type: object
      properties:
        name:
          type: string
        iban:
          type: string
    Color:
      type: object
      properties:
        name:
          type: string
        red:
          type: integer
          format: int32
        green:
          type: integer
          format: int32
        blue:
          type: integer
          format: int32

OpenAPI objects

Root Objects Open API v3 Specification

The plugin will merge the following Root OpenAPI objects and all its sub object from the input files

S.NO Field Name
1 servers
2 paths
3 components
4 security
5 tags

The plugin will ignore following Root OpenAPI objects and all its sub object from the input files.

S.NO Field Name
1 openapi
2 info
3 externalDocs

However the plugin allows the user to configure the above object as input properties that will be placed in the merged file.

Supported File formats

  1. json
  2. yaml

Plugin inputs

The plugin expects a directory as input which can contain any number of openapi specification files. Input directory can contain both yaml and json open api specification files, and the plugin can process them all.

Plugin outputs

The plugin can output the merged file either in json or yaml format, but not both.

Versions

Version
1.0.4
1.0.3
1.0.2