Skip to content

Example Spring Boot 2.0.3 pom.xml (version 3.7.1)

John Oss edited this page Jul 26, 2018 · 1 revision

Example that successfully generates a swagger.yaml with basic auth for Spring Boot 2.0.3.

<plugin>
    <!-- Generates swagger.json -->
    <groupId>com.github.kongchen</groupId>
    <artifactId>swagger-maven-plugin</artifactId>
    <version>3.1.7</version>
    <executions>
        <execution>
            <phase>compile</phase>
            <goals>
                <goal>generate</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <apiSources>
            <apiSource>
                <springmvc>true</springmvc>
                <locations>com.example.project</locations>
                <schemes>http,https</schemes>
                <info>
                    <title>example</title>
                    <description>
                    This is the documentation for this project
                    </description>
                    <contact>
                        <email>[email protected]</email>
                        <name>User Name</name>
                        <url>https://example.com</url>
                    </contact>
                    <version>0.0.1</version>
                </info>
                <securityDefinitions>
                    <securityDefinition>
                        <name>basicAuth</name>
                        <type>basic</type>
                    </securityDefinition>
                </securityDefinitions>
                <swaggerApiReader>com.github.kongchen.swagger.docgen.reader.SpringMvcApiReader</swaggerApiReader>
                <swaggerExtensions>com.github.kongchen.swagger.docgen.spring.SpringSwaggerExtension</swaggerExtensions>
                <modelConverters>io.swagger.validator.BeanValidator</modelConverters>
                <swaggerDirectory>${project.basedir}/docs/swagger</swaggerDirectory>
                <swaggerFileName>swagger</swaggerFileName>
                <outputFormats>yaml</outputFormats>
                <attachSwaggerArtifact>true</attachSwaggerArtifact>
            </apiSource>
        </apiSources>
    </configuration>
    <dependencies>
        <!-- Adding dependency to swagger-hibernate-validations to enable the BeanValidator for model converter -->
        <dependency>
            <groupId>io.swagger</groupId>
            <artifactId>swagger-hibernate-validations</artifactId>
            <version>1.5.20</version>
        </dependency>
    </dependencies>
</plugin>
Clone this wiki locally