首页 \ 问答 \ 从Swagger API文档生成PDF(抛出ArrayIndexOutOfBoundsException)(Generate PDF from Swagger API documentation (throwing ArrayIndexOutOfBoundsException))

从Swagger API文档生成PDF(抛出ArrayIndexOutOfBoundsException)(Generate PDF from Swagger API documentation (throwing ArrayIndexOutOfBoundsException))

我试图做的另一个问题: 从Swagger API文档生成PDF 。 我也在使用这个模板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 - > [Help 1]

我如何正确设置? 任何帮助表示赞赏。

PS:我甚asciidoctor-maven-plugin无法尝试asciidoctor-maven-plugin因为一旦我添加swagger2markup-maven-plugin作为asciidoctor-maven-plugin ,一切都会爆炸:(

一些属性

<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>

招摇 - Maven的插件

<!-- 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的插件

<!-- 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>

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>

原文:https://stackoverflow.com/questions/39651978
更新时间:2023-03-24 13:03

最满意答案

复合图案?

为常见行为定义接口( Component )( update方法)

让所有组件实现Component (可碰撞,重力,控制等)

让父类SpaceShip维护一个Component列表

让父类SpaceShip实现Component

从客户端的角度来看, SpaceShip是一个提供update方法的对象。

在内部,在它的update方法中, SpaceShip调用所有Componentupdate


Composite pattern?

Define an interface (Component) for the common behaviour (the update method)

Let all the components impletment Component (Collidable, Gravity, Controls etc)

Let the parent class SpaceShip maintain a list of Components

Let the parent class SpaceShip implement Component as well.

From client perspective SpaceShip is an object that provides update method.

Internally, in it's update method, SpaceShip calls update on all the Components

相关问答

更多
  • 例如,他们谈论的是检查饮料2类型的代码 if (beverage2 instanceof DarkRoast) { } 一旦用Mocha或Whip装饰drink2,它就不再是DarkRoast了。 编辑:我还应该提一下,通常使用instanceof表示一个不完整使用OO的糟糕设计,这表示它在某些情况下很有用。 They're talking about code that checks the type of beverage2, for example if (be ...
  • 你不能通过事件/代表实现它吗? 这是在C#和其他.Net语言中实现Observer模式的标准方法。 Can't you implement it via events/delegates? This is the standard way to implement the Observer pattern in C# and other .Net languages.
  • 不,这不是一个奇怪的巧合,不,python @decorators不实现GOF装饰器模式。 GOF(四人帮,以“设计模式”这本书的四位作者命名)装饰模式增加了“装饰”来改变对象的行为。 它通过创建可应用于未装饰基类的“装饰器”类来实现此目的。 Python装饰器为功能或类添加了“装饰”。 这些装饰器本质上是包装或修改函数/类的函数。 两者都是类似的,你可以重复使用装饰器多次添加相同的功能,但装饰器模式要求装饰器与你可以装饰的类一起设计。 Python装饰器反而只是在任何类的函数上进行工作。 No, it's ...
  • 经典的设计模式不涉及并行和线程。 你必须为N个观察者产生N个线程。 但要小心,因为它们之间的交互必须以线程安全的方式完成。 Classic design patterns do not involve parallelism and threading. You'd have to spawn N threads for the N observers. Be careful though since their interaction to this will have to be done in a t ...
  • 根据具体问题,它可能会也可能不会引用主题。 Subject可能只调用update()函数并在Observer中设置一些值,因此Observer不需要引用。 或者它可以通知观察者已经发生了变化,观察者将通过它所具有的参考来联系主题并获得新值。 如果观察者需要向主体通知某事,也可以使用实施中的参考。 It may or may not have a reference to the Subject, depending on the concrete problem. The Subject might onl ...
  • 复合图案? 为常见行为定义接口( Component )( update方法) 让所有组件实现Component (可碰撞,重力,控制等) 让父类SpaceShip维护一个Component列表 让父类SpaceShip实现Component 。 从客户端的角度来看, SpaceShip是一个提供update方法的对象。 在内部,在它的update方法中, SpaceShip调用所有Component的update Composite pattern? Define an interface (Compon ...
  • 是调度Event很慢,如果您的目标是性能,您可以选择自己的事件系统,或者如果您不想重新发明轮子,请查看Robert Penner的as3信号库 。 Yes dispatching Event are slow, if performance are you goal you can go for your own event system or if you don't want to reinvent the wheel take a look at the as3 signals library fro ...
  • 装饰者是一种通用模式; 它可能意味着多种东西,具体取决于域名。 它们也被称为“包装器”或“适配器”,IMO更适用于功能包装范例。 也就是说,不要过于依赖精确的措辞:它们是模式 ,而不是一成不变的法则。 Decorators are a generic pattern; it can mean multiple things depending on the domain. They're also called "wrappers" or "adapters", which IMO is more appl ...
  • 在拥有要绑定的方法的实例之前,不能注册绑定的方法。 单独的函数装饰器没有用于检测何时创建实例的上下文。 您可以使用元类/装饰器组合方法: class ObservingMeta(type): def __call__(cls, *args, **kw): instance = super(ObservingMeta, cls).__call__(*args, **kw) for attr in vars(cls).values(): if ...
  • 第二个例子看起来不错,但我不确定是否在OrderItemPickObserver类的update方法中创建新的Position对象。 相反,我建议将Position对象保持为OrderItem类的属性,以便您可以从外部设置它。 class OrderItem extends Observable { private $_position; public function setPosition($position){ $this->_posit ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。