Skip to content

Any way to get more detailed errors #390

@rtfpessoa

Description

@rtfpessoa

Hi,

When using the oapi.OapiRequestValidatorWithOptions is there a way to get a more detailed error?

When I have a parameter which is an enum and the value passed is not in the enum would be great to know the field failing the validation.

Instead I get a huge message about the whole schema:

{"error": "code=400, message=Request body has an error: doesn't match the schema: Doesn't match schema \"oneOf\", internal=Request body has an error: doesn't match the schema: Doesn't match schema \"oneOf\"\nSchema:\n  {\n    \"description\": \"Details of an event.\",\n    \"oneOf\": [\n      {\n        \"$ref\": \"#/components/schemas/Deployment\"\n      },\n      {\n        \"$ref\": \"#/components/schemas/Change\"\n      },\n      {\n        \"$ref\": \"#/components/schemas/Incident\"\n      }\n    ],\n    \"type\": \"object\"\n  }\n\nValue:\n  {\n    \"$type\": \"incidenta\",\n    \"incident_id\": \"1627554151\",\n    \"source\": \"api\",\n    \"time_created\": \"2021-07-29T09:10:00Z\",\n    \"time_resolved\": \"2021-07-29T09:10:00Z\"\n  }\n"}

In this case only the field $type is wrong not the whole object.
Also would be even better if we could let people know what are the valid options.

Any idea if any of this is possible or if this could even be implemented? I would be up to help if some pointers are provided.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions