Axway-API-Management-Plus / openapi-validator

Validates request and response based on the OpenAPI specification
Apache License 2.0
3 stars 1 forks source link

How to retrieve data which fields validation failed #5

Closed venkatesulua1990 closed 2 years ago

venkatesulua1990 commented 2 years ago

Hi when validation fails it prints in logs like below and the same i wan to return back to Consumer in response, please let me know how to fetch that details , is that stored in any msg variable?

OpenAPIValidator: Object instance has properties which are not allowed by the schema: ["data"] -- ERROR | 3/25/22, 11:30:11.570 | OpenAPIValidator: Object has missing required properties (["created","drugInfo","id","patient"])
cwiechmann commented 2 years ago

Hi @venkatesulua1990, I have created version 1.4.0 of the OpenAPI Validator, that makes it easier to return the validation details to the client.

See the updated README which now includes that requirement.

When using for instance the JSON Error policy filter to handle this error the client will get the following HTTP 400 Response information:

{
  "reasons": [
    {
      "language": "en",
      "message": "[ERROR - [Path '/id'] Instance type (string) does not match any allowed primitive type (allowed: [\"integer\"]): []]"
    }
  ],
  "details": {
    "msgId": "Id-297f41623d05114647150f11"
  }
}
venkatesulua1990 commented 2 years ago

Thanks for making it , it really help our project