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

Function refTypeName

scripts/codegen/utils.ts:973–990  ·  view source on GitHub ↗
(ref: string, definitions?: DefinitionCollections)

Source from the content-addressed store, hash-verified

971
972/** Extract the generated type name from a `$ref` path (e.g. "#/definitions/Model""Model"). */
973export function refTypeName(ref: string, definitions?: DefinitionCollections): string {
974 const baseName = ref.split("/").pop()!;
975 const match = ref.match(/^#\/(definitions|\$defs)\/(.+)$/);
976 if (!match || match[1] !== "$defs" || !definitions) return baseName;
977
978 const key = match[2];
979 const legacyDefinition = definitions.definitions?.[key];
980 const draftDefinition = definitions.$defs?.[key];
981 if (
982 legacyDefinition !== undefined &&
983 draftDefinition !== undefined &&
984 stableStringify(legacyDefinition) !== stableStringify(draftDefinition)
985 ) {
986 return `Draft${baseName}`;
987 }
988
989 return baseName;
990}
991
992export function parseExternalSchemaRef(ref: string): { schemaFile: string; definitionName: string } | undefined {
993 const match = ref.match(/^([^#]+)#\/(?:definitions|\$defs)\/(.+)$/);

Callers 15

rustRefTypeNameFunction · 0.85
getResultTypeNameFunction · 0.85
getCSharpSchemaTypeNameFunction · 0.85
resolvedResultTypeNameFunction · 0.85
resolveRpcTypeFunction · 0.85
goRefTypeNameFunction · 0.85
resolveGoPropertyTypeFunction · 0.85
goUnionFieldNameFunction · 0.85
goUntaggedUnionVariantFunction · 0.85

Calls 2

popMethod · 0.80
stableStringifyFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…