[英]Using Swagger when returning JsonNode
我目前已經編寫了一個Spring Boot應用程序,該應用程序在其中一個REST調用中返回一個Response Object(我創建的類)。 一切正常,直到我合並了Swagger,現在出現以下錯誤:
<Response>
<timeTook>69</timeTook>
<hitsCount>138</hitsCount>
<hits>
<hits>
<msg>
<Map>
<timestamp>1539357450970</timestamp>
<status>200</status>
<error>OK</error>
<message>Could not write JSON: Invalid white space character (0x1) in text to output (in xml 1.1, could output as a character entity); nested exception is com.fasterxml.jackson.core.JsonGenerationException: Invalid white space character (0x1) in text to output (in xml 1.1, could output as a character entity)</message>
<path>/api/messagesearch/1.0/search</path>
</Map>
這是我用來創建Response對象的Response類。
public class Response {
private String timeTook;
private String hitsCount;
private List<JsonNode> hits;
public Response(String took, String hitsCount, List<JsonNode> hits){
this.timeTook = took;
this.hitsCount = hitsCount;
this.hits = hits;
}
public String getTimeTook() {
return timeTook;
}
public String getHitsCount() {
return hitsCount;
}
public void setHitsCount(String hitCount) {
this.hitsCount = hitCount;
}
public void setTimeTook(String timeTook) {
this.timeTook = timeTook;
}
public List<JsonNode> getHits() {
return hits;
}
public void setHits(List<JsonNode> hits) {
this.hits = hits;
}
}
在我看來,Swagger並不特別喜歡使用JsonNodes。 它顯示了timetook和hitCount字符串。 有人知道如何解決此問題嗎? 謝謝。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.