Skip to content

[Bug]: Property name "$id" leads to TypeError "unhashable type: 'dict'" #608

@rtmiz

Description

@rtmiz

Actual Behavior

When a property named "$id" appears inside of an openAPI specification the openapi-core library fails whenever this property is part of a response validation (so when the field COULD appear in a response, it does not have to actually be in a response or be a required field).

"json_schema": {
                "type": "object",
                "title": "JSON Schema",
                "description": "A JSON Schema compliant to [JSON Schema draft-07](https://json-schema.org/draft-07/json-schema-validation.html) or later.\n\nJSON Schemas SHOULD always be dereferenced (i.e. all `$refs` should be resolved).\nThis allows clients to consume the schemas much better.\nClients are not expected to support dereferencing `$refs`.\n\nNote: The specified schema in the OpenAPI document is only a common subset of JSON Schema.\nAdditional keywords from the JSON Schema specification MAY be used.",
                "properties": {
                    "$schema": {
                        "description": "The JSON Schema version. If not given in the context of openEO,\ndefaults to `draft-07`.\n\nYou may need to add the default value for `$schema` property explicitly to the JSON Schema\nobject before passing it to a JSON Schema validator.",
                        "type": "string",
                        "format": "uri",
                        "default": "http://json-schema.org/draft-07/schema#"
                    },
                    "$id": {
                        "description": "ID of your JSON Schema.",
                        "type": "string",
                        "format": "uri"
                    },
                    "type": {
                        "description": "The allowed basic data type(s) for a value.\n\nIf this property is not present, all data types are allowed.",
                        "oneOf": [
                            {
                                "$ref": "#/components/schemas/json_schema_type"
                            },
                            {
                                "type": "array",
                                "minItems": 1,
                                "uniqueItems": true,
                                "items": {
                                    "$ref": "#/components/schemas/json_schema_type"
                                }
                            }
                        ]
                    },
                    "pattern": {
                        "type": "string",
                        "format": "regex",
                        "description": "The regular expression a string value must match against."
                    },
                    "enum": {
                        "type": "array",
                        "items": {},
                        "description": "An exclusive list of allowed values."
                    },
                    "minimum": {
                        "type": "number",
                        "description": "The minimum value (inclusive) allowed for a numerical value."
                    },
                    "maximum": {
                        "type": "number",
                        "description": "The maximum value (inclusive) allowed for a numerical value."
                    },
                    "minItems": {
                        "type": "number",
                        "minimum": 0,
                        "default": 0,
                        "description": "The minimum number of items required in an array."
                    },
                    "maxItems": {
                        "type": "number",
                        "minimum": 0,
                        "description": "The maximum number of items required in an array."
                    },
                    "items": {
                        "description": "Specifies schemas for the items in an array.",
                        "anyOf": [
                            {
                                "type": "array",
                                "minItems": 1,
                                "items": {
                                    "$ref": "#/components/schemas/json_schema"
                                }
                            },
                            {
                                "$ref": "#/components/schemas/json_schema"
                            }
                        ]
                    }
                },
                "additionalProperties": {
                    "description": "You can add any other property supported by the JSON Schema version that is given through the property `$schema`, so either [draft-07](https://json-schema.org/draft-07/json-schema-validation.html) or any later version."
                }
            },

(Taken from https://api.openeo.org/)

Expected Behavior

There should be no issue with properties named "$id", it should just work like any other name.

Steps to Reproduce

Add a property named "$id" to an internal schema object and validate a response that uses that schema.

OpenAPI Core Version

0.17.2

OpenAPI Core Integration

Requests

Affected Area(s)

Validation

References

OAI/OpenAPI-Specification#3302

Anything else we need to know?

No response

Would you like to implement a fix?

None

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugIndicates an issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions