我有一个应用程序,它接收一个服务作为对控制器的依赖,到目前为止一切都很好,但我想找到一种方法,而不是声明该服务的具体实现,以便能够从控制器“询问”该服务实现的接口,用于解耦该服务的具体实现。在 Nest js 中这是如何完成的?
当我在 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
Run Code Online (Sandbox Code Playgroud)
但是后来在 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 }
Run Code Online (Sandbox Code Playgroud)