swagger-api / swagger-ui

Swagger UI is a collection of HTML, JavaScript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API.
https://swagger.io
Apache License 2.0
26.01k stars 8.86k forks source link

utf-8 encoding issue when using multipart form post #277

Closed aquayee closed 9 years ago

aquayee commented 10 years ago

I'm using grape, grape-swagger and swagger-ui, everything works perfect.

Except when I try to post some data to the api. The body field contains some Chinese wording. When I debug in backend(Rails+Grape), the content of body is non utf-8 characters. The rails config and browsers view setting are both utf-8.

I try to use curl to test the API directly, it would not have problem.

curl -d "team_id=22&user_id=44&user_avatar=https://towerfiles.oss.aliyuncs.com/avatar/4e1e13c4157944358b513f6d10a571bf&body=你好&user_name=mafai" http://localhost:3000/api/v1/posts.json

Here's the log capture by firebug when using swagger-ui.

Accept application/json, text/javascript, /; q=0.01 Accept-Encoding gzip, deflate Accept-Language en-US,en;q=0.5 Cache-Control no-cache Connection keep-alive Content-Length 715 Content-Type multipart/form-data; boundary=---------------------------96109097118314405101137539119 Cookie email=xxx%40gmail.com; remember_user_token=BAhbB1sGaQhJIiIkMmEkMTAkLnY1WUI1MzN5SEFpQTJoQXVRNGMxZQY6BkVU--2ee40ebda7767c8a8e723ccd83a5554a7a98cda6; _aquayee_session=BAh7B0kiD3Nlc3Npb25faWQGOgZFVEkiJTI0ZmJjM2FmY2VlMmM3NTU1ODJkOWEyNzZlZjhlZWRmBjsAVEkiGXdhcmRlbi51c2VyLnVzZXIua2V5BjsAVFsISSIJVXNlcgY7AEZbBmkISSIiJDJhJDEwJC52NVlCNTMzeUhBaUEyaEF1UTRjMWUGOwBU--965bcc64b3ca53f86f053ab53f7365d2fe21e1af Host localhost:3000 Pragma no-cache Referer http://localhost:3000/swagger/index.html User-Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:22.0) Gecko/20100101 Firefox/22.0 X-Requested-With XMLHttpRequest

fehguy commented 10 years ago

Could you try with the develop-2.0 branch of swagger UI?

fehguy commented 9 years ago

please reopen if still an issue