首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >从Swagger文档生成PDF (抛出ArrayIndexOutOfBoundsException)

从Swagger文档生成PDF (抛出ArrayIndexOutOfBoundsException)
EN

Stack Overflow用户
提问于 2016-09-23 03:12:49
回答 2查看 3.7K关注 0票数 0

我正试着做另一个问题:Generate PDF from Swagger API documentation。我还使用了这个模板https://github.com/Swagger2Markup/swagger2markup-maven-project-template/blob/master/pom.xml

到目前为止,我已经设置了swagger-maven-plugin,并成功地生成了swagger.json和swagger.yaml :)

问题是当我添加swagger2markup-maven-plugin和尝试mvn compile时。我得到:

错误内部错误: java.lang.ArrayIndexOutOfBoundsException: 10364 ->帮助1

我怎么才能正确设置这个呢?任何帮助都是非常感谢的。

PS:我甚至不能尝试asciidoctor-maven-plugin,因为当我将swagger2markup-maven-plugin作为插件添加时,一切都会崩溃:

若干性质

代码语言:javascript
运行
复制
<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>

装腔作势

代码语言:javascript
运行
复制
<!-- 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>

Swagger2标记-maven-插件

代码语言:javascript
运行
复制
<!-- 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>
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-09-23 14:14:13

我找到了解决这个问题的方法。我应该摆脱所有的依赖关系和额外的配置,并使它更简单。

代码语言:javascript
运行
复制
<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>

并使用mvn package执行它。

票数 0
EN

Stack Overflow用户

发布于 2017-04-06 10:50:01

IndexOutOfBoundsException来自XML中的处理指令,即:

<?m2e execute onConfiguration?>

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39651978

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档