Skip to content

Fix the MappingProxyType error when converting schema to JSON #930

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
9 changes: 4 additions & 5 deletions src/confluent_kafka/avro/cached_schema_registry_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#
# derived from https://github.com/verisign/python-confluent-schemaregistry.git
#
import json
import logging
import warnings
from collections import defaultdict
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions tests/avro/mock_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy