diff --git a/src/confluent_kafka/avro/cached_schema_registry_client.py b/src/confluent_kafka/avro/cached_schema_registry_client.py index 6fee6151d..bdbe380e2 100644 --- a/src/confluent_kafka/avro/cached_schema_registry_client.py +++ b/src/confluent_kafka/avro/cached_schema_registry_client.py @@ -19,7 +19,6 @@ # # derived from https://github.com/verisign/python-confluent-schemaregistry.git # -import json import logging import warnings from collections import defaultdict @@ -213,7 +212,7 @@ def register(self, subject, avro_schema): url = '/'.join([self.url, 'subjects', subject, 'versions']) # body is { schema : json_string } - body = {'schema': json.dumps(avro_schema.to_json())} + body = {'schema': str(avro_schema)} result, code = self._send_request(url, method='POST', body=body) if (code == 401 or code == 403): raise ClientError("Unauthorized access. Error code:" + str(code)) @@ -253,7 +252,7 @@ def check_registration(self, subject, avro_schema): url = '/'.join([self.url, 'subjects', subject]) # body is { schema : json_string } - body = {'schema': json.dumps(avro_schema.to_json())} + body = {'schema': str(avro_schema)} result, code = self._send_request(url, method='POST', body=body) if code == 401 or code == 403: raise ClientError("Unauthorized access. Error code:" + str(code)) @@ -374,7 +373,7 @@ def get_version(self, subject, avro_schema): return version url = '/'.join([self.url, 'subjects', subject]) - body = {'schema': json.dumps(avro_schema.to_json())} + body = {'schema': str(avro_schema)} result, code = self._send_request(url, method='POST', body=body) if code == 404: @@ -402,7 +401,7 @@ def test_compatibility(self, subject, avro_schema, version='latest'): """ url = '/'.join([self.url, 'compatibility', 'subjects', subject, 'versions', str(version)]) - body = {'schema': json.dumps(avro_schema.to_json())} + body = {'schema': str(avro_schema)} try: result, code = self._send_request(url, method='POST', body=body) if code == 404: diff --git a/tests/avro/mock_registry.py b/tests/avro/mock_registry.py index f40e82f25..95c74f9c7 100644 --- a/tests/avro/mock_registry.py +++ b/tests/avro/mock_registry.py @@ -100,13 +100,13 @@ def get_schema_by_id(self, req, groups): if not schema: return self._create_error("schema not found", 404) result = { - "schema": json.dumps(schema.to_json()) + "schema": str(schema) } return (200, result) def _get_identity_schema(self, avro_schema): # normalized - schema_str = json.dumps(avro_schema.to_json()) + schema_str = str(avro_schema) if schema_str in self.schema_cache: return self.schema_cache[schema_str] self.schema_cache[schema_str] = avro_schema @@ -150,7 +150,7 @@ def get_version(self, req, groups): schema_id = self.registry.get_id_for_schema(subject, avro_schema) result = { - "schema": json.dumps(avro_schema.to_json()), + "schema": str(avro_schema), "subject": subject, "id": schema_id, "version": version @@ -163,7 +163,7 @@ def get_latest(self, req, groups): if schema_id is None: return self._create_error("Not found", 404) result = { - "schema": json.dumps(avro_schema.to_json()), + "schema": str(avro_schema), "subject": subject, "id": schema_id, "version": version