Nelmio API ドキュメントを使用して、FOSRestBundle と JMSSerializer を使用して REST API のドキュメントを生成しています。生成されたドキュメントによると、私の json オブジェクトは実際には配列です。オブジェクトがオブジェクトであるとドキュメントに記載するにはどうすればよいですか?
私はフードの下で知っています.phpではこれらのフィールドは実際にはキーと値の連想配列ですが、実際のjsonではそれらはオブジェクトであり、ドキュメントにそれを反映させたいと思います.
ここに私のコードエンティティがあります:
/**
*
* Class Facility
* @package Company\Bundle\RestApiBundle\Entity
*
* @Serializer\XmlRoot("facility")
*
* @Hateoas\Relation("self", href = "expr('/facility/' ~ object.getId())")
* @Hateoas\Relation(
* "units",
* embedded = "expr(object.getUnits())"
* )
* @Hateoas\Relation(
* "reviews",
* embedded = "expr(object.getReviews())"
* )
*
*/
class Facility
{
...
/**
* @var
* @Serializer\Type("array")
*/
protected $amenities;
...
}
コントローラ:
/**
* Resource describing the Facility object
*
* @ApiDoc(
* resource = true,
* resourceDescription="Operations on facilities.",
* description = "Facility object",
* output = "Company\Bundle\RestApiBundle\Entity\Facility",
* statusCodes = {
* 200 = "Returned when successful",
* 404 = "Returned when the resource is not found"
* }
* )
*
* @param $id
* @return \Symfony\Component\HttpFoundation\Response
*
* @Method("GET")
* @Route("/{id}", name = "api_facility_get")
*/
public function getFacilityAction($id)
{