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:
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:
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. 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(). 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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.