首页 > 解决方案 > 如何在 api-platform 中为 Dto 模型提供自定义名称?

问题描述

当我在 api 文档的模型中使用 Dto 时,Dto 的名称记录如下,Customer: 01d691680190c1b19dfee75af0f2e292,可以将此名称自定义为 Customer: Input 或其他任何内容。

这是我的资源的配置:

App\Entity\Customer\Customer:
collectionOperations:
    register:
        method: POST
        path: /register
        controller: App\Controller\ShopApi\Customer\RegisterCustomerAction
        input:
            class: App\Dto\RegisterCustomerRequest
            name: RegisterCustomerRequest
itemOperations:
    get:
        normalization_context:
            jsonld_embed_context: true
            groups: ['customer:read']
            swagger_definition_name: CustomerResponse

但后来在 api doc 中我得到了一个模型:

Customer:01d691680190c1b19dfee75af0f2e292 {
email*  string
plainPassword*  string
firstName*  string
lastName*   string
gender* string
identificationNumber*   string
typeIdentificationNumber*   string
subscribedToNewsletter  boolean
confirmTermsConditions  boolean
addressAlias    string
address*    string
countryCode*    string
provinceCode    string
provinceName    string
city*   string
postcode*   string
phoneNumber*    string  }

标签: dtoapi-platform.com

解决方案


推荐阅读