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

Union type annotation results in missing response docs #653

Open
romalytvynenko opened this issue Dec 6, 2024 · 0 comments
Open

Union type annotation results in missing response docs #653

romalytvynenko opened this issue Dec 6, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@romalytvynenko
Copy link
Member

          Were having the same issue described, but even without the array aspect... essentially anything with a multiple type response adds the first response, and ignores the rest.

This...

/**
 * Verify a user using their email address.
 * @unauthenticated
 *
 * @param Request $request
 * @param string $verificationId
 *
 * @return UserVerificationResource|JsonResponse
 */
public function email(Request $request, string $verificationId): UserVerificationResource|JsonResponse
{
    $userVerification = UserVerification::with(['user'])
                                        ->where('type', 'email')
                                        ->where('id', $verificationId)
                                        ->first();

    if (
        !$userVerification ||
        $userVerification->expires->isPast() ||
        $userVerification->attempts >= $this->authSettings->max_verify_attempts
    ) {
        return response()->json(
            [
                'meta' => [
                    'status' => '410',
                    'message' => 'Invalid User Verification code',
                ],
            ],
            410
        );
    }

    return new UserVerificationResource($userVerification);
}

Sadly results in only the UserVerificationResource showing in the docs or export, however if you swap the declarations for the return or typecast, then you get the JsonResponse listed, and no UserVerificationResource.

What is strange, is that if I remove the DocBlock AND the return Typehint, then the output is exactly as expected.

Originally posted by @J5Dev in #601 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant