Swagger 导入类型don'的所需值;t显示在“的列表中”;“示例值”;
我想知道我省略了什么,这样Swagger就不会在示例值列表中公开类型为Swagger 导入类型don'的所需值;t显示在“的列表中”;“示例值”;,swagger,symfony4,api-platform.com,Swagger,Symfony4,Api Platform.com,我想知道我省略了什么,这样Swagger就不会在示例值列表中公开类型为Misd\PhoneNumberBundle\doctor\DBAL\Types\PhoneNumberType的公共对象值了?尽管有另一个公共对象值,发布对象时的示例值如下所示: 我可以手动添加该字段,一切正常(值已过账),但这并不理想,因为文档中没有列出所需的值 /** * @AssertPhoneNumber(defaultRegion="US", message="Please specify a vali
Misd\PhoneNumberBundle\doctor\DBAL\Types\PhoneNumberType
的公共对象值了?尽管有另一个公共对象值,发布对象时的示例值如下所示:
我可以手动添加该字段,一切正常(值已过账),但这并不理想,因为文档中没有列出所需的值
/**
* @AssertPhoneNumber(defaultRegion="US", message="Please specify a valid mobile phone number", type="mobile")
* @Assert\NotBlank
* @ORM\Column(name="phone_number", type="phone_number", unique=true)
*/
public $phoneNumber;
我错过了什么?期待得到有关这方面的提示,提前谢谢。将ApiProperty指定为注释解决了我的问题。只需
使用apiplate\Core\Annotation\ApiProperty
并按如下方式注释phone number属性:
/**
* @ApiProperty(
* attributes={
* "swagger_context"={
* "type"="string"
* }
* }
* )
* @AssertPhoneNumber(defaultRegion="US", message="Please specify a valid mobile phone number", type="mobile")
* @Assert\NotBlank
* @ORM\Column(name="phone_number", type="phone_number", unique=true)
*/
public $phoneNumber;
/**
* @ApiProperty(
* attributes={
* "swagger_context"={
* "type"="string"
* }
* }
* )
* @AssertPhoneNumber(defaultRegion="US", message="Please specify a valid mobile phone number", type="mobile")
* @Assert\NotBlank
* @ORM\Column(name="phone_number", type="phone_number", unique=true)
*/
public $phoneNumber;