define explicitely that values should always be included in code completions (#601)
* define explicitely that values should always be included * spring apply
This commit is contained in:
parent
531c5b8015
commit
475456537f
2 changed files with 29 additions and 0 deletions
|
|
@ -2501,6 +2501,7 @@ public final class McpSchema {
|
|||
* @param hasMore Indicates whether there are additional completion options beyond
|
||||
* those provided in the current response, even if the exact total is unknown
|
||||
*/
|
||||
@JsonInclude(JsonInclude.Include.ALWAYS)
|
||||
public record CompleteCompletion( // @formatter:off
|
||||
@JsonProperty("values") List<String> values,
|
||||
@JsonProperty("total") Integer total,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,28 @@
|
|||
package io.modelcontextprotocol.spec;
|
||||
|
||||
import io.modelcontextprotocol.json.McpJsonMapper;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
class CompleteCompletionSerializationTest {
|
||||
|
||||
@Test
|
||||
void codeCompletionSerialization() throws IOException {
|
||||
McpJsonMapper jsonMapper = McpJsonMapper.getDefault();
|
||||
McpSchema.CompleteResult.CompleteCompletion codeComplete = new McpSchema.CompleteResult.CompleteCompletion(
|
||||
Collections.emptyList(), 0, false);
|
||||
String json = jsonMapper.writeValueAsString(codeComplete);
|
||||
String expected = """
|
||||
{"values":[],"total":0,"hasMore":false}""";
|
||||
assertEquals(expected, json, json);
|
||||
|
||||
McpSchema.CompleteResult completeResult = new McpSchema.CompleteResult(codeComplete);
|
||||
json = jsonMapper.writeValueAsString(completeResult);
|
||||
expected = """
|
||||
{"completion":{"values":[],"total":0,"hasMore":false}}""";
|
||||
assertEquals(expected, json, json);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in a new issue