-
Notifications
You must be signed in to change notification settings - Fork 93
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
Validation issue when using allOf with $ref #118
Comments
Hi, all "OK" tests do not utilze |
@scaytrase sorry, not sure I follow. I provided three different tests which are all actually the same in terms of schema, but achieved differently:
All schemas are equivalent, but when using Is that clearer? |
The current tests are clear, but they are not allow me to diagnose since you're changing two things at once - adding override and adding I'm asking you to replace two first tests with the third one, but having inline schema instead of |
@scaytrase I've updated my first message with the fix and a fourth test checking You seem to be right – that test fails too |
Yea, my guess was right. I think allOf:
- nullable: false
- nullable: true Which results in definition impossible to match. I think the root cause is here (example, not the behaviour) I don't really thing it comes against OAS3 as OAS3 clearly says that "if you need to allow null - set nullable: true". That also means nullable is by default false. |
type: object
properties:
test:
allOf:
- type: string
description: a dummy object
example: foobar
- description: different description
nullable: true Is this even a valid schema? Doesn't the second schema of |
We've discussed somewhere, that actually |
Could there be discrepancies in the way documentation tools such as Swagger UI and other tools like cebe/phpopenapi interpret OpenAPI definitions? Because with this example: type: object
properties:
test:
allOf:
- type: string
description: a dummy object
example: foobar
- description: different description
nullable: true Swagger UI correctly (in my opinion) understands that the resulting schema has Even from the documentation, it is my understanding that at least the properties which are in the second schema but not in the first one should be in the resulting schema (in this case, |
I found no clear statements about default nullability. Currently @cebe WDYT ? |
I've given this another go and updated my initial post with a 5th test where both sides have Now I admit I may be trying to use @cebe would be great to have your input on this |
I'm also looking at this same situation. It's unclear to me what the intended outcome is from the docs since this situation doesn't seem to be explicitly called out in any way. A few things I found which may be helpful to the conversation?
|
I think this topic should be raised to the OAS 3 core itself. We will support any outcome whatether they decide. |
Looks like there's an existing issue related to this on core. The original issue was on The result of that conversation is a clarification proposal for OAS 3.0.3 In that proposal (link), our situation here would be considered incorrect OAS:
Also noted is that the default value for From my read of this, it seems to answer this question (i.e. change the way I've written my spec), and at least my understanding of it would indicate there's no changes necessary here (or on the underlying php-openapi)? |
Not what I would have hoped for, but fair enough! Thanks for digging that up @zerodahero. I still think the last test case I provided indicates that something is wrong ( That being said, it's now clear that we should not attempt to overwrite schema elements using Closing for now as I don't think there's much that can be done about it |
I'm in a similar situation where public function testAllOfSingle(): void
{
$spec = <<<SPEC
openapi: 3.0.2
info:
title: Dummy API
version: 0.0.1
paths:
/dummy:
get:
summary: dummy
operationId: dummy
responses:
200:
description: dummy
content:
application/json:
schema:
\$ref: '#/components/schemas/dummy'
components:
schemas:
dummy:
type: object
properties:
test:
allOf:
- type: string
description: a dummy object
nullable: true
example: foobar
SPEC;
$this->assertResponseMatchesSpec($spec);
} This seems like it will become less of a problem once OpenAPI 3.1.0 becomes widely used - it replaces public function testAllOfSingleRootNullable(): void
{
$spec = <<<SPEC
openapi: 3.0.2
info:
title: Dummy API
version: 0.0.1
paths:
/dummy:
get:
summary: dummy
operationId: dummy
responses:
200:
description: dummy
content:
application/json:
schema:
\$ref: '#/components/schemas/dummy'
components:
schemas:
dummy:
type: object
properties:
test:
nullable: true
allOf:
- type: string
description: a dummy object
example: foobar
SPEC;
$this->assertResponseMatchesSpec($spec);
} |
Hi,
Validating responses whose schemas is a reference with some overwritten values doesn't seem to work properly. What's seemingly happening is that the reference is correctly read but the overwritten values are ignored.
Here is a test class so you can see for yourself:
It seems kinda related to this issue.
I'm also not 100% sure if this is coming from this package or cebe/php-openapi.
I'm using version 0.15.2 at the moment.
Cheers,
Yannick
The text was updated successfully, but these errors were encountered: