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

Wrong error message when using an undefined property for a schema object property definition #165

Open
machitgarha opened this issue Jul 12, 2022 · 1 comment
Labels
bug Something isn't working needs investigation Work is needed to figure out the root cause of the problem.

Comments

@machitgarha
Copy link

First of all, thanks for the efforts made on php-openapi. :)

Take the following simple (minimal reproducable) example:

openapi: 3.0.3
info:
  title: Test
  version: 0.1.0
paths:
  /test:
    get:
      responses:
        "200":
          description: Test

components:
  schemas:
    answer:
      type: object
      properties:
        id:
          type: integer

We all know, this is perfectly valid. But for some odd reason, I thought the summary property is allowed in an Schema Object (i.e. id in this case), so I wrote the above example this way:

# ...Stripped...
        id:
          type: integer
          summary: Unique answer ID

As this becomes invalid (description must be used instead), php-openapi must handle this and print a good error message. Let's see:

OpenAPI v3.0 schema violations:
- [components.schemas.answer.properties.id.$ref] The property $ref is required
- [components.schemas.answer.properties.id] The property summary is not defined and the definition does not
 allow additional properties

Ignoring the second error message, the first one is really confusing, and is completely wrong in this case. This can be daunting if you run php-openapi on a big erroneous document and getting bunches of these errors.

@cebe
Copy link
Owner

cebe commented Jul 14, 2022

Thanks for reporting. The error message shown here is the result of running justinrainbow/json-schema validator against the schema provided by OpenAPI https://github.com/OAI/OpenAPI-Specification/tree/main/schemas/v3.0
Not sure if there is anything I can change about it from our code, needs to be checked.

@cebe cebe added bug Something isn't working needs investigation Work is needed to figure out the root cause of the problem. labels Jul 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs investigation Work is needed to figure out the root cause of the problem.
Projects
None yet
Development

No branches or pull requests

2 participants