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

Request params inference from method calls on request, default request values support #356

Merged

Conversation

romalytvynenko
Copy link
Member

fixes #340

@romalytvynenko romalytvynenko merged commit d1d8e26 into main Apr 7, 2024
7 checks passed
@romalytvynenko romalytvynenko deleted the 340-add-ability-to-set-a-default-value-in-docs-for-params branch April 7, 2024 09:36
@jaimyborgman
Copy link
Contributor

jaimyborgman commented Jun 4, 2024

@romalytvynenko can we extend this with having /** @default */ working for ApiResourceItems?

Like for instance:

/**
 * @property Product $resource
 */
class ProductResource extends ResourceDto
{
    public function toArray(Request $request): array
    {
        $resource = $this->resource;

        return [
            /** @format uuid */
            'id' => $resource->getId(),
            ...
            /** @default draft | ProductStatus::DRAFT */
            'status' => $resource->status,
        ];
    }
}

@romalytvynenko
Copy link
Member Author

@jaimyborgman I thought to do this, but it seems like "default" is not applicable here. I feel like you need combination of @var and @example, like:

/** 
 * @var ProductStatus::DRAFT $status
 * @example draft
 */
'status' => $resource->status,

Do I understand this correctly, or @default in your opinion makes sense here?

@jaimyborgman
Copy link
Contributor

@default would suit this case better since i'd like to define and let know that there is a default value for "status" instead of giving an example :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add ability to set a default value in docs for params
2 participants