Parameter Annotations
[OpenApi] Add Property Description and Example Value
Add Property Description and Example Value
use Astral\Serialize\Serialize;
use Astral\Serialize\OpenApi\Annotations\OpenApi;
class UserAddRequest extends Serialize {
#[OpenApi(description: 'this is name',example: 'Job')]
public string $name;
#[OpenApi(description: 'this is id',example: '1')]
public int $id;
}Hide Input Property
Added InputIgnore annotation class. When generating OpenAPI docs for a Request class, these properties will be automatically ignored.
use Astral\Serialize\Serialize;
use Astral\Serialize\OpenApi\Annotations\OpenApi;
use Astral\Serialize\Annotations\DataCollection\InputIgnore;
class UserAddRequest extends Serialize {
#[InputIgnore]
public object $admin;
#[OpenApi(description: 'this is name',example: 'Job')]
public string $name;
#[OpenApi(description: 'this is id',example: '1')]
public int $id;
}Hide Output Property
Added OutputIgnore annotation class. When generating OpenAPI docs for a Response class, these properties will be automatically ignored.
tips: For detailed usage of OutputIgnore and InputIgnore, see Property Ignore
[Headers] Add/Remove Request Headers
Add
user-tokenwith default valuetrueAdd
company-idwith default value''Remove
tokenrequest header
[Tag] Add Tag Description
Each Controller must add a Tag annotation for OpenAPI documentation to be generated correctly.
valueTag namedescriptionTag descriptionsortSort order. The higher the value, the earlier the tag appears.
[Summary] API Method Description
valueMethod namedescriptionMethod description
[Route] Route
A Route annotation class must exist for OpenAPI documentation to be generated correctly. The route address must be unique; duplicate addresses will cause inconsistent display.
routeRequest pathmethodRequest method, default is POST
[RequestBody] API Method Description
Implicitly Obtain RequestBody
When the parameter object of the current API inherits from the Serialize object, it will automatically be used as the RequestBody.
RequestBody Grouped Documentation Display
When a group is specified in RequestBody, OpenAPI documentation will show the properties under that group.
Tips: For more details on Groups usage, please refer to Attribute Grouping
[Response] API Method Description
Implicitly Obtain Response
When an object returns another object that inherits from Serialize, it will automatically be used as the Response.
Response Grouped Documentation Display
If a Response specifies a group, the OpenAPI documentation will display only the properties in that group.
Tips: For more details on Groups usage, please refer to Attribute Grouping
最后更新于