## Schema請求類型
參數`@SWG\Schema()`是輸入和輸出數據類型的定義,這些類型可以是對象,也可以是字符串和數組
```
/**
* @SWG\Post(
* path="/index/index/user",
* tags={"用戶相關"},
* summary="個人資料",
* consumes={"application/json"},
* produces={"application/json"},
* @SWG\Parameter(
* in="body",
* required=true,
* name="body",
* description="description",
* @SWG\Schema(example={"username"="username","password"="password"})
* )
*/
```
| 參數 |含義 |
| --- | --- |
| ref | 允許此路徑項的外部定義 |
| example | 設置一個自定義的對象 |
| discriminator | 添加多個自定義 `ref` 的支持 |
> 我們來看看參數`@SWG\Schema()`使用
> 使用`example`參數來自定義
```
/**
* @SWG\Schema(example={"username"="username","password"="password"})
*/
```
> 使用`discriminator`參數來進行多個模型的支持
```
/**
*
* @SWG\Response(response="200",description="ok",@SWG\Schema(ref="#/definitions/Definition",discriminator="Definition")),
* @SWG\Response(response="404",description="ok",@SWG\Schema(ref="#/definitions/index",discriminator="index"))
*/
```
> 使用`@SWG\Property()`參數來設置:
>
| 參數 | 含義 |
| --- | --- |
| property | 名稱 |
| type | 類型 可設置值為 string、 number、 integer、boolean、array、object" |
| example | 設置默認值 |
| readOnly | 屬性聲明 |
```
/** @SWG\Schema(
* @SWG\Property(
* property="username",
* type="string",
* example="username"
* ),
* @SWG\Property(
* property="password",
* type="string",
* example="password"
* ),
* @SWG\Property(
* property="sex",
* type="integer",
* example=0
* )
* )
* /
```
> 參數`readOnly`如果設置為true,這意味著它只作為響應的一部分發送,不能作為請求的一部分發送,默認false
>