を応答し、取得 {"$ref":"#/definitions/DeferredResult«ResponseEntity«SummCollection»»"
奇妙な文字が闊歩2.0検証出力に埋め込まれたこれらの厄介な文字を検証テストを実行する
コントローラのメソッドが返す:私が書いているようDeferredResult<ResponseEntity<SummCollection>>
私は気づきました質問:実際: "<" クレイジー:「«」MockHttpServletRequest Swagger2 DeferredResultÂ応答
で奇妙な文字
これは "iso-8859-1"と "utf-8"の間の問題のようです。 IDK。
質問SwaggerTest validateImplementationAgainstDesignSpecがファイル.yaml jsonを読み込む原因は何ですか.MockMvcはGETを実行します。応答にはクラス名と区切り文字の間に "Â"という文字が含まれています。
CODEのCALL:
MvcResult mvcResult = this.mockMvc.perform(get("/v2/api-docs?group=full-api") // 2 .accept(MediaType.APPLICATION_JSON) .characterEncoding("application/json;charset=ISO-8859-1")) .andDo(MockMvcResultHandlers.print()) .andExpect(status().isOk()) .andReturn();
私はライン.characterEncoding("application/json;charset=ISO-8859-1"))
"UTF-8" に設定され、極端に他のすべて( "窓-1252" を含む)とのコードをデバッグしてきました。これはLinux CIサーバー上で発生するため、ワインダーではありません。
私はそれがStringHttpMessageConverter
の問題/症状であることを読んだが、MockMVCを使用してSwagger2を呼び出す方法を修正する方法としては役に立たない。
OUTPUT:
MockHttpServletResponse: Status = 200 Error message = null Headers = {Content-Type=[application/json]} Content type = application/json Body = {"swagger":"2.0","info":{"description":"Some Description ","version":"1.0","title":"Sum-Server","license":{}},"host":"localhost","basePath":"/","tags":[{"name":"summ-service","description":"Summary Service"}],"paths":{"/api/v1/summ/{id}":{"get":{"tags":["device-summary-service"],"summary":"getDeviceSummaries","operationId":"getDeviceSummariesUsingGET","consumes":["application/json"],"produces":["application/json"],"parameters":[{"name":"id","in":"path","description":"id","required":true,"type":"string"},{"name":"days","in":"query","description":"days","required":false,"type":"string"},{"name":"start","in":"query","description":"start","required":false,"type":"string"},{"name":"end","in":"query","description":"end","required":false,"type":"string"}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/DeferredResult«ResponseEntity«SummCollection»»"}}}}}},"definitions":{"SummCollection":{"type":"object","properties":{"SummList":{"type":"array","items":{"$ref":"#/definitions/SummDateRange"}},"endDate":{"type":"string"},"prioritizedReportFamily":{"type":"integer","format":"int32"},"startDate":{"type":"string"}}},"DeferredResult«ResponseEntity«SummCollection»»":{"type":"object","properties":{"result":{"type":"object"},"setOrExpired":{"type":"boolean"}}}}}