Search code examples
phpswaggersymfony4nelmioapidocbundle

Writing Swagger documentation for requests in body without model referencing


How to write Swagger documentation for requests in body without model referencing?

e.g:

@SWG\Parameter( 
    name="date",
    in="body",
    content="application/json",
    type="object",
    {custom written JSON}
)

I have tried to do it in description, but that is not going to work because it have to be shown in Edit Value field.

Similar for requests, too.

I have searched google, but found no solution.
Is something like that possible?


Solution

  • You can do it but in not very obvious way. This works for me:

    /**
     * @SWG\Get(
     *  path="/route",
     *  tags={"tag"},
     *  @SWG\Response(
     *      response="200",
     *      description="Simple list of name and value pairs ",
     *      @SWG\Schema(
     *          type="array",
     *          @SWG\Items(
     *                  @SWG\Property(
     *                      property="id",
     *                      type="string"
     *                  ),
     *                  @SWG\Property(
     *                      property="name",
     *                      type="string"
     *                  )
     *          )
     *      )
     *  )
     * )
     */