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

Could I change the charset in request header? #1298

Closed
bnupaladin opened this issue May 19, 2015 · 6 comments
Closed

Could I change the charset in request header? #1298

bnupaladin opened this issue May 19, 2015 · 6 comments
Milestone

Comments

@bnupaladin
Copy link
Contributor

Hi!
My original Content-Type in request header is "applcation/json". When I try to add to Content-Type a charset other than utf-8, like "applcation/json; charset=gb2312", it always changes to "applcation/json; charset=UTF-8".
Could I change the charset somewhere? Somebody help!

@webron
Copy link
Contributor

webron commented May 20, 2015

Just to be sure, how do you change the charset?

@bnupaladin
Copy link
Contributor Author

In the file index.html, add a line into function addApiKeyAuthorization below:
window.swaggerUi.api.clientAuthorizations.add("Content-Type",new SwaggerClient.ApiKeyAuthorization("Content-Type","application/json; charset=GB2312","header"));

@webron
Copy link
Contributor

webron commented May 21, 2015

That's not the way to set the content type of the request and it would be overridden.
The content type is controlled by the Swagger specification, specifically the consumes property.

@bnupaladin
Copy link
Contributor Author

The consumes property is the Parameter Content Type in test section? I just tried to set the consumes as "application/json; charset=whatever", then the request header's Content-Type changed to "application/json;charset=UTF-8".

@webron
Copy link
Contributor

webron commented May 26, 2015

That may be a different issue, but you cannot specify the content type directly as a header.

@webron webron added this to the v2.1 milestone May 28, 2015
@fehguy
Copy link
Contributor

fehguy commented Jun 6, 2015

There is an option in swagger-js to override the requst headers. You cannot override content-type in the UI like you mentioned. Please provide a sample spec, or more info and we can look at it.

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