0

I am trying to do as this other question: Generate PDF from Swagger API documentation . I am also using this template https://github.com/Swagger2Markup/swagger2markup-maven-project-template/blob/master/pom.xml

So far I have set swagger-maven-plugin and successfully generated swagger.json and swagger.yaml :)

The problem is when I add swagger2markup-maven-plugin and when try mvn compile. I get:

[ERROR] Internal error: java.lang.ArrayIndexOutOfBoundsException: 10364 -> [Help 1]

How can I set this correctly? Any help is appreciated.

PS: I couldn't even try asciidoctor-maven-plugin since everything blows up as soon as I add swagger2markup-maven-plugin as a plugin :(

Some Properties

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <java.version>1.8</java.version>
    <swagger.directory>${project.basedir}/src/docs/swagger</swagger.directory>
    <asciidoc.directory>${project.build.directory}/asciidoc</asciidoc.directory>        
</properties>

<build>
    ...
    <plugins>
        <!-- swagger-maven-plugin GOES HERE. SEE BELOW -->
        <!-- swagger2markup-maven-plugin GOES HERE. SEE BELOW -->
    </plugins>
</build>

swagger-maven-plugin

<!-- Use the swagger maven plugin to generate swagger file from sources -->
<plugin>
    <groupId>com.github.kongchen</groupId>
    <artifactId>swagger-maven-plugin</artifactId>
    <version>3.1.4</version>
    <configuration>
        <apiSources>
            <apiSource>
                <springmvc>false</springmvc>
                <locations>
                    <location>com.company.com.support.service</location>
                </locations>
                <schemes>http,https</schemes>
                <host>my.host.net</host>
                <basePath>/myapi</basePath>
                <info>
                    <title>MyTitle</title>
                    <version>v1</version>
                    <description>MyDescription</description>
                    <termsOfService>http://my.terms</termsOfService>
                    <contact>
                        <email>me@email.com</email>
                        <name>Just Me</name>
                        <url>www.company.com</url>
                    </contact>
                    <license>
                        <url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
                        <name>Apache 2.0</name>
                    </license>
                </info>
                <outputPath>${swagger.directory}/document.html</outputPath>
                <swaggerDirectory>${swagger.directory}</swaggerDirectory>
                <outputFormats>json,yaml</outputFormats>
            </apiSource>
        </apiSources>
    </configuration>
    <executions>
        <execution>
            <?m2e execute onConfiguration?>
            <phase>compile</phase>
            <goals>
                <goal>generate</goal>
            </goals>
        </execution>
    </executions>
</plugin>

swagger2markup-maven-plugin

<!-- Use the swagger2markup plugin to generate asciidoc from swagger.json -->
<plugin>
    <groupId>io.github.swagger2markup</groupId>
    <artifactId>swagger2markup-maven-plugin</artifactId>
    <version>1.0.1</version>
    <dependencies>
        <dependency>
            <groupId>io.github.swagger2markup</groupId>
            <artifactId>swagger2markup-import-files-ext</artifactId>
            <version>1.0.0</version>
        </dependency>
        <dependency>
            <groupId>io.github.swagger2markup</groupId>
            <artifactId>swagger2markup</artifactId>
            <version>1.0.1</version>
        </dependency>
    </dependencies>
    <configuration>
        <swaggerInput>${swagger.directory}/swagger.yaml</swaggerInput>
        <outputDir>${asciidoc.directory}</outputDir>
        <config>
            <swagger2markup.markupLanguage>ASCIIDOC</swagger2markup.markupLanguage>
            <swagger2markup.pathsGroupedBy>TAGS</swagger2markup.pathsGroupedBy>
            <swagger2markup.extensions.dynamicOverview.contentPath>${project.basedir}/src/docs/asciidoc/extensions/overview</swagger2markup.extensions.dynamicOverview.contentPath>
            <swagger2markup.extensions.dynamicDefinitions.contentPath>${project.basedir}/src/docs/asciidoc/extensions/definitions</swagger2markup.extensions.dynamicDefinitions.contentPath>
            <swagger2markup.extensions.dynamicPaths.contentPath>${project.basedir}/src/docs/asciidoc/extensions/paths</swagger2markup.extensions.dynamicPaths.contentPath>
            <swagger2markup.extensions.dynamicSecurity.contentPath>${project.basedir}src/docs/asciidoc/extensions/security</swagger2markup.extensions.dynamicSecurity.contentPath>
        </config>
    </configuration>
    <executions>
        <execution>
            <?m2e execute onConfiguration?>
            <phase>generate-sources</phase>
            <goals>
                <goal>convertSwagger2markup</goal>
            </goals>
        </execution>
    </executions>
</plugin>
Community
  • 1
  • 1
nacho4d
  • 43,720
  • 45
  • 157
  • 240

2 Answers2

0

I found the way how to solve this. I should get rid of all the dependencies and extra configuration and make it simpler.

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <java.version>1.8</java.version>
    <swagger.directory>${project.build.directory}/generated-docs/swagger</swagger.directory>
    <asciidoctor.directory>${project.build.directory}/generated-docs/asciidoc</asciidoctor.directory>
</properties>

<build>
    <plugins>

        <!-- Use the swagger maven plugin to generate swagger file from sources -->
        <plugin>
            <groupId>com.github.kongchen</groupId>
            <artifactId>swagger-maven-plugin</artifactId>
            <version>3.1.4</version>
            <configuration>
                <apiSources>
                    <apiSource>
                        <springmvc>false</springmvc>
                        <locations>
                            <location>com.company.com.support.service</location>
                        </locations>
                        <schemes>http,https</schemes>
                        <host>my.host.net</host>
                        <basePath>/myapi</basePath>
                        <info>
                            <title>MyTitle</title>
                            <version>v1</version>
                            <description>MyDescription</description>
                            <termsOfService>Some Terms</termsOfService>
                            <contact>
                                <email>me@email.com</email>
                                <name>Just Me</name>
                                <url>www.company.com</url>
                            </contact>
                            <license>
                                <url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
                                <name>Apache 2.0</name>
                            </license>
                        </info>
                        <outputPath>${swagger.directory}/document.html</outputPath>
                        <swaggerDirectory>${swagger.directory}</swaggerDirectory>
                        <outputFormats>yaml</outputFormats>
                    </apiSource>
                </apiSources>
            </configuration>
            <executions>
                <execution>
                    <?m2e execute onConfiguration?>
                    <phase>compile</phase>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

        <!-- Use the swagger2markup to generate asciidoc from swagger file -->
        <plugin>
            <groupId>io.github.swagger2markup</groupId>
            <artifactId>swagger2markup-maven-plugin</artifactId>
            <version>1.0.1</version>
            <configuration>
                <swaggerInput>${swagger.directory}/swagger.yaml</swaggerInput>
                <outputFile>${asciidoctor.directory}/api-documentation</outputFile>
                <config>
                    <swagger2markup.markupLanguage>ASCIIDOC</swagger2markup.markupLanguage>
                </config>
            </configuration>
            <executions>
                <execution>
                    <phase>prepare-package</phase>
                    <goals>
                        <goal>convertSwagger2markup</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

And execute it with mvn package.

nacho4d
  • 43,720
  • 45
  • 157
  • 240
0

The IndexOutOfBoundsException is from your processing instruction in the XML, namely:

<?m2e execute onConfiguration?>

Pascal de Kloe
  • 523
  • 4
  • 12