Skip to content

ErrorException : Undefined property: stdClass::$type #38

Closed

Description

@xbojch

The allOf property is not resolved correctly and doesn't act as a replacement for the type property.
Validating a response with a spec below (only the relevant parts) results in the error in the issue title.

Is this an issue in Spectator or related to cebe/php-openapi#31?

Workaround
Replacing the allOf with a type property resolves the error.

{
  "components": {
    "schemas": {
      "Name": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          }
        }
      },
      "MySchema": {
        "title": "MySchema",
        "allOf": [
          {
            "$ref": "#/components/schemas/Name"
          },
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "integer"
              },
              "description": {
                "type": "string"
              }
            },
            "required": [
              "type"
            ]
          }
        ]
      }
    }
  }
}

Activity

  1. hotmeteor commented on Apr 21, 2021

    @hotmeteor
    Owner

    @xbojch Can you provide more information on what you're trying to do? I added a test for this and didn't hit an issue, but I'm sure I'm not replicating it properly: https://github.com/hotmeteor/spectator/blob/v1.0.0/tests/ResponseValidatorTest.php#L277

  2. xbojch commented on Apr 21, 2021

    @xbojch
    Author

    The Components.v1.yaml looks correct. The path / that's being tested is not defined in it though or am I missing something.
    The schemaMySchema seems to not be used anywhere. Try referencing the MySchema in a response, that tripped it for me.

  3. hotmeteor commented on Apr 21, 2021

    @hotmeteor
    Owner

    @xbojch This should be fixed in v1.0.1. There is an issue with the parsing of component references, so I've got a workaround until the underlying package is fixed.

  4. xbojch commented on Apr 21, 2021

    @xbojch
    Author

    Thank you very much @hotmeteor. I'll give it another try, because I just love how much shorter and more understandable it makes the tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions