In the previous version we used something like this:
* @ApiDoc(
* description="Create new address.",
* section="Address area",
* resource=true,
* input="PathToType\AddressType",
But with new version(with swagger) I cant find a solution how to simply set input type to AddressType
currently, I have to define every single field like this:
* @SWG\Schema(
* type="object",
* @SWG\Property(property="firstName", type="string"),
* @SWG\Property(property="lastName", type="string"),
* @SWG\Property(property="email", type="string"),
* @SWG\Property(property="address", type="string"),
any solution?
* @SWG\Parameter(
* name="form",
* in="body",
* description="Bla Bla Bla",
* @Model(type=PathToType\AddressType::class)
* ),
hmm need add this to converter and in doc
Closing as @ivan1986 gave you the answer :)
PRs welcome to improve the docs.
This solution doesn't allow setting an example for the response and forces the post to be sent as a json object in the swagger ui instead of creating a form for the fields. It doesn't look very nice. The older version of this bundle rendered a form when passing a form type as an input. I'm trying to get similar results as i did in the previous version but i can't. Any ideas on this?
@noquepoaqui Doesn't specifying consumes="application/x-www-form-urlencoded" solve your issue?
I've tried your solution but couldn't make it work. My api only manages json format, so i guess i won't be able to have the forms available.
Thanks for your response anyway!
Hi, I got error as bellow after I tried to define a documentation option in form type according to the official guide.
The option "documentation" does not exist. Defined options are: "action", "allow_extra_fields", "attr", "auto_initialize", "block_name", "by_reference", "compound", "constraints", "csrf_field_name", "csrf_message", "csrf_protection", "csrf_token_id", "csrf_token_manager", "data", "data_class", "disabled", "empty_data", "error_bubbling", "error_mapping", "extra_fields_message", "inherit_data", "invalid_message", "invalid_message_parameters", "label", "label_attr", "label_format", "mapped", "method", "post_max_size_message", "property_path", "required", "translation_domain", "trim", "upload_max_size_message", "validation_groups".
This is my controller annotation configuration. I used in combination with FOSRestBundle routing.
/**
* Create a new user.
*
* @SWG\Parameter(
* name="form",
* in="body",
* description="User creation parameters",
* @Model(type=UserType::class)
* )
* @SWG\Response(
* response=200,
* description="Create a new user",
* @SWG\Schema(
* type="array",
* @Model(type=User::class, groups={"full"})
* )
* )
* @SWG\Tag(name="/api/v1/user")
*
* @Rest\Post("/user")
*
* @param Request $request
*
* @return User|FormInterface
*/
@tuancode in fact this feature is not released yet, you need to install dev-master to be able to use it.
@GuilhemN Is there support for sending input as formData? I'm expecting something like this to work, but seems like it's not rendering correctly:
* @SWG\Parameter(
* name="listing_enquiry",
* in="formData",
* type="array",
* @Model(type=ListingEnquiryType::class)
* ),
Hello,
Is there any news about this please ? With the version 2 of this bundle we can render a form when passing a form type as an input, it's not possible with the new version :(
+1
+1
+1
Is it possible to use form types to create formData?
I get this
Warning: count(): Parameter must be an array or an object that implements Countable
after trying
* @SWG\Parameter(
* name="form",
* in="body",
* description="Bla Bla Bla",
* @Model(type=PathToType\AddressType::class)
* ),
Most helpful comment
@GuilhemN Is there support for sending input as formData? I'm expecting something like this to work, but seems like it's not rendering correctly: