8000 Produces application/pdf ignored · Issue #1284 · go-swagger/go-swagger · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Produces application/pdf ignored #1284
Closed
@Xzya

Description

@Xzya

Problem statement

The below swagger definition will generate the ProducersFor:

func (o *SomeAPI) ProducersFor(mediaTypes []string) map[string]runtime.Producer {

	result := make(map[string]runtime.Producer)
	for _, mt := range mediaTypes {
		switch mt {

		case "text/html":
			result["text/html"] = o.HTMLProducer

		}
	}
	return result

}

So the application/pdf is ignored.
Also there is no producer property:

type SomeAPI struct {
...
	// JSONConsumer registers a consumer for a "application/json" mime type
	JSONConsumer runtime.Consumer

	// HTMLProducer registers a producer for a "text/html" mime type
	HTMLProducer runtime.Producer
...
}

Reading the source code, this seems intended. Is there any way to add a custom producer? I want the application/pdf producer to do the same as runtime.ByteStreamProducer(), but I cannot find any way to set it as there is no ApplicationPDFProducer property generated.
I expected this to work the same way as security schemes, where you get a handler which you can override for each scheme.

Swagger specification

paths:
  /some/path:
    get:
      operationId: "getPDF"
      produces:
      - "application/pdf"
      - "text/html"
      responses:
        200:
          description: "ok"
          schema:
            type: "string"
            format: "binary"
        default:
          description: "Unexpected error"
          schema:
            type: "object"

Environment

swagger version: 0.13.0
go version: 1.9
OS: OSX El Capitan

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0