[Go-Server] Support for an endpoint returning a file to the client - #15206#16748
Conversation
|
Hi @icubbon, Similarly from the other PR. As there are currently no cases with file in the generation sample, it is difficult to see how the generated files will look. Would you be able to add a new route that returns file in https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/test/resources/3_0/go-server/petstore.yaml then regenerate the code for go-server. Let us know if you need any help with generation |
Hi @lwj5, thank you for looking at these PRs. I added an example but since the changes were done in the router.mustache file, the generated api-controller file doesn't have any meaningful change as that code should look the same. |
The current Go-Server routers.mustache template does not support an endpoint returning a File to the client.
When the response is about to be sent out to the client, check if the
anybeing sent is of type*os.File. If the item to be sent is a file, read the file into a byte slice and send it out.The headers should still be written as dictated by the
addResponseHeadersmustache variable.This addresses #15206
PR checklist
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*.For Windows users, please run the script in Git BASH.
master(upcoming 7.1.0 minor release - breaking changes with fallbacks),8.0.x(breaking changes without fallbacks)@lwj5 @wing328