Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Message "can't parse JSON. Raw result:" added to response body

I'm trying to define a file download endpoint using the OpenAPI spec (v3). I am facing two problems. 1) the file is not being downloaded 2) within swagger-ui, the response body shows a message that isn't produced by the server (i.e. can't parse JSON. Raw result:"

Anyone have a clue as to what I am doing wrong?

YAML code snapshot: enter image description here

Output result from swagger-ui running on an AWS server. enter image description here

like image 647
Mike Avatar asked Jan 09 '18 01:01

Mike


1 Answers

The cause of the anomalous message, I was told, is because application/json is the content media said to be returned in the server's response header. See the header here: enter image description here

The response is actually a text file -- not JSON. The sending server is incorrectly configured. Swagger-UI runtime response handler determines whether the response is valid. So Swagger-UI outputs the "can't parse JSON..." message.

Because of the error, the output to local storage function on the browser is not performed.

For more details, refer to the Swagger-UI issue #4098.

like image 60
Mike Avatar answered Nov 13 '22 11:11

Mike