Error Message missing helpful information about failed validation of discriminator schema

Issue #323 resolved
Former user created an issue

Hi,

we are using swagger-request-validator-core version 2.15.1.

It looks like there still is useful information lost when building the report message.

ImmutableMessage#toString prints:

ERROR - [Path '/productOrderItem/0/appointment'] Failed validation of discriminator schema '/components/schemas/Appointment': []

But debuging into SchemaValidator#validate reveals that com.github.fge.jsonschema.core.report.ProcessingMessage contains more helpful information for the same error:

error: failed validation of discriminator schema '/components/schemas/Appointment'
    level: "error"
    schema: "/components/schemas/Appointment"
    instance: {"pointer":"/productOrderItem/0/appointment"}
    domain: "validation"
    keyword: "discriminator"
    key: "err.swaggerv2.discriminator.fail"
    report: [{
            "level": "error",
            "schema": {
                "loadingURI": "#",
                "pointer": "/components/schemas/Appointment"
            },
            "instance": {
                "pointer": "/productOrderItem/0/appointment"
            },
            "domain": "validation",
            "keyword": "additionalProperties",
            "message": "object instance has properties which are not allowed by the schema: [\"@type\",\"validFor\"]",
            "unwanted": ["@type", "validFor"]
        }, {
            "level": "error",
            "schema": {
                "loadingURI": "#",
                "pointer": "/components/schemas/Appointment"
            },
            "instance": {
                "pointer": "/productOrderItem/0/appointment"
            },
            "domain": "validation",
            "keyword": "allOf",
            "message": "instance failed to match all required schemas (matched only 1 out of 2)",
            "matched": 1,
            "nrSchemas": 2,
            "reports": {
                "/components/schemas/Appointment/allOf/0": [],
                "/components/schemas/Appointment/allOf/1": [{
                        "level": "error",
                        "schema": {
                            "loadingURI": "#",
                            "pointer": "/components/schemas/Appointment/allOf/1"
                        },
                        "instance": {
                            "pointer": "/productOrderItem/0/appointment"
                        },
                        "domain": "validation",
                        "keyword": "additionalProperties",
                        "message": "object instance has properties which are not allowed by the schema: [\"@type\"]",
                        "unwanted": ["@type"]
                    }
                ]
            }
        }
    ]

Orignally reported as comment of https://bitbucket.org/atlassian/swagger-request-validator/issues/104/how-to-surface-nested-validation-errors-in

Comments (3)

  1. Log in to comment