Home > OS >  Symfony RequestBody swagger annotations not showing schema
Symfony RequestBody swagger annotations not showing schema

Time:09-23

I'm using nelmio/api-doc-bundle v4.9 in Symfony for documentation. Here's the annotation for an endpoint:

 * @OA\RequestBody(
 *     required=true,
 *     @OA\JsonContent(
 *     example={
 *      "file": "file",
 *      "documentCategoryCode": "O"
 *     },
 *     @OA\Schema(
 *      type="object",
 *      @OA\Property(
 *          property="file",
 *          required=true,
 *          type="file",
 *          description="File to be uploaded",
 *          example="file"
 *      ),
 *      @OA\Property(
 *          property="documentCategoryCode",
 *          required=true,
 *          type="string",
 *          description="Document category")
 *      ),
 *     )
 *  )
 * )

It shows the example fine:

enter image description here

However the "Schema" part is an empty object, like the properties are not recognized

enter image description here

Any ideas what am I missing here?

CodePudding user response:

 * @OA\RequestBody(
 *     required=true,
 *     @OA\JsonContent(
 *     example={
 *      "file": "file",
 *      "documentCategoryCode": "O"
 *     },
 *     required={"file", "documentCategoryCode"},
 *      @OA\Property(
 *          property="file",
 *          type="file",
 *          description="File to be uploaded",
 *          example="file"
 *      ),
 *      @OA\Property(
 *          property="documentCategoryCode",
 *          type="string",
 *          description="Document category")
 *      )
 *  )
 * )

Thanks to @Helen for the suggestion, this was the annotation that worked in the end.

  • Related