Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
xbojch opened this issue Apr 9, 2021 · 5 comments
Closed

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

xbojch opened this issue Apr 9, 2021 · 5 comments

Comments

@xbojch
Copy link

xbojch commented Apr 9, 2021

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"
            ]
          }
        ]
      }
    }
  }
}
@xbojch
Copy link
Author

xbojch commented Apr 9, 2021

@hotmeteor
Copy link
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

@xbojch
Copy link
Author

xbojch commented Apr 21, 2021

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.

@hotmeteor
Copy link
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.

@xbojch
Copy link
Author

xbojch commented Apr 21, 2021

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants