kandi background
Explore Kits

swagger-maven-plugin | SpringMVC supported maven build plugin | REST library

 by   kongchen Java Version: Current License: Apache-2.0

 by   kongchen Java Version: Current License: Apache-2.0

Download this library from

kandi X-RAY | swagger-maven-plugin Summary

swagger-maven-plugin is a Java library typically used in Web Services, REST, Swagger applications. swagger-maven-plugin has no bugs, it has no vulnerabilities, it has build file available, it has a Permissive License and it has high support. You can download it from GitHub, Maven.
This plugin enables your Swagger-annotated project to generate Swagger specs and customizable, templated static documents during the maven build phase. Unlike swagger-core, swagger-maven-plugin does not actively serve the spec with the rest of the application; it generates the spec as a build artifact to be used in downstream Swagger tooling.
Support
Support
Quality
Quality
Security
Security
License
License
Reuse
Reuse

kandi-support Support

  • swagger-maven-plugin has a highly active ecosystem.
  • It has 680 star(s) with 420 fork(s). There are 56 watchers for this library.
  • It had no major release in the last 12 months.
  • There are 273 open issues and 282 have been closed. On average issues are closed in 115 days. There are 30 open pull requests and 0 closed requests.
  • It has a positive sentiment in the developer community.
  • The latest version of swagger-maven-plugin is current.
swagger-maven-plugin Support
Best in #REST
Average in #REST
swagger-maven-plugin Support
Best in #REST
Average in #REST

quality kandi Quality

  • swagger-maven-plugin has 0 bugs and 0 code smells.
swagger-maven-plugin Quality
Best in #REST
Average in #REST
swagger-maven-plugin Quality
Best in #REST
Average in #REST

securitySecurity

  • swagger-maven-plugin has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • swagger-maven-plugin code analysis shows 0 unresolved vulnerabilities.
  • There are 0 security hotspots that need review.
swagger-maven-plugin Security
Best in #REST
Average in #REST
swagger-maven-plugin Security
Best in #REST
Average in #REST

license License

  • swagger-maven-plugin is licensed under the Apache-2.0 License. This license is Permissive.
  • Permissive licenses have the least restrictions, and you can use them in most projects.
swagger-maven-plugin License
Best in #REST
Average in #REST
swagger-maven-plugin License
Best in #REST
Average in #REST

buildReuse

  • swagger-maven-plugin releases are not available. You will need to build from source code and install.
  • Deployable package is available in Maven.
  • Build file is available. You can build the component from source.
  • Installation instructions are not available. Examples and code snippets are available.
  • It has 12982 lines of code, 690 functions and 122 files.
  • It has medium code complexity. Code complexity directly impacts maintainability of the code.
swagger-maven-plugin Reuse
Best in #REST
Average in #REST
swagger-maven-plugin Reuse
Best in #REST
Average in #REST
Top functions reviewed by kandi - BETA

kandi has reviewed swagger-maven-plugin and discovered the below as its top functions. This is intended to give you an instant insight into swagger-maven-plugin implemented functionality, and help decide if they suit your requirements.

  • Parse the API method .
    • Executes the plugin .
      • Updates the API response with the given ApiResponse annotation .
        • Loads the model modifier
          • Extract parameters from model annotation .
            • Get path .
              • Sort the Swagger
                • Generates the exception mapping .
                  • Gets the security scheme definition by type .
                    • Set info from info annotation

                      Get all kandi verified functions for this library.

                      Get all kandi verified functions for this library.

                      swagger-maven-plugin Key Features

                      Supports Swagger Spec 2.0

                      Supports SpringMvc & JAX-RS

                      Quickly generates swagger.json and static document by mvn compile

                      Use Handlebars as template to customize the static document.

                      swagger-maven-plugin Examples and Code Snippets

                      See all related Code Snippets

                      Usage

                      copy iconCopydownload iconDownload
                      <build>
                      	<plugins>
                      		<plugin>
                      			<groupId>com.github.kongchen</groupId>
                      			<artifactId>swagger-maven-plugin</artifactId>
                      			<version>${swagger-maven-plugin-version}</version>
                      			<configuration>
                      				<apiSources>
                      					<apiSource>
                      						...
                      					</apiSource>
                      				</apiSources>
                      			</configuration>
                      			<executions>
                      				<execution>
                      					<phase>compile</phase>
                      					<goals>
                      						<goal>generate</goal>
                      					</goals>
                      				</execution>
                      			</executions>
                      		</plugin>
                      	</plugins>
                      </build>
                      

                      Configuration for

                      copy iconCopydownload iconDownload
                      <securityDefinition>
                          <name>MybasicAuth</name>
                          <type>basic</type>
                      </securityDefinition>
                      

                      Sample model substitution

                      copy iconCopydownload iconDownload
                      com.foo.bar.PetName : java.lang.String
                      

                      Install/Deploy

                      copy iconCopydownload iconDownload
                      <swaggerDirectory>${project.build.directory}/swagger-ui</swaggerDirectory>
                      <attachSwaggerArtifact>true</attachSwaggerArtifact>
                      
                      

                      A Sample Configuration

                      copy iconCopydownload iconDownload
                      <project>
                      ...
                      <build>
                      <plugins>
                      <plugin>
                          <groupId>com.github.kongchen</groupId>
                          <artifactId>swagger-maven-plugin</artifactId>
                          <version>3.0.0</version>
                          <configuration>
                              <apiSources>
                                  <apiSource>
                      	            <springmvc>true</springmvc>
                                      <locations>
                                          <location>com.wordnik.swagger.sample</location>
                                      </locations>
                                      <schemes>
                                          <scheme>http</scheme>
                                          <scheme>https</scheme>
                                      </schemes>
                                      <host>www.example.com:8080</host>
                                      <basePath>/api</basePath>
                                      <info>
                                          <title>Swagger Maven Plugin Sample</title>
                                          <version>v1</version>
                                          <!-- use markdown here because I'm using markdown for output,
                                          if you need to use html or other markup language, you need to use your target language,
                                           and note escape your description for xml -->
                                          <description>
                                              This is a sample.
                                          </description>
                                          <termsOfService>
                                              http://www.github.com/kongchen/swagger-maven-plugin
                                          </termsOfService>
                                          <contact>
                                              <email>kongchen@gmail.com</email>
                                              <name>Kong Chen</name>
                                              <url>http://kongch.com</url>
                                          </contact>
                                          <license>
                                              <url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
                                              <name>Apache 2.0</name>
                                          </license>
                                      </info>
                                      <securityDefinitions>
                                          <securityDefinition>
                                              <name>basicAuth</name>
                                              <type>basic</type>
                                          </securityDefinition>
                                          <securityDefinition>
                                              <json>/securityDefinition.json</json>
                                          </securityDefinition>
                                      </securityDefinitions>
                                      <responseMessageOverrides>
                                          <responseMessageOverride>
                                              <code>401</code>
                                              <message>Unauthenticated - could not authenticate the user.</message>
                                          </responseMessageOverride>
                                          <responseMessageOverride>
                                              <code>403</code>
                                              <message>Forbidden - the user does not have the required permissions to execute this request.</message>
                                          </responseMessageOverride>
                                      </responseMessageOverrides>
                      
                                      <!-- Support classpath or file absolute path here.
                                      1) classpath e.g: "classpath:/markdown.hbs", "classpath:/templates/hello.html"
                                      2) file e.g: "${basedir}/src/main/resources/markdown.hbs",
                                          "${basedir}/src/main/resources/template/hello.html" -->
                                      <templatePath>${basedir}/src/test/resources/strapdown.html.hbs</templatePath>
                                      <outputPath>${basedir}/generated/document.html</outputPath>
                                      <swaggerDirectory>${basedir}/generated/swagger-ui</swaggerDirectory>
                                      <swaggerApiReader>com.wordnik.swagger.jaxrs.reader.DefaultJaxrsApiReader</swaggerApiReader>
                                      <attachSwaggerArtifact>true</attachSwaggerArtifact>
                                      <modelConverters>io.swagger.validator.BeanValidator</modelConverters>
                                      <swaggerExtensions>
                                          <swaggerExtension>com.example.VendorExtension</swaggerExtension>
                                      </swaggerExtensions>
                                      <enabledObjectMapperFeatures>
                                          <feature>com.fasterxml.jackson.databind.SerializationFeature.WRITE_ENUMS_USING_TO_STRING</feature>
                                          <feature>com.fasterxml.jackson.core.JsonParser$Feature.ALLOW_NUMERIC_LEADING_ZEROS</feature>
                                      </enabledObjectMapperFeatures>
                                      <disabledObjectMapperFeatures>
                                          <feature>com.fasterxml.jackson.databind.SerializationFeature.FAIL_ON_EMPTY_BEANS</feature>
                                      </disabledObjectMapperFeatures>
                                      <operationIdFormat>{{className}}_{{methodName}}_{{httpMethod}}</operationIdFormat>
                                      <externalDocs>
                                          <description>Example external docs</description>
                                          <url>https://example.com/docs</url>
                                      </externalDocs>
                                  </apiSource>
                              </apiSources>
                          </configuration>
                          <executions>
                              <execution>
                                  <phase>compile</phase>
                                  <goals>
                                      <goal>generate</goal>
                                  </goals>
                              </execution>
                          </executions>
                          <dependencies>
                              <!-- Adding dependency to swagger-hibernate-validations to enable the BeanValidator as a custom
                                   model converter -->
                              <dependency>
                                  <groupId>io.swagger</groupId>
                                  <artifactId>swagger-hibernate-validations</artifactId>
                                  <version>1.5.6</version>
                              </dependency>
                          </dependencies>
                      </plugin>
                      ...
                      </plugins>
                      </build>
                      </project>
                      

                      1. SNAPSHOT Version

                      copy iconCopydownload iconDownload
                      <pluginRepositories>
                        <pluginRepository>
                          <id>sonatype-snapshot</id>
                          <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
                          <releases>
                            <enabled>false</enabled>
                          </releases>
                          <snapshots>
                            <enabled>true</enabled>
                          </snapshots>
                        </pluginRepository>
                      </pluginRepositories>
                      

                      2. Dependency conflicts

                      copy iconCopydownload iconDownload
                      mvn dependency:tree
                      

                      3. Building from source

                      copy iconCopydownload iconDownload
                      mvn install
                      

                      How to generate OpenAPI specification in WebFlux project as part of maven build without starting service

                      copy iconCopydownload iconDownload
                      <plugin>
                          <groupId>io.openapitools.swagger</groupId>
                          <artifactId>swagger-maven-plugin</artifactId>
                          <version>2.1.4</version>
                          <executions>
                              <execution>
                                  <goals>
                                      <goal>generate</goal>
                                  </goals>
                              </execution>
                          </executions>
                          <configuration>
                              <swaggerConfig>
                                  <servers>
                                      <server>
                                          <url>https://www.example.com:8080</url>
                                      </server>
                                  </servers>
                                  <info>
                                      <title>${project.name}</title>
                                      <description>${project.description}</description>
                                      <version>{project.version}</version>
                                      <contact>
                                          <name>Some Name</name>
                                          <url>example.com</url>
                                          <email>help@example.com</email>
                                      </contact>
                                  </info>
                              </swaggerConfig>
                              <resourcePackages>com.example.mypackages</resourcePackages>
                              <useResourcePackagesChildren>true</useResourcePackagesChildren>
                              <outputDirectory>${project.basedir}/generated/openapi/</outputDirectory>
                              <outputFilename>openApiSpec</outputFilename>
                              <outputFormats>YAML</outputFormats>
                              <prettyPrint>true</prettyPrint>
                              <attachSwaggerArtifact>true</attachSwaggerArtifact>
                          </configuration>
                      </plugin>
                      
                      <!-- Use the below plugin if you want to generate an HTML client (Swagger UI) using the above specification -->
                      <plugin>
                          <groupId>io.swagger.codegen.v3</groupId>
                          <artifactId>swagger-codegen-maven-plugin</artifactId>
                          <version>3.0.21</version>
                          <executions>
                              <execution>
                                  <phase>prepare-package</phase>
                                  <goals>
                                      <goal>generate</goal>
                                  </goals>
                                  <configuration>
                                      <inputSpec>${project.basedir}/generated/openapi/openApiSpec.yaml</inputSpec>
                                      <language>html2</language>
                                      <output>${project.basedir}/generated/openapi</output>
                                  </configuration>
                              </execution>
                          </executions>
                      </plugin>
                      

                      Jersey 1.x - Uplifting Swagger 1.x to 2.x

                      copy iconCopydownload iconDownload
                      <plugin>
                         <groupId>io.openapitools.swagger</groupId>
                         <artifactId>swagger-maven-plugin</artifactId>
                         <version>2.1.4</version>
                         <executions>
                            <execution>
                               <goals>
                                  <goal>generate</goal>
                               </goals>
                            </execution>
                         </executions>
                         <configuration>
                            <swaggerConfig>
                               <servers>
                                  <server>
                                     <url>https://www.example.com:8080/cas/api</url>
                                  </server>
                               </servers>
                               <info>
                                  <title>${project.name}</title>
                                  <description>${project.description}</description>
                                  <version>${project.version}</version>
                               </info>
                            </swaggerConfig>
                            <resourcePackages>com.cerner.careaware.rest.personnel</resourcePackages>
                            <useResourcePackagesChildren>true</useResourcePackagesChildren>
                            <outputDirectory>${basedir}/generated/openapi/</outputDirectory>
                            <outputFilename>openApiSpec</outputFilename>
                            <outputFormats>JSON,YAML</outputFormats>
                            <prettyPrint>true</prettyPrint>
                            <attachSwaggerArtifact>true</attachSwaggerArtifact>
                         </configuration>
                      </plugin>
                      

                      How to use @Api swagger annotation in sub-resource class?

                      copy iconCopydownload iconDownload
                         @Api(hidden = true, authorizations = {
                           @Authorization(value = "auth", scopes = {})
                      })
                      public class SubResourceA {
                      
                          @GET
                          ...
                      }
                      

                      @BeanParam not documented when annotated with @Parameter

                      copy iconCopydownload iconDownload
                      public class Oauth2AuthorizationRequest {
                          // Use the @Parameter annotation to document the attribute.
                          @HeaderParam("Authorization")
                          @Parameter(description = "Authorization header")
                          String authorization;
                      
                          // If the attribute is a @FormParam, use the @Schema annotation.
                          @FormParam("client_id")
                          @Schema(description = "The id of the client")
                          String client_id;
                      
                          // If the attribute is a @FormParam and is required, 
                          // use the @Schema annotation for the description
                          // and the @Parameter one to set it as required.
                          @FormParam("grant_type")
                          @Schema(description = "Should be either \"credentials\" or \"password\"")
                          @Parameter(required = true)
                          String grant_type;
                      }
                      
                      @GET
                      @Path("/authorize")
                      @Operation(summary = "Summary", description = "Description")
                      Response authorize(
                          // No more annotation on the @BeanParam
                          @BeanParam Oauth2AuthorizationRequest request,
                          @Parameter(
                              description = "Session id",
                              name = "sessionId",
                              required = true
                          )
                          @CookieParam("sessionId") String sessionId
                      );
                      
                      public class Oauth2AuthorizationRequest {
                          // Use the @Parameter annotation to document the attribute.
                          @HeaderParam("Authorization")
                          @Parameter(description = "Authorization header")
                          String authorization;
                      
                          // If the attribute is a @FormParam, use the @Schema annotation.
                          @FormParam("client_id")
                          @Schema(description = "The id of the client")
                          String client_id;
                      
                          // If the attribute is a @FormParam and is required, 
                          // use the @Schema annotation for the description
                          // and the @Parameter one to set it as required.
                          @FormParam("grant_type")
                          @Schema(description = "Should be either \"credentials\" or \"password\"")
                          @Parameter(required = true)
                          String grant_type;
                      }
                      
                      @GET
                      @Path("/authorize")
                      @Operation(summary = "Summary", description = "Description")
                      Response authorize(
                          // No more annotation on the @BeanParam
                          @BeanParam Oauth2AuthorizationRequest request,
                          @Parameter(
                              description = "Session id",
                              name = "sessionId",
                              required = true
                          )
                          @CookieParam("sessionId") String sessionId
                      );
                      

                      Swagger/OpenAPI 3.0 generation - Endpoint with generic list from an interface does not show up in documentation

                      copy iconCopydownload iconDownload
                         <!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger-ui -->
                      <dependency>
                          <groupId>io.springfox</groupId>
                          <artifactId>springfox-swagger-ui</artifactId>
                          <version>2.9.2</version>
                      </dependency>
                      

                      See all related Code Snippets

                      Community Discussions

                      Trending Discussions on swagger-maven-plugin
                      • How to add a goal to release:perform phase of maven-release-plugin
                      • How to generate OpenAPI specification in WebFlux project as part of maven build without starting service
                      • Jersey 1.x - Uplifting Swagger 1.x to 2.x
                      • How to use @Api swagger annotation in sub-resource class?
                      • @BeanParam not documented when annotated with @Parameter
                      • Swagger/OpenAPI 3.0 generation - Endpoint with generic list from an interface does not show up in documentation
                      Trending Discussions on swagger-maven-plugin

                      QUESTION

                      How to add a goal to release:perform phase of maven-release-plugin

                      Asked 2021-Apr-22 at 18:07

                      I use the swagger-maven-plugin from kongchen. Additionally I use the maven-release-plugin. The swagger.json which is generated from swagger-maven-plugin is not part of the repo. If I build the application with mvn package the swagger.json is generated and part of the jar.

                      If I release the app with maven-release-plugin the swagger.json is not part of the jar-file. I checked the logs and saw that maven-release-plugin has three steps - release:clean, release:prepare and perform.

                      release:clean - cleans the workspace

                      release:prepare - logs show that the swagger-maven-plugin works and generated the swagger.json

                      release:perform - logs show that perform is composed of three phases (verify-completed-prepare-phases, checkout-prjoect-from-scm and run-perform-goals). I think this means that the whole project is checked out again and therefore the generated file is gone (how great is that...).

                      How can I add another phase to release:perform?

                      I found the following documentation https://maven.apache.org/maven-release/maven-release-manager/index.html and know that additional preparation goals can be added https://maven.apache.org/maven-release/maven-release-plugin/examples/run-goals-before-commit.html

                      I need to add goals to the release:perform step (for example compile or package). How can I achieve that?

                      Thanks!

                               <plugin>
                                  <groupId>com.github.kongchen</groupId>
                                  <artifactId>swagger-maven-plugin</artifactId>
                                  <version>3.1.8</version>
                                  <configuration>
                                      <apiSources>
                                          <apiSource>
                                              <basePath>/.../api</basePath>
                                              <locations>
                                                  <location>not.public</location>
                                              </locations>
                                              <info>
                                                  <title>${project.artifactId}</title>
                                                  <version>${project.version}</version>
                                              </info>
                                              <outputFormats>json</outputFormats>
                                              <swaggerDirectory>${basedir}/src/main/resources/META-INF/path</swaggerDirectory>
                                          </apiSource>
                                      </apiSources>
                                  </configuration>
                                  <executions>
                                      <execution>
                                          <phase>compile</phase>
                                          <goals>
                                              <goal>generate</goal>
                                          </goals>
                                      </execution>
                                  </executions>
                              </plugin>
                      

                      ANSWER

                      Answered 2021-Apr-22 at 18:07

                      You need to set the goals parameter of release:perform. This contains the goals that are executed in the "inner build".

                      Source https://stackoverflow.com/questions/67218029

                      Community Discussions, Code Snippets contain sources that include Stack Exchange Network

                      Vulnerabilities

                      No vulnerabilities reported

                      Install swagger-maven-plugin

                      You can download it from GitHub, Maven.
                      You can use swagger-maven-plugin like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the swagger-maven-plugin component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .

                      Support

                      For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .

                      DOWNLOAD this Library from

                      Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
                      over 430 million Knowledge Items
                      Find more libraries
                      Reuse Solution Kits and Libraries Curated by Popular Use Cases
                      Explore Kits

                      Save this library and start creating your kit

                      Explore Related Topics

                      Share this Page

                      share link
                      Consider Popular REST Libraries
                      Try Top Libraries by kongchen
                      Compare REST Libraries with Highest Support
                      Compare REST Libraries with Highest Quality
                      Compare REST Libraries with Highest Security
                      Compare REST Libraries with Permissive License
                      Compare REST Libraries with Highest Reuse
                      Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
                      over 430 million Knowledge Items
                      Find more libraries
                      Reuse Solution Kits and Libraries Curated by Popular Use Cases
                      Explore Kits

                      Save this library and start creating your kit

                      • © 2022 Open Weaver Inc.