Skip to content
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

Add JSON Schema support to schema_registry_encode / schema_registry_decode #1150

Open
davidlday opened this issue Feb 28, 2022 · 3 comments
Open
Labels
enhancement processors Any tasks or issues relating specifically to processors

Comments

@davidlday
Copy link

Please add JSON Schema schema registry support.

@Jeffail Jeffail added enhancement processors Any tasks or issues relating specifically to processors labels Mar 1, 2022
@jc43081
Copy link

jc43081 commented Sep 6, 2022

We are currently leveraging Confluent for our brokers and are working towards implementing Benthos without our company. One of the benefits of Confluent is the use of Schema Registry for managing schemas and validating messages. Schema Registry has expanded its support beyond AVRO and now includes JSON Schema.

We would like to take advantage of JSON Schema validation within Benthos using Schema Registry. Adding support in the schema_registry_encode and decode processors will be a big benefit to us on our Benthos journey.

@zcmack
Copy link

zcmack commented Sep 16, 2022

i'm interested in working on this. just for context, here is a sample of how the existing code does the deserialization:

    "name": { "string": "zcmack" },
    "time": { "long.timestamp": 1661187534012000 },

where the schema definition is:

    {
      "name": "name",
      "type": [
        "string",
        "null"
      ]
    },

and

    {
      "name": "time",
      "type": [
        {
          "type": "long",
          "logicalType": "timestamp"
        },
        "null"
      ]
    }

for my use case, i do not need the type information so i would expect to produce something like this:

{"name": "zcmack",
 "time": 1661187534012000
}

any concerns with this approach, or should i include typings like so:

{"name": {"type": "string", "value": "zcmack"},
 "time": {"type": "long", "value": 1661187534012000
}

@mihaitodor
Copy link
Collaborator

mihaitodor commented Sep 16, 2022

i'm interested in working on this.

Cool, thanks @zcmack!

i do not need the type information

We'll have to support both modes. avro_raw_json was added to the schema_registry_decode processor in #1407 and schema_registry_encode already supports it. Have a look at the tests here for examples.

While it won't impact you, linkedin/goavro#252 will require a breaking change in the way logical types are deserialised when avro_raw_json: true. I need to work with the goavro maintainers to get that sorted sometime soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement processors Any tasks or issues relating specifically to processors
Projects
None yet
Development

No branches or pull requests

5 participants