Improve serialization groups filter doc#3007
Improve serialization groups filter doc#3007fredericbarthelet wants to merge 1 commit intoapi-platform:mainfrom
Conversation
86745bd to
8ee86b0
Compare
|
The filter's description should not be tied to the serialization formats. As I've tried to explain before in #2971, converting the filter description to whichever appropriate documentation format is the job of the But it might be a good idea to use a |
|
I agree with @teohhanhui, the filter should be agnostic of the documentation format (Swagger/OpenAPI/Hydra etc). However, describing it with a JSON Schema looks OK to me. Formats relying on JSON Schema (such as OpenAPI/Swagger) can use it directly, and others (such as Hydra) will have to convert it. As JSON Schema is kind of a standard (an Internet Draft actually, but that should become a RFC at some point), using it looks better to me than creating another custom format of our own. So the filter should only provide a |
|
Using a plain array (following the JSON Schema semantic) looks better to me than using a |
|
@teohhanhui @dunglas understood, no Schema use in getDescription return value. As of now we than have 2 strategy to "enrich" generated plain array description, that will then be eventually used by the DocumentationNormalizer :
Which one do you prefer in order to ensure consistency in this array ? |
|
@teohhanhui @dunglas I made a small concept PR to show you what I mean by This would ensure :
WDYT ? |
|
Uhh... I didn't realize we have That's bad and should be deprecated. |
|
@teohhanhui, noted, I removed swagger and openapi keys in my |
|
No, sorry. My comment is about those keys in the existing implementation. As for your suggestion of using a class, I don't think we'll do it. (Personally, I'd like to see everything being well-defined classes, but I understand it's not what we'd like to do in this project. That's why you see |
2d694ae to
dee7d46
Compare
|
@teohhanhui I updated For my knowledge, what is the advantage of using plain arrays instead of object to describe "options" arguments ? Is something like |
dee7d46 to
2da52d9
Compare
2da52d9 to
40f7abf
Compare
|
Hi @teohhanhui, I updated my PR with latest changes from master. Did you see my previous message :) ? Is there any remaining modification to be made on this PR ? |
40f7abf to
c90f350
Compare
|
Hello @teohhanhui, sorry to insist, but could you let me know if this PR is fine for you now :) ? |
93acf83 to
a1b09dd
Compare
a1b09dd to
e59bfe8
Compare
|
Sorry, I've somehow missed this one. 🙇♂️ I'm going to take a look now. |
| * - swagger (optional/deprecated): additional parameters for the path operation | ||
| * - openapi (optional/deprecated): additional parameters for the path operation in the version 3 |
There was a problem hiding this comment.
| * - swagger (optional/deprecated): additional parameters for the path operation | |
| * - openapi (optional/deprecated): additional parameters for the path operation in the version 3 | |
| * - swagger (optional) (deprecated): additional parameters for the path operation | |
| * - openapi (optional) (deprecated): additional parameters for the path operation in the version 3 |
| ]; | ||
|
|
||
| if ($this->whitelist) { | ||
| $description['schema'] = ['type' => 'array', 'items' => ['type' => 'string', 'enum' => $this->whitelist]]; |
There was a problem hiding this comment.
| $description['schema'] = ['type' => 'array', 'items' => ['type' => 'string', 'enum' => $this->whitelist]]; | |
| $description['schema'] = [ | |
| 'type' => 'array', | |
| 'items' => [ | |
| 'type' => 'string', | |
| 'enum' => $this->whitelist, | |
| ], | |
| ]; |
| } | ||
| } | ||
|
|
||
| /** @deprecated schema key should be used instead */ |
There was a problem hiding this comment.
We need to trigger deprecation errors instead. This phpdoc is unnecessary.
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
@dunglas @teohhanhui, I got inspired by existing
getDescriptionfunction of FilterProperty to add'enum'information to generated documentation.https://github.com/api-platform/core/blob/master/src/Serializer/Filter/PropertyFilter.php#L73-L105
However, I was wondering if I should not use your newly created
TypeFactoryto enrich generated array. I would do that by :SchemainFilterProperty::getDescriptionmethod with one uniqueenumproperty set to the withlisted serialization groups.schemakeyschemavalue found in parameter data as lastgetTypeargumentTypeFactory::getTypemethod to use provided schema to improve returned type (not only forBUILTIN_TYPE_OBJECTas it is the case right now)What do you think ? This could be ported as well on #2971, which is currently relying on a new
Schemaproperty defined without theSchema::classtype.#hackdayparis