Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions schemaregistry/mock-schemaregistry-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ class MockClient implements Client {
throw new RestError("Schema not found", 404, 40400);
}


return {
id,
version,
Expand All @@ -202,7 +201,6 @@ class MockClient implements Client {
if (parsedKey.subject === subject && (!value.softDeleted || deleted)) {
if (parsedKey.schema.metadata && this.isSubset(metadata, parsedKey.schema.metadata.properties)) {
results.push({
id: parsedKey.schema.id,
version: value.version,
subject,
...parsedKey.schema
Expand All @@ -223,6 +221,18 @@ class MockClient implements Client {
}
});

let id: number = -1;
for (const [key, value] of this.idToSchemaCache.entries()) {
const parsedKey = JSON.parse(key);
if (parsedKey.subject === subject && value.info.schema === latest.schema) {
id = parsedKey.id;
}
}
if (id === -1) {
throw new RestError("Schema not found", 404, 40400);
}

latest.id = id;
return latest;
}

Expand Down
15 changes: 7 additions & 8 deletions schemaregistry/serde/serde.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,16 +257,15 @@ export abstract class Serializer extends Serde {
id = await this.client.register(subject, info, Boolean(normalizeSchema))
} else if (useSchemaId != null && useSchemaId >= 0) {
info = await this.client.getBySubjectAndId(subject, useSchemaId, format)
id = await this.client.getId(subject, info, false)
if (id !== useSchemaId) {
throw new SerializationError(`failed to match schema ID (${id} != ${useSchemaId})`)
}
id = useSchemaId
} else if (useLatestWithMetadata != null && Object.keys(useLatestWithMetadata).length !== 0) {
info = await this.client.getLatestWithMetadata(subject, useLatestWithMetadata, true, format)
id = await this.client.getId(subject, info, false)
let metadata = await this.client.getLatestWithMetadata(subject, useLatestWithMetadata, true, format)
info = metadata
id = metadata.id
} else if (useLatest) {
info = await this.client.getLatestSchemaMetadata(subject, format)
id = await this.client.getId(subject, info, false)
let metadata = await this.client.getLatestSchemaMetadata(subject, format)
info = metadata
id = metadata.id
} else {
id = await this.client.getId(subject, info, Boolean(normalizeSchema))
}
Expand Down