diff --git a/src/SchemaRegistry.ts b/src/SchemaRegistry.ts index cb8ce32..0bafc03 100644 --- a/src/SchemaRegistry.ts +++ b/src/SchemaRegistry.ts @@ -213,7 +213,13 @@ export default class SchemaRegistry { helper: SchemaHelper, referencesSet: Set, ): Promise { - const { name, subject, version } = reference + const { name, subject } = reference + + const versionResponse = await this.api.Subject.version(reference) + const foundSchema = versionResponse.data() as SchemaResponse + + // rely on version retrieved from the registry, because references may use -1 as version + const { version } = foundSchema const key = `${name}-${subject}-${version}` // avoid duplicates @@ -222,9 +228,6 @@ export default class SchemaRegistry { } referencesSet.add(key) - const versionResponse = await this.api.Subject.version(reference) - const foundSchema = versionResponse.data() as SchemaResponse - const schema = helper.toConfluentSchema(foundSchema) const referencedSchemas = await this.getreferencedSchemasRecursive( schema,