update openapi

This commit is contained in:
2026-03-06 16:55:46 +08:00
parent d00af8372c
commit 4b10572794
3 changed files with 74 additions and 1 deletions
+15
View File
@@ -6,6 +6,7 @@ namespace App\Model;
use Hyperf\Database\Model\Relations\HasMany;
use Hyperf\DbConnection\Model\Model;
use OpenApi\Attributes as OA;
use Qbhy\HyperfAuth\Authenticatable;
/**
@@ -20,6 +21,20 @@ use Qbhy\HyperfAuth\Authenticatable;
* @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at
*/
#[OA\Schema(
schema: 'User',
type: 'object',
properties: [
new OA\Property(property: 'id', type: 'integer', example: 1),
new OA\Property(property: 'username', type: 'string', example: 'user_1234'),
new OA\Property(property: 'email', type: 'string', example: 'user@example.com'),
new OA\Property(property: 'status', type: 'integer', example: 1),
new OA\Property(property: 'ext', type: 'object', nullable: true, example: ['nickname' => 'user']),
new OA\Property(property: 'refresh_token_expires_at', type: 'string', format: 'date-time', nullable: true),
new OA\Property(property: 'created_at', type: 'string', format: 'date-time'),
new OA\Property(property: 'updated_at', type: 'string', format: 'date-time'),
]
)]
class User extends Model implements Authenticatable
{
/**
+57
View File
@@ -0,0 +1,57 @@
<?php
declare(strict_types=1);
namespace App;
use OpenApi\Attributes as OA;
#[OA\Info(
version: '1.0.0',
title: 'Datahub API',
description: 'Datahub API documentation'
)]
#[OA\Server(url: '/api/v1', description: 'API v1')]
#[OA\SecurityScheme(
securityScheme: 'bearerAuth',
type: 'http',
scheme: 'bearer',
bearerFormat: 'JWT'
)]
#[OA\SecurityScheme(
securityScheme: 'apiKeyAuth',
type: 'apiKey',
in: 'header',
name: 'X-API-Key'
)]
#[OA\Schema(
schema: 'ApiResponse',
type: 'object',
properties: [
new OA\Property(property: 'code', type: 'integer', example: 0),
new OA\Property(property: 'message', type: 'string', example: 'success'),
new OA\Property(property: 'data', type: 'object', nullable: true),
]
)]
#[OA\Schema(
schema: 'PaginatedData',
type: 'object',
properties: [
new OA\Property(property: 'items', type: 'array', items: new OA\Items()),
new OA\Property(property: 'total', type: 'integer', example: 0),
new OA\Property(property: 'page', type: 'integer', example: 1),
new OA\Property(property: 'per_page', type: 'integer', example: 15),
]
)]
#[OA\Schema(
schema: 'ErrorResponse',
type: 'object',
properties: [
new OA\Property(property: 'code', type: 'integer', example: 400),
new OA\Property(property: 'message', type: 'string', example: 'Bad request'),
new OA\Property(property: 'data', type: 'object', nullable: true),
]
)]
class OpenApiSpec
{
}