我想在ref(文章)中添加一个“ custom”属性(例如,在json中,它是“ countries”数组属性):
{
"message" : "Get one article",
"status" : 200,
"data": {
"id": 1,
"title": "Title"
"countries" : [
{
"id": 1,
"name": "Country name"
}
]
}
}
控制器中的注释
当前,在批注中,我拥有此属性(不具有country属性):
* @OA\Response(
* response="200",
* description="Get one article success",
* @OA\MediaType(
* mediaType="application/json",
* @OA\Schema(
* allOf={
*
@OA\Schema(ref="#/components/schemas/StandardResponse")
* },
* @OA\Property(
* property="data",
* ref="#/components/schemas/Article"
* )
* )
* )
* ),
文章架构
/**
* @OA\Schema(
* schema="Article",
* type="object",
* title="Article",
* @OA\Property(property="id", type="integer", description="Article id"),
* @OA\Property(property="title", type="string", description="Article title"),
* )
*/
国家架构
/**
* @OA\Schema(
* schema="Country",
* type="object",
* title="Country",
* @OA\Property(property="id", type="integer", description="Country id"),
* @OA\Property(property="name", type="string", description="Country name"),
* )
*/
我想在 property =“ data”
中添加“ 国家/地区”属性我尝试了一下(直接在数据属性中添加了Countrys属性),但没有成功...
* @OA\Response(
* response="200",
* description="Get one article success",
* @OA\MediaType(
* mediaType="application/json",
* @OA\Schema(
* allOf={
*
@OA\Schema(ref="#/components/schemas/StandardResponse")
* },
* @OA\Property(
* property="data",
* ref="#/components/schemas/Article",
* @OA\Property(
* property="countries",
* type="array",
* @OA\Items(ref="#/components/schemas/Countries")
* )
* )
* )
* )
* ),