Swagger Maven Plugin

Maven plugin to generate OpenAPI documentation using Swagger.

Лицензия

Лицензия

Категории

Категории

Maven Компиляция и сборка Swagger Межпрограммное взаимодействие REST Frameworks
Группа

Группа

io.openapitools.swagger
Идентификатор

Идентификатор

swagger-maven-plugin
Последняя версия

Последняя версия

2.1.6
Дата

Дата

Тип

Тип

maven-plugin
Описание

Описание

Swagger Maven Plugin
Maven plugin to generate OpenAPI documentation using Swagger.
Ссылка на сайт

Ссылка на сайт

https://github.com/openapi-tools/swagger-maven-plugin
Система контроля версий

Система контроля версий

https://github.com/openapi-tools/swagger-maven-plugin/tree/master

Скачать swagger-maven-plugin

Как подключить последнюю версию

<plugin>
    <groupId>io.openapitools.swagger</groupId>
    <artifactId>swagger-maven-plugin</artifactId>
    <version>2.1.6</version>
</plugin>

Зависимости

compile (11)

Идентификатор библиотеки Тип Версия
io.swagger.core.v3 : swagger-jaxrs2 jar 2.1.7
javax.ws.rs : javax.ws.rs-api jar 2.1
org.slf4j : slf4j-api jar 1.7.29
org.apache.maven.plugin-tools : maven-plugin-annotations jar 3.5
org.apache.maven : maven-plugin-api jar 3.6.0
org.apache.maven : maven-core jar 3.6.0
org.apache.maven : maven-artifact jar 3.6.0
org.reflections : reflections jar 0.9.12
javax.xml.bind : jaxb-api Необязательный jar 2.3.0
com.fasterxml.jackson.core : jackson-databind jar 2.12.2
com.google.guava : guava jar 30.0-jre

test (9)

Идентификатор библиотеки Тип Версия
junit : junit jar 4.13.1
org.slf4j : slf4j-simple jar 1.7.29
org.mockito : mockito-core jar 3.2.0
org.apache.maven.plugin-testing : maven-plugin-testing-harness jar 3.3.0
org.apache.maven : maven-compat jar 3.6.0
io.openapitools.jackson.dataformat : jackson-dataformat-hal jar 1.0.8
org.codehaus.groovy : groovy-eclipse-compiler jar 2.7.0-01
org.codehaus.groovy : groovy-eclipse-batch jar 2.0.4-04
org.codehaus.groovy : groovy-all jar 1.8.0

Модули Проекта

Данный проект не имеет модулей.

Swagger Maven Plugin

This plugin is intended to use the Swagger Core library to generate OpenAPI documentation from a JAX-RS based REST service with as little change as possible. This allows for @SwaggerDefinition, @ReaderListener and ModelConverters to work the same way as with the core Swagger library.

Status

The plugin is considered production ready. The version 2.x.x of the plugin is supporting generation of OpenAPI version 3 specifications using Swagger 2.x. To generate OpenAPI version 2 specifications using Swagger 1.x use the latest 1.x.x version of the plugin.

Maven Central Javadoc Build status Known Vulnerabilities

Usage

To have Swagger generate the OpenAPI specifications as part of the build add in the plugin to the POM.

<build>
  <plugins>
    ...
    <plugin>
      <groupId>io.openapitools.swagger</groupId>
      <artifactId>swagger-maven-plugin</artifactId>
      <configuration>
        <resourcePackages>
          <resourcePackage>io.openapitools.swagger.example</resourcePackage>
          <resourcePackage>io.openapitools.swagger.example.alternate</resourcePackage>
        </resourcePackages>
        <outputDirectory>${basedir}/target/</outputDirectory>
        <outputFilename>swagger</outputFilename>
        <outputFormats>JSON,YAML</outputFormats>
        <prettyPrint>true</prettyPrint>
      </configuration>
      <executions>
        <execution>
          <goals>
            <goal>generate</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
    ...
  </plugins>
</build>

This will run the generation in the prepare-package lifecycle stage of the Maven build.

Specifying Packages with JAX-RS Endpoints

The packages containing JAX-RS endpoints must be configured using the resourcePackages element. See the minimal configuration above.

Properties of Swagger model

Most general properties of the Swagger model is configurable using the swaggerConfig element. Note this may also be configured through the @OpenAPIDefinition annotation - see Customizing your auto-generated Swagger Definitions.

<plugin>
  <groupId>io.openapitools.swagger</groupId>
  <artifactId>swagger-maven-plugin</artifactId>
  <configuration>
    <swaggerConfig>
      <servers>
        <server>
          <url>https://services.exmple.it/base/path</url>
          <description>Endpoint URL</description>
        </server>
      </servers>
      <info>
        <title>Title</title>
        <version>1.0.0</version>
        <termsOfService>Terms</termsOfService>
        <contact>
          <email>e@mail.com</email>
          <name>My Name</name>
          <url>https://google.com</url>
        </contact>
        <license>
          <url>https://license</url>
          <name>MIT</name>
        </license>
        <extensions>
          <x-custom-field-1>my-custom-field-1</x-custom-field-1>
          <x-custom-field-2>my-custom-field-2</x-custom-field-2>
        </extensions>
      </info>
      <descriptionFile>src/test/resources/descriptions.md</descriptionFile>
    </swaggerConfig>

Deploying

The generated OpenAPI specifications may be installed and deployed as Maven artifact. To enable this add the configuration parameter attachSwaggerArtifact.

<plugin>
  <groupId>io.openapitools.swagger</groupId>
  <artifactId>swagger-maven-plugin</artifactId>
  <configuration>
    <attachSwaggerArtifact>true</attachSwaggerArtifact>

Acknowledgement

Thanks to Yukai Kong for his work on Swagger Maven plugin. This plugin is heavily inspired by that.

io.openapitools.swagger

OpenAPI Tools

Tools around the OpenAPI specification and REST service design in general

Версии библиотеки

Версия
2.1.6
2.1.5
2.1.4
2.1.3
2.1.2
2.1.1
2.1.0
2.0.3
2.0.2
2.0.1
2.0.0
1.0.3
1.0.2
1.0.1