api-platform / docs

API Platform documentation
https://api-platform.com/docs/
164 stars 1.05k forks source link

docs: parameters documentation #1932

Closed soyuka closed 2 months ago

GwendolenLynch commented 3 months ago

Thanks so much for your help lately, and for this Parameter work.

This all reads well for me, with two comments.

It might be worth adding a note/example specifically relative to JSON:API's include parameter. For example, when testing the beta I was using this to have the parameter show up in Swagger UI, et al:

#[GetCollection(
    parameters: ['include' => new QueryParameter(description: 'Included relationship paths, comma separated')],
)]
#[Get(
    parameters: ['include' => new QueryParameter(description: 'Included relationship paths, comma separated')],
)]

The other thing is with documentation the very long constructors are really hard to read. Can they be one property per-line to better communicate to the developer what they need to "pull in", or not?

soyuka commented 3 months ago

@GwendolenLynch you should be able to create a parameter with default values and use it as attribute right?

class IncludeParameter extends QueryParameter {
    public function __construct(...) {
        parent::__construct(description: 'my very long descr');
    }
}
GwendolenLynch commented 3 months ago

Ha! I didn't even think of trying something like that yet. I am liking this new feature more and more than I already did!