schema_registry_client 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/lint.yml +18 -0
  3. data/.github/workflows/release.yml +31 -0
  4. data/.github/workflows/test.yml +22 -0
  5. data/.gitignore +1 -0
  6. data/.rspec +2 -0
  7. data/.rubocop.yml +39 -0
  8. data/CHANGELOG.md +12 -0
  9. data/Gemfile +5 -0
  10. data/Gemfile.lock +150 -0
  11. data/LICENSE +20 -0
  12. data/README.md +48 -0
  13. data/Rakefile +3 -0
  14. data/lib/schema_registry_client/avro_schema_store.rb +127 -0
  15. data/lib/schema_registry_client/cached_confluent_schema_registry.rb +57 -0
  16. data/lib/schema_registry_client/confluent_schema_registry.rb +118 -0
  17. data/lib/schema_registry_client/output/json_schema.rb +78 -0
  18. data/lib/schema_registry_client/output/proto_text.rb +320 -0
  19. data/lib/schema_registry_client/schema/avro.rb +61 -0
  20. data/lib/schema_registry_client/schema/base.rb +44 -0
  21. data/lib/schema_registry_client/schema/proto_json_schema.rb +30 -0
  22. data/lib/schema_registry_client/schema/protobuf.rb +131 -0
  23. data/lib/schema_registry_client/version.rb +5 -0
  24. data/lib/schema_registry_client/wire.rb +30 -0
  25. data/lib/schema_registry_client.rb +156 -0
  26. data/schema_registry_client.gemspec +33 -0
  27. data/spec/decoding_spec.rb +183 -0
  28. data/spec/encoding_spec.rb +207 -0
  29. data/spec/gen/everything/everything_pb.rb +26 -0
  30. data/spec/gen/referenced/referer_pb.rb +24 -0
  31. data/spec/gen/simple/simple_pb.rb +18 -0
  32. data/spec/json_schema_spec.rb +12 -0
  33. data/spec/proto_text_spec.rb +10 -0
  34. data/spec/schemas/everything/everything.json +328 -0
  35. data/spec/schemas/everything/everything.proto +105 -0
  36. data/spec/schemas/referenced/referenced.json +16 -0
  37. data/spec/schemas/referenced/referer.proto +28 -0
  38. data/spec/schemas/referenced/v1/MessageBA.avsc +21 -0
  39. data/spec/schemas/simple/simple.json +12 -0
  40. data/spec/schemas/simple/simple.proto +12 -0
  41. data/spec/schemas/simple/v1/SimpleMessage.avsc +11 -0
  42. data/spec/spec_helper.rb +16 -0
  43. metadata +46 -9
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.describe SchemaRegistry::Output::ProtoText do
4
+ it 'should output as expected' do
5
+ output = described_class.output(Everything::V1::TestAllTypes.descriptor.file_descriptor.to_proto)
6
+
7
+ expected = File.read("#{__dir__}/schemas/everything/everything.proto")
8
+ expect(output).to eq(expected)
9
+ end
10
+ end
@@ -0,0 +1,328 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "type": "object",
4
+ "properties": {
5
+ "optional_int32": {
6
+ "type": "integer"
7
+ },
8
+ "optional_int64": {
9
+ "type": "string"
10
+ },
11
+ "optional_uint32": {
12
+ "type": "integer"
13
+ },
14
+ "optional_uint64": {
15
+ "type": "string"
16
+ },
17
+ "optional_sint32": {
18
+ "type": "integer"
19
+ },
20
+ "optional_sint64": {
21
+ "type": "string"
22
+ },
23
+ "optional_fixed32": {
24
+ "type": "integer"
25
+ },
26
+ "optional_fixed64": {
27
+ "type": "string"
28
+ },
29
+ "optional_sfixed32": {
30
+ "type": "integer"
31
+ },
32
+ "optional_sfixed64": {
33
+ "type": "string"
34
+ },
35
+ "optional_float": {
36
+ "type": "number"
37
+ },
38
+ "optional_double": {
39
+ "type": "number"
40
+ },
41
+ "optional_bool": {
42
+ "type": "boolean"
43
+ },
44
+ "optional_string": {
45
+ "type": "string"
46
+ },
47
+ "optional_bytes": {
48
+ "type": "string"
49
+ },
50
+ "optional_nested_message": {
51
+ "type": "object"
52
+ },
53
+ "optional_foreign_message": {
54
+ "type": "object"
55
+ },
56
+ "optional_import_message": {
57
+ "type": "object"
58
+ },
59
+ "optional_nested_enum": {
60
+ "enum": [
61
+ "FOO",
62
+ "BAR",
63
+ "BAZ"
64
+ ]
65
+ },
66
+ "optional_foreign_enum": {
67
+ "enum": [
68
+ "FOREIGN_FOO",
69
+ "FOREIGN_BAR"
70
+ ]
71
+ },
72
+ "optional_import_enum": {
73
+ "enum": [
74
+ "SIMPLE_FOO",
75
+ "SIMPLE_BAR"
76
+ ]
77
+ },
78
+ "optional_string_piece": {
79
+ "type": "string"
80
+ },
81
+ "optional_cord": {
82
+ "type": "string"
83
+ },
84
+ "optional_bytes_cord": {
85
+ "type": "string"
86
+ },
87
+ "optional_lazy_message": {
88
+ "type": "object"
89
+ },
90
+ "optional_unverified_lazy_message": {
91
+ "type": "object"
92
+ },
93
+ "repeated_int32": {
94
+ "type": "array",
95
+ "items": {
96
+ "type": "integer"
97
+ }
98
+ },
99
+ "repeated_int64": {
100
+ "type": "array",
101
+ "items": {
102
+ "type": "string"
103
+ }
104
+ },
105
+ "repeated_uint32": {
106
+ "type": "array",
107
+ "items": {
108
+ "type": "integer"
109
+ }
110
+ },
111
+ "repeated_uint64": {
112
+ "type": "array",
113
+ "items": {
114
+ "type": "string"
115
+ }
116
+ },
117
+ "repeated_sint32": {
118
+ "type": "array",
119
+ "items": {
120
+ "type": "integer"
121
+ }
122
+ },
123
+ "repeated_sint64": {
124
+ "type": "array",
125
+ "items": {
126
+ "type": "string"
127
+ }
128
+ },
129
+ "repeated_fixed32": {
130
+ "type": "array",
131
+ "items": {
132
+ "type": "integer"
133
+ }
134
+ },
135
+ "repeated_fixed64": {
136
+ "type": "array",
137
+ "items": {
138
+ "type": "string"
139
+ }
140
+ },
141
+ "repeated_sfixed32": {
142
+ "type": "array",
143
+ "items": {
144
+ "type": "integer"
145
+ }
146
+ },
147
+ "repeated_sfixed64": {
148
+ "type": "array",
149
+ "items": {
150
+ "type": "string"
151
+ }
152
+ },
153
+ "repeated_float": {
154
+ "type": "array",
155
+ "items": {
156
+ "type": "number"
157
+ }
158
+ },
159
+ "repeated_double": {
160
+ "type": "array",
161
+ "items": {
162
+ "type": "number"
163
+ }
164
+ },
165
+ "repeated_bool": {
166
+ "type": "array",
167
+ "items": {
168
+ "type": "boolean"
169
+ }
170
+ },
171
+ "repeated_string": {
172
+ "type": "array",
173
+ "items": {
174
+ "type": "string"
175
+ }
176
+ },
177
+ "repeated_bytes": {
178
+ "type": "array",
179
+ "items": {
180
+ "type": "string"
181
+ }
182
+ },
183
+ "repeated_nested_message": {
184
+ "type": "array",
185
+ "items": {
186
+ "type": "object"
187
+ }
188
+ },
189
+ "repeated_foreign_message": {
190
+ "type": "array",
191
+ "items": {
192
+ "type": "object"
193
+ }
194
+ },
195
+ "repeated_import_message": {
196
+ "type": "array",
197
+ "items": {
198
+ "type": "object"
199
+ }
200
+ },
201
+ "repeated_nested_enum": {
202
+ "type": "array",
203
+ "items": {
204
+ "enum": [
205
+ "FOO",
206
+ "BAR",
207
+ "BAZ"
208
+ ]
209
+ }
210
+ },
211
+ "repeated_foreign_enum": {
212
+ "type": "array",
213
+ "items": {
214
+ "enum": [
215
+ "FOREIGN_FOO",
216
+ "FOREIGN_BAR"
217
+ ]
218
+ }
219
+ },
220
+ "repeated_import_enum": {
221
+ "type": "array",
222
+ "items": {
223
+ "enum": [
224
+ "SIMPLE_FOO",
225
+ "SIMPLE_BAR"
226
+ ]
227
+ }
228
+ },
229
+ "repeated_string_piece": {
230
+ "type": "array",
231
+ "items": {
232
+ "type": "string"
233
+ }
234
+ },
235
+ "repeated_cord": {
236
+ "type": "array",
237
+ "items": {
238
+ "type": "string"
239
+ }
240
+ },
241
+ "repeated_lazy_message": {
242
+ "type": "array",
243
+ "items": {
244
+ "type": "object"
245
+ }
246
+ },
247
+ "oneof_uint32": {
248
+ "type": "integer"
249
+ },
250
+ "oneof_nested_message": {
251
+ "type": "object"
252
+ },
253
+ "oneof_string": {
254
+ "type": "string"
255
+ },
256
+ "oneof_bytes": {
257
+ "type": "string"
258
+ },
259
+ "oneof_cord": {
260
+ "type": "string"
261
+ },
262
+ "oneof_string_piece": {
263
+ "type": "string"
264
+ },
265
+ "oneof_lazy_nested_message": {
266
+ "type": "object"
267
+ }
268
+ },
269
+ "required": [
270
+ "optional_int32",
271
+ "optional_int64",
272
+ "optional_uint32",
273
+ "optional_uint64",
274
+ "optional_sint32",
275
+ "optional_sint64",
276
+ "optional_fixed32",
277
+ "optional_fixed64",
278
+ "optional_sfixed32",
279
+ "optional_sfixed64",
280
+ "optional_float",
281
+ "optional_double",
282
+ "optional_bool",
283
+ "optional_string",
284
+ "optional_bytes",
285
+ "optional_nested_message",
286
+ "optional_foreign_message",
287
+ "optional_import_message",
288
+ "optional_nested_enum",
289
+ "optional_foreign_enum",
290
+ "optional_import_enum",
291
+ "optional_string_piece",
292
+ "optional_cord",
293
+ "optional_bytes_cord",
294
+ "optional_lazy_message",
295
+ "optional_unverified_lazy_message",
296
+ "repeated_int32",
297
+ "repeated_int64",
298
+ "repeated_uint32",
299
+ "repeated_uint64",
300
+ "repeated_sint32",
301
+ "repeated_sint64",
302
+ "repeated_fixed32",
303
+ "repeated_fixed64",
304
+ "repeated_sfixed32",
305
+ "repeated_sfixed64",
306
+ "repeated_float",
307
+ "repeated_double",
308
+ "repeated_bool",
309
+ "repeated_string",
310
+ "repeated_bytes",
311
+ "repeated_nested_message",
312
+ "repeated_foreign_message",
313
+ "repeated_import_message",
314
+ "repeated_nested_enum",
315
+ "repeated_foreign_enum",
316
+ "repeated_import_enum",
317
+ "repeated_string_piece",
318
+ "repeated_cord",
319
+ "repeated_lazy_message",
320
+ "oneof_uint32",
321
+ "oneof_nested_message",
322
+ "oneof_string",
323
+ "oneof_bytes",
324
+ "oneof_cord",
325
+ "oneof_string_piece",
326
+ "oneof_lazy_nested_message"
327
+ ]
328
+ }
@@ -0,0 +1,105 @@
1
+ syntax = "proto3";
2
+
3
+ package everything.v1;
4
+
5
+ import "simple/simple.proto";
6
+ import "google/protobuf/descriptor.proto";
7
+
8
+ extend google.protobuf.FieldOptions {
9
+ int32 some_option = 51234;
10
+ }
11
+
12
+ enum ForeignEnum {
13
+ FOREIGN_FOO = 0;
14
+ FOREIGN_BAR = 1;
15
+ }
16
+
17
+ message ForeignMessage {
18
+ int32 id = 1;
19
+ string name = 2;
20
+ }
21
+ message TestAllTypes {
22
+
23
+ enum NestedEnum {
24
+ FOO = 0;
25
+ BAR = 2;
26
+ BAZ = 3;
27
+ }
28
+
29
+ int32 optional_int32 = 1;
30
+ int64 optional_int64 = 2;
31
+ uint32 optional_uint32 = 3;
32
+ uint64 optional_uint64 = 4;
33
+ sint32 optional_sint32 = 5;
34
+ sint64 optional_sint64 = 6;
35
+ fixed32 optional_fixed32 = 7;
36
+ fixed64 optional_fixed64 = 8;
37
+ sfixed32 optional_sfixed32 = 9;
38
+ sfixed64 optional_sfixed64 = 10;
39
+ float optional_float = 11;
40
+ double optional_double = 12;
41
+ bool optional_bool = 13;
42
+ string optional_string = 14;
43
+ bytes optional_bytes = 15;
44
+ NestedMessage optional_nested_message = 18;
45
+ ForeignMessage optional_foreign_message = 19;
46
+ simple.v1.SimpleMessage optional_import_message = 20;
47
+ NestedEnum optional_nested_enum = 21;
48
+ ForeignEnum optional_foreign_enum = 22;
49
+ simple.v1.SimpleEnum optional_import_enum = 23;
50
+ string optional_string_piece = 24 [ctype = STRING_PIECE];
51
+ string optional_cord = 25 [ctype = CORD];
52
+ bytes optional_bytes_cord = 86 [ctype = CORD];
53
+ NestedMessage optional_lazy_message = 27 [lazy = true];
54
+ NestedMessage optional_unverified_lazy_message = 28 [unverified_lazy = true];
55
+ repeated int32 repeated_int32 = 31;
56
+ repeated int64 repeated_int64 = 32;
57
+ repeated uint32 repeated_uint32 = 33;
58
+ repeated uint64 repeated_uint64 = 34;
59
+ repeated sint32 repeated_sint32 = 35;
60
+ repeated sint64 repeated_sint64 = 36;
61
+ repeated fixed32 repeated_fixed32 = 37;
62
+ repeated fixed64 repeated_fixed64 = 38;
63
+ repeated sfixed32 repeated_sfixed32 = 39;
64
+ repeated sfixed64 repeated_sfixed64 = 40;
65
+ repeated float repeated_float = 41;
66
+ repeated double repeated_double = 42;
67
+ repeated bool repeated_bool = 43;
68
+ repeated string repeated_string = 44;
69
+ repeated bytes repeated_bytes = 45;
70
+ repeated NestedMessage repeated_nested_message = 48;
71
+ repeated ForeignMessage repeated_foreign_message = 49;
72
+ repeated simple.v1.SimpleMessage repeated_import_message = 50;
73
+ repeated NestedEnum repeated_nested_enum = 51;
74
+ repeated ForeignEnum repeated_foreign_enum = 52;
75
+ repeated simple.v1.SimpleEnum repeated_import_enum = 53;
76
+ repeated string repeated_string_piece = 54 [ctype = STRING_PIECE];
77
+ repeated string repeated_cord = 55 [ctype = CORD];
78
+ repeated NestedMessage repeated_lazy_message = 57 [lazy = true];
79
+ oneof oneof_field {
80
+ uint32 oneof_uint32 = 111;
81
+ NestedMessage oneof_nested_message = 112;
82
+ string oneof_string = 113;
83
+ bytes oneof_bytes = 114;
84
+ string oneof_cord = 115 [ctype = CORD];
85
+ string oneof_string_piece = 116 [ctype = STRING_PIECE];
86
+ NestedMessage oneof_lazy_nested_message = 117 [lazy = true];
87
+ }
88
+
89
+ message NestedMessage {
90
+ int32 bb = 1 [(everything.v1.some_option) = 1234
91
+ ];
92
+ }
93
+
94
+ message OptionalGroup {
95
+ int32 a = 17;
96
+ }
97
+
98
+ message RepeatedGroup {
99
+ int32 a = 47;
100
+ }
101
+ }
102
+ service TestService {
103
+ rpc TestMethod(TestAllTypes) returns (ForeignMessage) {
104
+ };
105
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "type": "object",
4
+ "properties": {
5
+ "name": {
6
+ "type": "string"
7
+ },
8
+ "simple": {
9
+ "type": "object"
10
+ }
11
+ },
12
+ "required": [
13
+ "name",
14
+ "simple"
15
+ ]
16
+ }
@@ -0,0 +1,28 @@
1
+ syntax = "proto3";
2
+
3
+ package referenced.v1;
4
+
5
+ import "simple/simple.proto";
6
+
7
+ message MessageA {
8
+
9
+ message MessageAA {
10
+ string name = 1;
11
+ simple.v1.SimpleMessage simple = 2;
12
+ }
13
+
14
+ message MessageAB {
15
+ string name = 1;
16
+ }
17
+ }
18
+ message MessageB {
19
+
20
+ message MessageBA {
21
+ string name = 1;
22
+ simple.v1.SimpleMessage simple = 2;
23
+ }
24
+
25
+ message MessageBB {
26
+ string name = 1;
27
+ }
28
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ "type": "record",
3
+ "name": "MessageBA",
4
+ "namespace": "referenced.v1",
5
+ "fields": [
6
+ {
7
+ "name": "simple",
8
+ "type": {
9
+ "type": "record",
10
+ "name": "SimpleMessage",
11
+ "namespace": "simple.v1",
12
+ "fields": [
13
+ {
14
+ "name": "name",
15
+ "type": "string"
16
+ }
17
+ ]
18
+ }
19
+ }
20
+ ]
21
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "type": "object",
4
+ "properties": {
5
+ "name": {
6
+ "type": "string"
7
+ }
8
+ },
9
+ "required": [
10
+ "name"
11
+ ]
12
+ }
@@ -0,0 +1,12 @@
1
+ syntax = "proto3";
2
+
3
+ package simple.v1;
4
+
5
+ enum SimpleEnum {
6
+ SIMPLE_FOO = 0;
7
+ SIMPLE_BAR = 1;
8
+ }
9
+
10
+ message SimpleMessage {
11
+ string name = 1;
12
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "type": "record",
3
+ "name": "SimpleMessage",
4
+ "namespace": "simple.v1",
5
+ "fields": [
6
+ {
7
+ "name": "name",
8
+ "type": "string"
9
+ }
10
+ ]
11
+ }
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'simplecov'
4
+ SimpleCov.start
5
+
6
+ $LOAD_PATH.unshift(File.expand_path('../lib', __dir__))
7
+ $LOAD_PATH.unshift(File.expand_path('gen', __dir__))
8
+ Dir["#{__dir__}/gen/**/*.rb"].each { |file| require file }
9
+ require 'schema_registry_client'
10
+ require 'webmock/rspec'
11
+
12
+ RSpec.configure do |config|
13
+ config.full_backtrace = true
14
+
15
+ config.shared_context_metadata_behavior = :apply_to_host_groups
16
+ end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: schema_registry_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Orner
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2026-01-02 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: avro
@@ -136,19 +135,58 @@ dependencies:
136
135
  - - ">="
