File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed
main/java/io/modelcontextprotocol/spec
test/java/io/modelcontextprotocol/spec Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -2501,6 +2501,7 @@ public CompleteResult(CompleteCompletion completion) {
25012501 * @param hasMore Indicates whether there are additional completion options beyond
25022502 * those provided in the current response, even if the exact total is unknown
25032503 */
2504+ @JsonInclude(JsonInclude.Include.ALWAYS)
25042505 public record CompleteCompletion( // @formatter:off
25052506 @JsonProperty("values") List<String> values,
25062507 @JsonProperty("total") Integer total,
Original file line number Diff line number Diff line change 1+ package io.modelcontextprotocol.spec;
2+
3+ import io.modelcontextprotocol.json.McpJsonMapper;
4+ import org.junit.jupiter.api.Test;
5+ import java.io.IOException;
6+ import java.util.Collections;
7+ import static org.junit.jupiter.api.Assertions.assertEquals;
8+
9+ class CompleteCompletionSerializationTest {
10+
11+ @Test
12+ void codeCompletionSerialization() throws IOException {
13+ McpJsonMapper jsonMapper = McpJsonMapper.getDefault();
14+ McpSchema.CompleteResult.CompleteCompletion codeComplete = new McpSchema.CompleteResult.CompleteCompletion(
15+ Collections.emptyList(), 0, false);
16+ String json = jsonMapper.writeValueAsString(codeComplete);
17+ String expected = """
18+ {"values":[],"total":0,"hasMore":false}""";
19+ assertEquals(expected, json, json);
20+
21+ McpSchema.CompleteResult completeResult = new McpSchema.CompleteResult(codeComplete);
22+ json = jsonMapper.writeValueAsString(completeResult);
23+ expected = """
24+ {"completion":{"values":[],"total":0,"hasMore":false}}""";
25+ assertEquals(expected, json, json);
26+ }
27+
28+ }
You can’t perform that action at this time.
0 commit comments