[英]Error while compiling swagger-codegen java Petstore sdk
I am trying to generate a java API using swagger-codegen (3.0.0) I am using the swagger-codegen-cli-3.0.24.jar version of codegen jar. I am trying to generate a java API using swagger-codegen (3.0.0) I am using the swagger-codegen-cli-3.0.24.jar version of codegen jar. I ran the following command to generate the SDK for the sample petstore project:
我运行以下命令为示例 petstore 项目生成 SDK:
java -jar swagger-codegen-cli.jar generate -i code/swagger-codegen/modules/swagger-codegen/src/test/resources/3_0_0/petstore.json -l java -o out/pet-java
When I am compiling the generated sdk project:当我编译生成的 sdk 项目时:
cd out/pet-java
mvn clean package
I am getting the below error:我收到以下错误:
Compilation failure
[ERROR] out/pet-java/src/main/java/io/swagger/client/model/Pet.java:[87,34] cannot find symbol
[ERROR] symbol: method nextObject()
[ERROR] location: variable jsonReader of type com.google.gson.stream.JsonReader
it is using <gson-version>2.8.1</gson-version> as dependency.
Ultimately the real answer is for swagger-codegen to fix their regression.最终,真正的答案是让 swagger-codegen 修复他们的回归。 They've admitted that it's a problem.
他们承认这是个问题。 In the mean time I've worked around the issue for my particular situation.
同时,我已经针对我的特殊情况解决了这个问题。 To demonstrate the types of changes that are necessary, see below:
要演示必要的更改类型,请参见下文:
In some files instead of nextObject(), there may be a call to next().在某些文件而不是 nextObject() 中,可能会调用 next()。 The solution is the same, however.
但是,解决方案是相同的。
Apologies for any confusion in the diff.对差异中的任何混淆表示歉意。 Apparently I left the original lines in the file commented out below the working replacement line.
显然,我将文件中的原始行在工作替换行下方注释掉了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.