I'm using NelmioApiDocBundle and Swagger to describe my API.
I want to describe my response object that contains another object:
For example - json str:
"Person": {
"firstname": "John",
"lastName": "Smith",
"car": {
"brand": "Tesla",
"price": "1000"
}
}
My PHP look like:
use Swagger\Annotations as SWG;
class Person {
/**
* @SWG\Property(
* title="firstName",
* type="string",
* required={"true"},
* description="Last Name"
* )
*/
protected $firstName;
/**
* @SWG\Property(
* title="lastName",
* type="string",
* required={"true"},
* description="First Name"
* )
*/
protected $lastName;
/**
* @SWG\Property(
* title="data",
* required={"true"},
* description="The fetched article",
* type="object", <- THAT IS THE PROBLEM
* @SWG\Property(property="Car", type=Car::class)
* )
*/
protected $car;
}
class Car {
/**
* @SWG\Property(
* title="brand",
* type="string",
* required={"true"},
* description="brand"
* )
*/
protected $brand;
/**
* @SWG\Property(
* title="price",
* type="string",
* required={"true"},
* description="price"
* )
*/
protected $price;
}
Configuration:
- php: "7.1.7"
- nelmio/api-doc-bundle: "3.0"
- symfony/symfony: "3.4.0",
- zircote/swagger-php": "2.0"