Generated client does not accept content types specified in schema
Author: sidhCreated Nov 3, 2017Updated Jun 28, 2026
Labelsquestiondocgenerate clientmedia types
Problem statement
If some content type like "image/png" or "/" is specified in "produces" part schema, generated client does not accept those content types and errors out with 'no consumer: "image/png"'.
Specifically, we use a schema like the one below and respond to user requests with binary data and set content-type header manually based on mime-type of the data. It works fine if you access it from curl or web browser but errors in go-swagger generated client.
Swagger specification
swagger: "2.0"
info:
title: Test
version: 0.0.1
schemes:
- "http"
paths:
/test:
get:
produces:
- "application/octet-stream"
- "*/*"
responses:
200:
description: 200 response
headers:
Content-Type:
type: string
schema:
type: string
format: byteSource: go-swagger/go-swagger