(schema: JSONSchema7, ctx: GoCodegenCtx)
| 2140 | } |
| 2141 | |
| 2142 | function goDefinitionRefForEquivalentSchema(schema: JSONSchema7, ctx: GoCodegenCtx): string | undefined { |
| 2143 | const schemaKey = stableStringify(normalizeSchemaForMatch(schema, ctx)); |
| 2144 | const definitions = { |
| 2145 | ...(ctx.definitions?.definitions ?? {}), |
| 2146 | ...(ctx.definitions?.$defs ?? {}), |
| 2147 | }; |
| 2148 | for (const [definitionName, definition] of Object.entries(definitions)) { |
| 2149 | if (!definition || typeof definition !== "object") continue; |
| 2150 | const definitionKey = stableStringify(normalizeSchemaForMatch(definition as JSONSchema7, ctx)); |
| 2151 | if (definitionKey === schemaKey) { |
| 2152 | return `#/definitions/${definitionName}`; |
| 2153 | } |
| 2154 | } |
| 2155 | return undefined; |
| 2156 | } |
| 2157 | |
| 2158 | function goDefinitionName(definitionName: string): string { |
| 2159 | return toGoSchemaTypeName(definitionName); |
no test coverage detected
searching dependent graphs…