从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 trymvn 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 addswagger2markup-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
最满意答案
复合图案?
为常见行为定义接口(
Component
)(update
方法)让所有组件实现
Component
(可碰撞,重力,控制等)让父类
SpaceShip
维护一个Component
列表让父类
SpaceShip
实现Component
。从客户端的角度来看,
SpaceShip
是一个提供update
方法的对象。在内部,在它的
update
方法中,SpaceShip
调用所有Component
的update
Composite pattern?
Define an interface (
Component
) for the common behaviour (theupdate
method)Let all the components impletment
Component
(Collidable, Gravity, Controls etc)Let the parent class
SpaceShip
maintain a list ofComponent
sLet the parent class
SpaceShip
implementComponent
as well.From client perspective
SpaceShip
is an object that providesupdate
method.Internally, in it's
update
method,SpaceShip
callsupdate
on all theComponent
s
相关问答
更多-
装饰设计模式问题?(Decorator design pattern issue?)[2023-09-20]
例如,他们谈论的是检查饮料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 @decorator与装饰器设计模式有关吗?(Is python @decorator related to the decorator design pattern?)[2023-07-08]
不,这不是一个奇怪的巧合,不,python @decorators不实现GOF装饰器模式。 GOF(四人帮,以“设计模式”这本书的四位作者命名)装饰模式增加了“装饰”来改变对象的行为。 它通过创建可应用于未装饰基类的“装饰器”类来实现此目的。 Python装饰器为功能或类添加了“装饰”。 这些装饰器本质上是包装或修改函数/类的函数。 两者都是类似的,你可以重复使用装饰器多次添加相同的功能,但装饰器模式要求装饰器与你可以装饰的类一起设计。 Python装饰器反而只是在任何类的函数上进行工作。 No, it's ... -
观察者设计模式(Observer Design Pattern)[2022-07-11]
经典的设计模式不涉及并行和线程。 你必须为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 ...
-
是否有一个设计模式,其功能类似于观察者与装饰器的混合?(Is there a design pattern that functions like observer mixed with decorator?)[2024-04-14]
复合图案? 为常见行为定义接口( 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 ...
-
观察者设计模式问题(observer design pattern question)[2022-03-31]
第二个例子看起来不错,但我不确定是否在OrderItemPickObserver类的update方法中创建新的Position对象。 相反,我建议将Position对象保持为OrderItem类的属性,以便您可以从外部设置它。 class OrderItem extends Observable { private $_position; public function setPosition($position){ $this->_posit ...