Skip to content

Include parameter name in JSON Schema error path on unmarshalling #246

Closed
@playpauseandstop

Description

@playpauseandstop

Hi,

I've run into the problem, when I'm not able to show which invalid parameter raised an InvalidSchemaValue.

As InvalidSchemaValue contains a list of schema_errors (List[JsonSchemaValidationError]) I expect to have relative_path / absoulte_path filled for its items. But in reality all items have empty path / relative_path attributes (and absolute_path property).

I've managed to fix this by manually add parameter name as JSON Schem error path as,

        try:
            return unmarshaller(value)
        except InvalidSchemaValue as err:
            # Modify invalid schema validation errors to include parameter name
            if isinstance(param_or_media_type, Parameter):
                param_name = param_or_media_type.name

                for schema_error in err.schema_errors:
                    schema_error.path = schema_error.relative_path = deque(
                        [param_name]
                    )

            raise err

instead of plain,

        return unmarshaller(value)

But would like to have path filled by openapi_core instead.


More details in playpauseandstop/rororo#53

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/castingIndicates an issue on casting area.area/unmarshallingIndicates an issue on unmarshalling area.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions