Description
If we use the Retrofit2 generator with a swagger endpoint that returns a file, the corresponding retrofit method will return a java.io.file which is not supported by Retrofit: It throws a com.google.gson.stream.MalformedJsonException.
Swagger-codegen version
I've used the latest master branch, 2.3.0-SNAPSHOT.
Swagger declaration file content or url
# C:\temp\swagger.yaml
swagger: "2.0"
info:
version: "1.0.0"
title: "ImageRetrieval"
host: "boston2016.apistrat.com"
schemes:
- "http"
paths:
/images/{name}:
get:
summary: "Add a new pet to the store"
produces:
- "image/png"
parameters:
- in: path
name: name
required: true
type: string
responses:
200:
description: Image found
schema:
type: file # !!!
Command line used for generation
java -jar swagger-codegen-cli.jar generate -i C:/temp/swagger.yaml -o C:/temp/swagger/ -l java --library retrofit2 --additional-properties useRxJava2=true
Steps to reproduce
- Create the file
C:\temp\swagger.yaml and copy the content from above into it.
java -jar swagger-codegen-cli.jar generate -i C:/temp/swagger.yaml -o C:/temp/swagger/ -l java --library retrofit2 --additional-properties useRxJava2=true
- Open the file
C:\Temp\swagger\src\test\java\io\swagger\client\api\DefaultApiTest.java and insert the following test case:
@Test
public void imagesNameGetTest2() {
String name = "sponsor-logo-swagger.png";
File response = api.imagesNameGet(name).blockingLast();
}
- Run the test case and observe the error message :(
Related issues/PRs
I think this is the first time this issue has been reported.
Suggest a fix/enhancement
A small change in the respective template fixes the bug. I will commit a PR soon.
Description
If we use the Retrofit2 generator with a swagger endpoint that returns a file, the corresponding retrofit method will return a
java.io.filewhich is not supported by Retrofit: It throws acom.google.gson.stream.MalformedJsonException.Swagger-codegen version
I've used the latest master branch, 2.3.0-SNAPSHOT.
Swagger declaration file content or url
Command line used for generation
java -jar swagger-codegen-cli.jar generate -i C:/temp/swagger.yaml -o C:/temp/swagger/ -l java --library retrofit2 --additional-properties useRxJava2=trueSteps to reproduce
C:\temp\swagger.yamland copy the content from above into it.java -jar swagger-codegen-cli.jar generate -i C:/temp/swagger.yaml -o C:/temp/swagger/ -l java --library retrofit2 --additional-properties useRxJava2=trueC:\Temp\swagger\src\test\java\io\swagger\client\api\DefaultApiTest.javaand insert the following test case:Related issues/PRs
I think this is the first time this issue has been reported.
Suggest a fix/enhancement
A small change in the respective template fixes the bug. I will commit a PR soon.