Skip to content

Commit

Permalink
Solve the integration swagger into the gin framework, access the Chin…
Browse files Browse the repository at this point in the history
…ese garbled problem in the json returned by swagger/doc.json. (#78)

enable UTF8 for swagger json documentation
  • Loading branch information
singhwang authored Aug 11, 2021
1 parent 8c37e9f commit 6322a8f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion swagger.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func CustomWrapHandler(config *Config, h *webdav.Handler) gin.HandlerFunc {
} else if strings.HasSuffix(path, ".js") {
c.Header("Content-Type", "application/javascript")
} else if strings.HasSuffix(path, ".json") {
c.Header("Content-Type", "application/json")
c.Header("Content-Type", "application/json; charset=utf-8")
}

switch path {
Expand Down
2 changes: 1 addition & 1 deletion swagger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func TestWithGzipMiddleware(t *testing.T) {

w4 := performRequest("GET", "/doc.json", router)
assert.Equal(t, 200, w4.Code)
assert.Equal(t, w4.Header()["Content-Type"][0], "application/json")
assert.Equal(t, w4.Header()["Content-Type"][0], "application/json; charset=utf-8")
}

func performRequest(method, target string, router *gin.Engine) *httptest.ResponseRecorder {
Expand Down

0 comments on commit 6322a8f

Please sign in to comment.