Skip to content

Conversation

@s-shiryaev
Copy link
Contributor

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

@oralunal
Copy link

oralunal commented May 21, 2025

I was doing this by using HTML helpers. This is a good feature.

   /**
     * Daily Insights (Deprecated)
     *
     * <small class="badge badge-grey">Deprecated</small>
     *
     * Retrieve daily insights. <i>Deprecation Note: Use GET method instead.</i>
     */

It would be great if we can give more information about the deprecation.

@shalvah
Copy link
Contributor

shalvah commented May 21, 2025

Wow, thank you for the thorough work.

@shalvah shalvah merged commit a6c2836 into knuckleswtf:v5 May 21, 2025
5 of 6 checks passed
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.

3 participants