== Maven Plugin

Swagger2Markup provides a Maven plugin. The Maven plugin is published in JCenter and Maven Central.

NOTE: The Maven Plugin requires at least JDK 8.

=== Usage guide

Add the following snippet to your Maven POM file:

[source,xml, subs="specialcharacters,attributes"]
----
<pluginRepositories>
    <pluginRepository>
        <id>jcenter-snapshots</id>
        <name>jcenter</name>
        <url>http://oss.jfrog.org/artifactory/oss-snapshot-local/</url>
    </pluginRepository>
    <pluginRepository>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
        <id>jcenter-releases</id>
        <name>jcenter</name>
        <url>http://jcenter.bintray.com</url>
    </pluginRepository>
</pluginRepositories>

<build>
    <plugins>
      <plugin>
        <groupId>io.github.swagger2markup</groupId>
        <artifactId>swagger2markup-maven-plugin</artifactId>
        <version>{release-version}</version>
      </plugin>
    </plugins>
</build>
----

The plugin adds a new task goal `swagger2markup:convertSwagger2markup`. You can run the goal as follows:

`mvn swagger2markup:convertSwagger2markup` 

=== Configuration

You can customize the task by configuring a Map of <<Swagger2Markup properties>>.

[source,xml, subs="specialcharacters,attributes"]
----
<build>
    <plugins>
      <plugin>
        <groupId>io.github.swagger2markup</groupId>
        <artifactId>swagger2markup-maven-plugin</artifactId>
        <version>{release-version}</version>
        <configuration>
          <swaggerInput>${project.basedir}/src/docs/swagger/swagger_petstore.yaml</swaggerInput>
          <outputDir>${project.build.directory}/asciidoc</outputDir>
          <config>
            <swagger2markup.markupLanguage>ASCIIDOC</swagger2markup.markupLanguage>
          </config>
        </configuration>
      </plugin>
    </plugins>
</build>
----


[options="header"]
.Maven Plugin properties
|====
| Name | Description | Type |  Example
| swaggerInput | The URL or file path to the Swagger specification | String | `${project.basedir}/src/docs/swagger/swagger_petstore.yaml`  or `http://petstore.swagger.io/v2/swagger.json`
| outputDir | The directory where the output should be stored. | File | `${project.build.directory}/asciidoc` 
| outputFile | The file path (without extension) where the output should be stored. | File | `${project.build.directory}/asciidoc/swagger` 
| config | The Swagger2Markup properties to configure the converter | Map |  | 
|====

=== Example

You can copy the template project from GitHub to get started.

https://github.com/Swagger2Markup/swagger2markup-maven-project-template



