【发布时间】:2020-08-11 15:10:30
【问题描述】:
我正在尝试使用 mapstruct 在我的 kotlin 项目中转换复杂的 dto。
mapstruct:1.3.1.final 科特林:1.3.71 openapi 生成器:4.2.3
例如,我想从一个简单的对象转换为 TestObjectDTO
@Mapping(source = "mydescription", target = "description")
fun convertToDto(dto: TestObject): TestObjectDTO
我使用 OpenApi 来生成我的 DTO: yaml
components:
schemas:
TestObject:
title: TestObject
description: ''
type: object
properties:
mode:
type: string
description:
type: string
required:
- mode
- description
生成的 DTO
/**
*
* @param mode
* @param description
*/
data class TestObjectDTO (
@get:NotNull
@JsonProperty("mode") var mode: kotlin.String,
@get:NotNull
@JsonProperty("description") var description: kotlin.String
) {
}
A总是有错误,因为我的构造函数不允许无参数。
你知道如何解决这个问题吗?
【问题讨论】:
标签: kotlin mapstruct openapi-generator