GitHub user anthonyikeda added a comment to the discussion: [Bug] Pulsar Client 
ignores producer schema

Attempted the same with a JSON Schema:

product.schema.json

```json
{
    "$schema" : "https://json-schema.org/draft/2020-12/schema";,
    "$id": "http://example.com/product.schema.json";,
    "title" : "Product",
    "description" : "A product in the catalog",
    "type" : "object",
    "properties":{
        "product_id" : {
            "description" : "A unique identifier",
            "type" : "integer"
        },
        "product_name" : {
            "description" : "name of the product",
            "type" : "string"
        },
        "product_description" : {
            "description" : "A description of the product",
            "type" : "string"
        }
    },
    "required": [ "product_id", "product_name"]
}
```

topic-schema-2.json

```json
{
    "type" : "JSON",
    "schema" : "{ \"$schema\" : 
\"https://json-schema.org/draft/2020-12/schema\";, \"$id\": 
\"http://example.com/product.schema.json\";, \"title\" : \"Product\", 
\"description\" : \"A product in the catalog\", \"type\" : \"object\", 
\"properties\":{\"product_id\" : {\"description\" : \"A unique identifier\", 
\"type\" : \"integer\" },\"product_name\" : {\"description\" : \"name of the 
product\", \"type\" : \"string\" }, \"product_description\" : { \"description\" 
: \"A description of the product\", \"type\" : \"string\" }  },\"required\": [ 
\"product_id\", \"product_name\"]}"
}
```

Upload schema:

```bash
$ bin/pulsar-admin topics create 
persistent://my-tenant/my-namespace/basic-topic-4
$ bin/pulsar-admin schemas upload -f topic-schema-2.json 
persistent://my-tenant/my-namespace/basic-topic-4
2023-04-05T14:33:42,660-0700 [AsyncHttpClient-7-1] WARN  
org.apache.pulsar.client.admin.internal.BaseResource - 
[http://localhost:8080/admin/v2/schemas/my-tenant/my-namespace/basic-topic-4/schema]
 Failed to perform http post request: javax.ws.rs.ClientErrorException: HTTP 
422 Invalid schema definition data for JSON schema
HTTP 422 Invalid schema definition data for JSON schema

Reason: HTTP 422 Invalid schema definition data for JSON schema
```

I think in this attempt it's about how to position a JSON schema vs an AVRO 
schema.

Is JSON Schema meant to represent an AVRO schema definition written in JSON or 
actual JSON Schema (https://json-schema.org) ?


GitHub link: 
https://github.com/apache/pulsar/discussions/20586#discussioncomment-6187222

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]

Reply via email to