Git Product home page Git Product logo

openapi-spring-maven-plugin's Introduction

Maven Central

Swagger Maven Plugin for Spring MVC

This maven plugin generates Open Specification 3.0.1 (OAS3) for your Spring Rest Project. It supports most of the Swagger 2+ and Spring Web annotation. It is simple to use and generates the OAS3 specifaction in yaml format. Please note that it is the first release so there are few bugs, we will fix them.

#Prerequisite

  • Maven >= 3.3.9
  • Java 8

Features

Versions

  • [0.3] supports Swagger Spec [2.0] SpingMVC.

Usage/Example

Import the plugin in your project by adding following configuration in your plugins block of pom file:

<build>
    <plugins>
        <plugin>
            <groupId>uk.ac.ebi.uniprot</groupId>
            <artifactId>openapi-maven-plugin</artifactId>
            <version>0.3</version>
            <configuration>
                <packageLocations>
			<packageLocation>your.package.with.spring.controllers</packageLocation>
	        	<packageLocation>your.package.with.spring.controllers</packageLocation>
                </packageLocations>
                <openApiDirectory>generated/swagger</openApiDirectory>
                <openApiFileName>openapi.yaml</openApiFileName>
                <serverBaseUrl>http://localhost/</serverBaseUrl>
            </configuration>
            <executions>
                <execution>
                    <phase>compile</phase>
                    <goals>
                        <goal>oas-generate</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

Configuration for configuration

name description
packageLocations Mandatory param to pass the packageLocation name(s) where Spring Controllers are.
openApiDirectory Path of the directory where you want to generate the Open API Specification yaml file. Defaults to target/generated-sources/swagger/
openApiFileName Name of the Open API Specification yaml file. Defaults to openapi3.yaml
serverBaseUrl Server URL. Default to localhost

#Build the source

  • mvn clean install
  • mcn clean install -DskipTests -- To skip the test

#Dependency conflicts If you face any dependency conflict after adding the plugin, use the below command to exclude duplicate dependency:

mvn dependency:tree

An example to exclude slf4j-log4j12 :

        <dependency>
            <groupId>uk.ac.ebi.uniprot</groupId>
            <artifactId>openapi-maven-plugin</artifactId>
            <version>${openapi-maven-plugin.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-log4j12</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

Credit

The project uses codes or inspires from the codes from the below 3 projects. Thanks to them for writing such code.

openapi-spring-maven-plugin's People

Contributors

ahmadshadab avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.