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

"application/json; charset=utf-8" consumer issue #1

Open
simenandre opened this issue Jun 22, 2020 · 1 comment
Open

"application/json; charset=utf-8" consumer issue #1

simenandre opened this issue Jun 22, 2020 · 1 comment

Comments

@simenandre
Copy link
Member

Parts of the Tripletex Swagger file utilizes a consumer named application/json; charset=utf-8.

In order to use this library, you'll have to add a new producer:

r.Producers["application/json; charset=utf-8"] = runtime.JSONProducer()

Read go-swagger/go-swagger#1899 for more information.

You could create a separate client.go file with the following content to fix this.

package tripletex

import (
	apiclient "github.com/bjerkio/tripletex-go/client"
	"github.com/go-openapi/runtime"
	httptransport "github.com/go-openapi/runtime/client"
	"github.com/go-openapi/strfmt"
)

// Client returns a authenticated Tripletex client
func Client(token string) (*apiclient.Tripletex, runtime.ClientAuthInfoWriter) {
	r := httptransport.New(apiclient.DefaultHost, apiclient.DefaultBasePath, apiclient.DefaultSchemes)
	r.DefaultAuthentication = httptransport.BasicAuth("0", token)

	// Fix "application/json; charset=utf-8" issue
	r.Producers["application/json; charset=utf-8"] = runtime.JSONProducer()

	return apiclient.New(r, strfmt.Default), r.DefaultAuthentication
}
@casualjim
Copy link

You don't need the charset bit. it will be respected like that

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

No branches or pull requests

2 participants