Skip to content

Conversation

@s-shiryaev
Copy link
Contributor

@s-shiryaev s-shiryaev commented Aug 27, 2025

It is possible to implement this using custom strategies, spec generators, themes, attributes...

However, looking at #971, I believe many developers will find built-in support useful.

Changes

  1. Updated the Parameter DTO
  2. Updated the GenericParam Attribute
  3. Updated strategies for BodyParam/QueryParam
  4. Updated the base OpenApiSpecGenerator
  5. Updated the default and elements themes
  6. Updated tests

Usage

The @bodyParam and @queryParam annotations now have a new optional section. The formats now look like this:

//@bodyParam <name> <type> <"required" (optional)> <"deprecated" (optional)> <description>
//@queryParam <name> <type (optional)> <"required" (optional)> <"deprecated" (optional)> <description>

Example with annotation:

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

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

Example with attributes:

#[QueryParam(name: "sort", type: "string", required: true, deprecated: true)]
public function list(GetRolesRequest $request): Role
{
    $data = $request->validated();

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

Examples

Default theme
Elements theme
External themes: Elements, Scalar, RapiDoc

This PR fixes #971

@shalvah
Copy link
Contributor

shalvah commented Oct 20, 2025

Thanks! 👏

@shalvah shalvah merged commit 0b578d1 into knuckleswtf:v5 Oct 20, 2025
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.

Deprecating BodyParam or QueryParam

2 participants