Class: SchemaRegistry::Schema::ProtoJsonSchema
- Defined in:
- lib/schema_registry_client/schema/proto_json_schema.rb
Class Method Summary collapse
Instance Method Summary collapse
- #decode(stream, _schema_text) ⇒ Object
- #encode(message, stream, schema_name: nil) ⇒ Object
- #schema_text(message, schema_name: nil) ⇒ Object
Methods inherited from Base
Class Method Details
.schema_type ⇒ Object
9 10 11 |
# File 'lib/schema_registry_client/schema/proto_json_schema.rb', line 9 def self.schema_type "JSON" end |
Instance Method Details
#decode(stream, _schema_text) ⇒ Object
22 23 24 25 |
# File 'lib/schema_registry_client/schema/proto_json_schema.rb', line 22 def decode(stream, _schema_text) json = stream.read JSON.parse(json) end |
#encode(message, stream, schema_name: nil) ⇒ Object
17 18 19 20 |
# File 'lib/schema_registry_client/schema/proto_json_schema.rb', line 17 def encode(, stream, schema_name: nil) json = .to_h.sort.to_h.to_json stream.write(json) end |
#schema_text(message, schema_name: nil) ⇒ Object
13 14 15 |
# File 'lib/schema_registry_client/schema/proto_json_schema.rb', line 13 def schema_text(, schema_name: nil) SchemaRegistry::Output::JsonSchema.output(.class.descriptor.to_proto) end |