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

v2 - POST /topics/ - return full error why validation has been failed #1239

Open
rkobryn opened this issue Jan 16, 2024 · 0 comments
Open

v2 - POST /topics/ - return full error why validation has been failed #1239

rkobryn opened this issue Jan 16, 2024 · 0 comments

Comments

@rkobryn
Copy link

rkobryn commented Jan 16, 2024

Following JSON schema is deployed to the schema registry:

{
  "type": "object",
  "additionalProperties": false,
  "title": "demo.schema.v3",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "required": [
    "metafields",
    "MESSAGE"
  ],
  "properties": {
    "MESSAGE": {
      "oneOf": [
        {
          "type": "null"
        },
        {
          "type": "object",
          "required": [
            "required1",
            "required2",
            "required3",
            "required4",
            "required5"
          ],
          "properties": {
            "required3": {
              "type": "boolean"
            },
            "required4": {
              "type": "string",
              "minLength": 1,
              "maxLength": 40
            },
            "required5": {
              "type": "integer",
              "maximum": 9999999999,
              "exclusiveMinimum": 0
            },
            "required1": {
              "type": "string",
              "minLength": 1,
              "maxLength": 40
            },
            "required2": {
              "type": "integer",
              "maximum": 9999999999,
              "exclusiveMinimum": 0
            }
          }
        }
      ]
    }
  }
}

Following message body is being send to the rest proxy:

{
   "value_schema_id":9996756,
   "key_schema": "{\"type\": \"string\"}",
   "records":[
      {
         "key":"123",
         "value":{
            "MESSAGE":{
               "required1":"123"
            }
         }
      }
   ]
}

Actual HTTP response:

{
    "error_code": 400,
    "message": "Bad Request: #: 6 schema violations found"
}

Is there a way to log full erro message? e.g:

{
    "error_code": 400,
    "message": "Bad Request: #: 6 schema violations found: (Message:
JSON is valid against no schemas from 'oneOf'. Schema path:
#/properties/MESSAGE/oneOf; Message: Required properties are missing from object: required2, required3, required4, required5.
Schema path: #/properties/MESSAGE/oneOf/1/required; ....) "
}

Response is just an example, any message which is showing detailed errors is ok

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant