confluentinc / kafka-rest

Confluent REST Proxy for Kafka
https://docs.confluent.io/current/kafka-rest/docs/index.html
Other
38 stars 641 forks source link

Json Schema not retrieved from schema-registry when using Content-Type: application/vnd.kafka.json.v2+json #1025

Open mbrembilla opened 2 years ago

mbrembilla commented 2 years ago

Hi, I would like to use Kafka Rest Proxy + Schema Registry with a JSON Schema, but every time I made a request to insert a new message on a topic, the schema isn't retrieved from the schema-registry. So there is no validation and I can write anything on the topic.

I always used Avro schema without problems; I don't get what I'm doing wrong.

Below an example of one of my many tries: Upload the schema

$ curl -X POST http://localhost:8081/subjects/persons-value/versions \
    -header 'Content-Type: application/vnd.schemaregistry.v1+json' \
    --data '
{
    "schemaType": "JSON",
    "schema": "{\"definitions\":{\"record:examples.Person\":{\"type\":\"object\",\"required\":[\"fullName\"],\"additionalProperties\":false,\"properties\":{\"fullName\":{\"type\":\"string\"}}}},\"$ref\":\"#/definitions/record:examples.Person\"}"
}'

RESPONSE
{"id":1}

Upload of a message that isn't compliant with the schema

$ curl -X POST 'http://localhost:8082/topics/persons' \
    --header 'Content-Type: application/vnd.kafka.json.v2+json' \
    --data '
{
    "value_schema_id": 1,
    "records": [
        {
            "value": 123
        }
    ]
}'

RESPONSE
{
    "offsets": [
        {
            "partition": 0,
            "offset": 1,
            "error_code": null,
            "error": null
        }
    ],
    "key_schema_id": null,
    "value_schema_id": null
}

I also tried:

but nothing works

Can you please help me?

Regards, Mauro

aishwary-03 commented 1 week ago

Hi @mbrembilla , I am also facing the same issue. Could you please let me know if you are able to solve this issue and how?