Thorbenl opened a new pull request, #283:
URL: https://github.com/apache/pulsar-dotpulsar/pull/283
Fixes #282
# Description
`Schema.Json<T>()` and `Schema.Json<T>(options)` passed
`Array.Empty<byte>()` as `SchemaInfo.Data`, causing the Pulsar broker
to reject producers with `IncompatibleSchemaException` ("No content to map
due to end-of-input") because its Jackson parser
received an empty schema definition.
This PR adds `JsonSchemaDefinitionGenerator` — a reflection-based generator
that produces an Avro-style schema definition
from `T`, matching what the Java client does. The parameterless and
options-only constructors now auto-generate the schema
definition. The explicit definition overload (`JsonSchema<T>(options,
definition)`) is unchanged and remains available as an
escape hatch for custom schema strings.
The generator:
- Maps .NET types to Avro types (string, int, long, float, double, boolean,
bytes)
- Handles nullable types as Avro unions (`["null", "type"]`)
- Handles enums, arrays, lists, dictionaries, and nested record types
- Respects `JsonPropertyNameAttribute`, `JsonIgnoreAttribute`, and
`PropertyNamingPolicy`
# Regression
Yes — this was introduced in 5.2.0 with the addition of JSON schema support
(#279). The explicit definition overload worked
correctly, but the parameterless and options-only constructors did not
produce a broker-compatible schema.
# Testing
- 16 new unit tests for `JsonSchemaDefinitionGenerator` covering all type
mappings, naming policies, attribute handling,
nullables, enums, collections, dictionaries, and nested types
- 3 new unit tests on `JsonSchema<T>` verifying constructors produce
non-empty schema data and that explicit definitions
still take priority
- All 11 existing `JsonSchemaTests` continue to pass
- Builds cleanly across all 5 target frameworks (netstandard2.0,
netstandard2.1, net8.0, net9.0, net10.0)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]