Использование Swagger при возврате JsonNode - PullRequest
0 голосов
/ 12 октября 2018

В настоящее время я написал приложение Spring Boot, которое возвращает объект Response (класс, который я создал) на один из его вызовов REST.Он работал нормально, пока я не включил 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;
    }
}

ItМне кажется, что Swagger не особенно нравится использование JsonNodes.Он показывает строки timetook и hitCount.Кто-нибудь знает, как обойти это?Спасибо.

...