Search code examples
symfony-formsfosrestbundleapi-doc

How to make Nelmio ApiDoc annotations pass request method to my forms?


I use dynamic forms (defined as services(!)) to enable/disable some fields for specific request (POST/PUT/PATCH). I want that to be displayed in ApiDoc automatically by passing options to form as described in documentation. But it doesn't work. I use this:

 * @ApiDoc(
 *  section = "...",
 *  description = "...",
 *  input = {
 *      "class" = "my_form_type_alias",
 *      "options" = {"method" = "PUT"},
 *      "name" = ""
 *  },
 *  statusCodes = {
 *      200 = "Updated (seems to be OK)",
 *      400 = "Bad request (see messages)",
 *      401 = "Unauthorized, you must login first",
 *      404 = "Not found",
 *  }
 * )

But via xdebug I can see that $options['method'] always is equal to 'POST', like when I don't specify "options" = {"method" = "PUT"}.


Solution

  • Currently this is fixed in Nelmio ApiDoc and works fine.