MCPcopy Index your code
hub / github.com/github/copilot-sdk / generateRpcMapperClass

Function generateRpcMapperClass

java/scripts/codegen/java.ts:2082–2123  ·  view source on GitHub ↗

* Generate RpcMapper.java — a package-private holder for the shared ObjectMapper used * when merging sessionId into session API call params. All session API classes that * need an ObjectMapper reference this single instance instead of instantiating their own.

(packageName: string, packageDir: string)

Source from the content-addressed store, hash-verified

2080 * need an ObjectMapper reference this single instance instead of instantiating their own.
2081 */
2082async function generateRpcMapperClass(packageName: string, packageDir: string): Promise<void> {
2083 const lines: string[] = [];
2084 lines.push(COPYRIGHT);
2085 lines.push(``);
2086 lines.push(AUTO_GENERATED_HEADER);
2087 lines.push(GENERATED_FROM_API);
2088 lines.push(``);
2089 lines.push(`package ${packageName};`);
2090 lines.push(``);
2091 lines.push(`import javax.annotation.processing.Generated;`);
2092 lines.push(``);
2093 lines.push(`/**`);
2094 lines.push(` * Package-private holder for the shared {@link com.fasterxml.jackson.databind.ObjectMapper}`);
2095 lines.push(` * used by session API classes when merging {@code sessionId} into call parameters.`);
2096 lines.push(` * <p>`);
2097 lines.push(` * {@link com.fasterxml.jackson.databind.ObjectMapper} is thread-safe and expensive to`);
2098 lines.push(` * instantiate, so a single shared instance is used across all generated API classes.`);
2099 lines.push(` * The configuration mirrors {@code JsonRpcClient}'s mapper (JavaTimeModule, lenient`);
2100 lines.push(` * unknown-property handling, ISO date format, NON_NULL inclusion).`);
2101 lines.push(` *`);
2102 lines.push(` * @since 1.0.0`);
2103 lines.push(` */`);
2104 lines.push(GENERATED_ANNOTATION);
2105 lines.push(`final class RpcMapper {`);
2106 lines.push(``);
2107 lines.push(` static final com.fasterxml.jackson.databind.ObjectMapper INSTANCE = createMapper();`);
2108 lines.push(``);
2109 lines.push(` private static com.fasterxml.jackson.databind.ObjectMapper createMapper() {`);
2110 lines.push(` com.fasterxml.jackson.databind.ObjectMapper mapper = new com.fasterxml.jackson.databind.ObjectMapper();`);
2111 lines.push(` mapper.registerModule(new com.fasterxml.jackson.datatype.jsr310.JavaTimeModule());`);
2112 lines.push(` mapper.configure(com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);`);
2113 lines.push(` mapper.configure(com.fasterxml.jackson.databind.SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);`);
2114 lines.push(` mapper.setDefaultPropertyInclusion(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL);`);
2115 lines.push(` return mapper;`);
2116 lines.push(` }`);
2117 lines.push(``);
2118 lines.push(` private RpcMapper() {}`);
2119 lines.push(`}`);
2120 lines.push(``);
2121
2122 await writeGeneratedFile(`${packageDir}/RpcMapper.java`, lines.join("\n"));
2123}
2124
2125/** Main entry point for RPC wrapper generation */
2126async function generateRpcWrappers(schemaPath: string): Promise<void> {

Callers 1

generateRpcWrappersFunction · 0.85

Calls 3

joinMethod · 0.80
writeGeneratedFileFunction · 0.70
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…