Skip to content

Commit 837347d

Browse files
committed
编写 response 和 security
1 parent d605928 commit 837347d

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed

src/swagger3.0/response.php

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
/**
4+
*
5+
* 第一部分:
6+
* @note: 返回:
7+
* 1. 非200 的返回
8+
* 2. 200 的返回内容, 其写法与 request body 一样
9+
*
10+
* @OA\Get(
11+
* path="/path",
12+
* tags={"pet"},
13+
* summary="simple summary of this api request",
14+
* description=" A detailed description about this api how to be using",
15+
* operationId="addPet",
16+
*
17+
* @OA\Parameter(name="username", in="query", @OA\Schema(type="string"), required=true, example="melody", description="姓名"),
18+
* @OA\Response(response=400, description="Invalid status value"),
19+
* @OA\Response(
20+
* response=200,
21+
* description="successful operation",
22+
* @OA\JsonContent(
23+
* allOf={
24+
* @OA\Schema(ref="#/components/schemas/UserModel"),
25+
* @OA\Schema(@OA\Property(property="classModel", ref="#/components/schemas/ClassModel")),
26+
* @OA\Schema(@OA\Property(property="teacherModel", type="array", @OA\Items(ref="#/components/schemas/TeacherModel"))),
27+
* @OA\Schema(@OA\Property(property="book", type="array", @OA\Items(type="integer",example=1))),
28+
* },
29+
* ),
30+
* )
31+
* )
32+
*
33+
*
34+
*
35+
*
36+
*/
37+

src/swagger3.0/security.php

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
/**
4+
*
5+
* 第一部分:
6+
* @note: 返回:
7+
* 1. 定义个授权方式 ( 这里默认 给出的是 api key , 具体的其他授权方式比如 http、oauth2 自行查找)
8+
* 2. 对某一个请求进行授权
9+
*
10+
* @OA\SecurityScheme(
11+
* type="apiKey",
12+
* in="header",
13+
* securityScheme="api_key",
14+
* name="Authorization",
15+
* description="这是一个认证,比如jwt认证",
16+
* )
17+
*
18+
* @OA\Get(
19+
* path="/path",
20+
* tags={"pet"},
21+
* summary="simple summary of this api request",
22+
* description=" A detailed description about this api how to be using",
23+
* operationId="addPet",
24+
*
25+
* @OA\Parameter(name="username", in="query", @OA\Schema(type="string"), required=true, example="melody", description="姓名"),
26+
* @OA\Response(response=400, description="Invalid status value"),
27+
* security={{"api_key": {}}}
28+
* )
29+
*
30+
*
31+
*
32+
*/
33+

0 commit comments

Comments
 (0)