Skip to content

feat: Routes can be marked as deprecated #994

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

Open
wants to merge 1 commit into
base: v5
Choose a base branch
from

Conversation

s-shiryaev
Copy link

In OpenAPI 3.0 it is possible to specify paths as deprecated. It is possible to implement this using custom spec generators, themes.

But I think it would be useful to implement native support.

Changes

  1. Updated Metadata DTO
  2. Updated Metadata strategies for DocBlock/Attributes
  3. Updated base OpenApiSpecGenerator
  4. Updated PostmanCollectionGenerator (Since Postman doesn't have a way to mark methods as deprecated, I decided to add the [DEPRECATED] suffix to method names.)
  5. Updated default and elements themes
  6. Updated tests

Usage

Just add a annotation @deprecated in method/class/route DocBlock:

/**
 * Update Role
 *
 * @deprecated
 */
public function update(string $id, CreateUpdateRoleRequest $request): Role
{
    $data = $request->validated();
    $model = $this->roleService->getModel($id, ['permissions']);

    return $this->roleService->updateRole($model, $data);
}

You can also use attributes:

#[Deprecated]
public function create(CreateUpdateRoleRequest $request): Role
{
    $data = $request->validated();

    return $this->roleService->createRole($data);
}

Examples

Default theme
Elements theme
External elements, scalar, rapidoc

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.

1 participant