kongchen / swagger-maven-plugin

JAX-RS & SpringMVC supported maven build plugin, helps you generate Swagger JSON and API document in build phase.
http://kongchen.github.io/swagger-maven-plugin/
Apache License 2.0
761 stars 451 forks source link

ApiDocumentMojo.execute looks for html template even when <templatePath> is not defined #637

Open wedsa5 opened 6 years ago

wedsa5 commented 6 years ago

During ApiDocumentMojo.execute(), AbstractDocumentSource.toDocuments() gets called even when the is not set. This causes a java.io.FileNotFoundException since it tries to look for src/main/resources/swaggertemplates/strapdown.html.hbs which does not exist.

It should be able to generate the swagger.json without using a template to generate an html document.

pom.xml plugin definition:

<plugin>
    <groupId>com.github.kongchen</groupId>
    <artifactId>swagger-maven-plugin</artifactId>
    <version>3.1.7</version>
    <configuration>
        <apiSources>
            <apiSource>
                <springmvc>false</springmvc>
                <locations>com.[omitted]</locations>
                <schemes>${swagger.plugin.schemes}</schemes>
                <host>${swagger.plugin.host}</host>
                <basePath>${swagger.plugin.basePath}</basePath>
                <info>
                    <title>[omitted] Service</title>
                    <version>${project.version}</version>
                    <description>[omitted] Service - REST Endpoints</description>
                </info>
                <swaggerDirectory>${project.build.outputDirectory}/META-INF/documentation/swagger</swaggerDirectory>
                <attachSwaggerArtifact>true</attachSwaggerArtifact>
            </apiSource>
        </apiSources>
    </configuration>
    <executions>
        <execution>
            <phase>compile</phase>
            <goals>
                <goal>generate</goal>
            </goals>
        </execution>
    </executions>
</plugin>

As far as I understand, the templatePath and outputDirectory are optional parameters.

Postremus commented 6 years ago

I looked into this a bit:

Could you please look at the swagger-maven-plugin in your effective pom, and see if there are any oious mistakes