Currently, I have my Swagger YAML set up to accept application/json
by default for each route with the following on the top-level Swagger definition:
swagger: "2.0"
info:
version: "0.0.1"
title: my App
# during dev, should point to your local machine
host: localhost:5054
# basePath prefixes all resource paths
basePath: /
schemes:
# tip: remove http to make production-grade
- http
- https
# format of bodies a client can send (Content-Type)
consumes:
- application/json
produces:
- application/json
I now have a route that can return files, and I don't want to have to specify all the potential files that may be returned. I have seen on the Swagger GitHub page that there may be some sort of wildcard that allows any content type to be returned. I have tried the following in my route:
get:
description: Download a single document
operationId: getDocument
produces: []
but Swagger UI will not allow me to send the request in the UI, as it sees this as having no Accept
field populated.
Then:
get:
description: Download a single document
operationId: getDocument
produces: */*
But Swagger UI throws an error stating unidentified alias "/*"
. I also tried \*/*
just in case it was something to do with needing to be escaped but that didn't work.
Finally:
get:
description: Download a single document
operationId: getDocument
produces: "*/*"
This one allowed me to test the route in Swagger UI but the response still failed validation and claimed the expected content type was still to be application/json
.
Is there a wildcard that works or am I trying to do something Swagger isn't set up for?