[JsonSchema] Only build schemas which can be serialized / deserialied#6276
[JsonSchema] Only build schemas which can be serialized / deserialied#6276GeLoLabs wants to merge 1 commit intoapi-platform:mainfrom
Conversation
|
use |
|
@soyuka Using the flag What I want is to keep the operation in the OpenAPI spec but skip the associated schema as my Currenlty, it includes the schema of the class tagged as |
This is quite wrong if a class is marked as a resource it is a public API. I like your patch though, is it possible to add a test on that though? |
|
@soyuka I mean it exposes unwanted properties as I use deserialization / serialization groups everywhere on this ApiResource for all its operations except for the delete operation. Then, it ends by adding the "root" resource (not specific to a (de)serializer group) with all is properties, something I don't want. I will complete this PR with some tests. |
src/JsonSchema/SchemaFactory.php
Outdated
| @@ -65,6 +65,14 @@ public function buildSchema(string $className, string $format = 'json', string $ | |||
|
|
|||
| [$operation, $serializerContext, $validationGroups, $inputOrOutputClass] = $metadata; | |||
There was a problem hiding this comment.
To save you digging too hard, and easing the rebase, after my last PR these are now assigned here:
core/src/JsonSchema/SchemaFactory.php
Lines 62 to 70 in 678eb4f
There was a problem hiding this comment.
Thanks, I just rebase my PR
|
@soyuka @GwendolenLynch I'm not familiar with the project test suite. Can you point me where / how I can add tests about this feature ? |
6e9c3d9 to
97093c0
Compare
97093c0 to
e404ed2
Compare
|
I just rebased the PR. Can someone helps me with the missing tests ? |
|
This should already be working using |
Hello,
This PR is a first step for a discussion about a bugfix.
Given the following ApiResource:
If I generate the OpenAPI documentation using
php bin/console api:openapi:export, theApiPlatform\OpenApi\Factory\OpenApiFactorywill generate a doc including the components "MyResource" whereas no operation references it (request / response -> no content).Futhermore, it exposes all
MyResourceproperties which should stay internal as it is not part of our API.I would expect that the
OpenApiFactoryonly builds schemas that operation can deserialize / serialize and this is what this PR does.Now, to fix my OpenAPI doc, I can just do the following:
WDYT ?