137
136
  - !ruby/object:Gem::Version
138
137
  version: '0'
139
- description:
140
138
  email:
141
139
  - daniel.orner@flipp.com
142
140
  executables: []
143
141
  extensions: []
144
142
  extra_rdoc_files: []
145
- files: []
143
+ files:
144
+ - ".github/workflows/lint.yml"
145
+ - ".github/workflows/release.yml"
146
+ - ".github/workflows/test.yml"
147
+ - ".gitignore"
148
+ - ".rspec"
149
+ - ".rubocop.yml"
150
+ - CHANGELOG.md
151
+ - Gemfile
152
+ - Gemfile.lock
153
+ - LICENSE
154
+ - README.md
155
+ - Rakefile
156
+ - lib/schema_registry_client.rb
157
+ - lib/schema_registry_client/avro_schema_store.rb
158
+ - lib/schema_registry_client/cached_confluent_schema_registry.rb
159
+ - lib/schema_registry_client/confluent_schema_registry.rb
160
+ - lib/schema_registry_client/output/json_schema.rb
161
+ - lib/schema_registry_client/output/proto_text.rb
162
+ - lib/schema_registry_client/schema/avro.rb
163
+ - lib/schema_registry_client/schema/base.rb
164
+ - lib/schema_registry_client/schema/proto_json_schema.rb
165
+ - lib/schema_registry_client/schema/protobuf.rb
166
+ - lib/schema_registry_client/version.rb
167
+ - lib/schema_registry_client/wire.rb
168
+ - schema_registry_client.gemspec
169
+ - spec/decoding_spec.rb
170
+ - spec/encoding_spec.rb
171
+ - spec/gen/everything/everything_pb.rb
172
+ - spec/gen/referenced/referer_pb.rb
173
+ - spec/gen/simple/simple_pb.rb
174
+ - spec/json_schema_spec.rb
175
+ - spec/proto_text_spec.rb
176
+ - spec/schemas/everything/everything.json
177
+ - spec/schemas/everything/everything.proto
178
+ - spec/schemas/referenced/referenced.json
179
+ - spec/schemas/referenced/referer.proto
180
+ - spec/schemas/referenced/v1/MessageBA.avsc
181
+ - spec/schemas/simple/simple.json
182
+ - spec/schemas/simple/simple.proto
183
+ - spec/schemas/simple/v1/SimpleMessage.avsc
184
+ - spec/spec_helper.rb
146
185
  homepage: https://github.com/flipp-oss/schema_registry_client
147
186
  licenses:
148
187
  - MIT
149
188
  metadata:
150
189
  rubygems_mfa_required: 'true'
151
- post_install_message:
152
190
  rdoc_options: []
153
191
  require_paths:
154
192
  - lib
@@ -163,8 +201,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
163
201
  - !ruby/object:Gem::Version
164
202
  version: '0'
165
203
  requirements: []
166
- rubygems_version: 3.4.10
167
- signing_key:
204
+ rubygems_version: 3.6.9
168
205
  specification_version: 4
169
- summary: Support for Protobuf files in Confluent Schema Registry
206
+ summary: Confluent Schema Registry client with support for Avro and Protobuf
170
207
  test_files: []