Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Static list of consumers / producers? #31

Open
mikkeloscar opened this issue Jan 18, 2017 · 4 comments
Open

Static list of consumers / producers? #31

mikkeloscar opened this issue Jan 18, 2017 · 4 comments

Comments

@mikkeloscar
Copy link

mikkeloscar commented Jan 18, 2017

Hello,

Trying to understand why my client (generated by go-swagger) would not accept the application/problem+json media type I stumbled upon these hard coded values: https://github.com/go-openapi/runtime/blob/master/client/runtime.go#L137-L147

What are the reason for these?
They are used in Submit() but shouldn't the values from the passed runtime.ClientOperation struct be used instead e.i. runtime.ClientOperation.ProducesMediaTypes and runtime.ClientOperation.ConsumesMediaTypes?

@GlenDC GlenDC added the bug label Jan 18, 2017
@GlenDC
Copy link
Member

GlenDC commented Jan 18, 2017

There is a clear TODO in the runtime code, right above the location you linked (https://github.com/go-openapi/runtime/blob/master/client/runtime.go#L136), so I suppose that gives the answer you are seeking for.

Another possible TODO will need or should to be solved is https://github.com/go-openapi/runtime/blob/master/client/runtime.go#L231 (this TODO/bug is about making the consumer selection smarter than simply selecting the first one available in the array)

Solving those TODOs in a reasonable way will resolve your issue. Setting those runtime consumers producers for generated clients by go-swagger is already possible, by creating the runtime yourself (possibly using the generated client defaults), setting a consumer/producer for your custom MIME Type and pass that newly created runtime to the constructor of your generated API client.

@GlenDC
Copy link
Member

GlenDC commented Jan 18, 2017

In fact you might already make your code work by simply adding your custom consumer/producer as follows:

rt := runtime.New(myHost, myBasePath, mySchemes)
rt.Consumers["application/problem+json"] = runtime.JSONConsumer()
rt.Producers["application/problem+json"] = runtime.JSONProducer()

// do something with the newly created runtime
// ..

@GlenDC
Copy link
Member

GlenDC commented Jan 18, 2017

Relevant issues: #32 #33

@RubenGarcia
Copy link
Contributor

It seems the cited code has been modified and the list of mimetimes is no longer there. Can you check if this is still an issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants