我在我的java项目中使用maven插件:
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>4.3.1</version>在openapi配置文件(yml)中,我描述了一个post请求和响应模型:
post:
tags:
- instance
summary: createInstances
description: Creates instances for given ids
operationId: createInstances
requestBody:
description: Params for creation
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CreateInstancesRequest'
responses:
200:
description: Ok
content:
application/json:
schema:
$ref: '#/components/schemas/CreateInstancesResponse'
206:
description: Partial Content
content:
application/json:
schema:
$ref: '#/components/schemas/PartialCreateInstancesResponse'
CreateInstancesResponse:
type: object
PartialCreateInstancesResponseResponse:
allOf:
- $ref: '#/components/schemas/CreateInstancesResponse'
required:
- failedIds
properties:
failedIds:
$ref: '#/components/schemas/Ids'我希望它将生成一个不带字段的基本java类(CreateInstancesResponse)和一个继承类(PartialCreateInstancesResponse)。奇怪的是,生成了PartialCreateInstancesResponse类。但是基类不会生成。你能帮我解决这个问题吗?
发布于 2021-03-22 18:24:14
看起来它还不受支持。你可以参考一个开放的问题here。
一个变通的办法是,在超类中添加虚拟属性。
"Pet": {
"title": "AbstractPet",
"type": "object",
"properties": {
"dummyProperty": {
"type": "string",
"description": "Workaround - OpenAPI generator does not consider definitions without properties"
}
},
"description": "model containing all the details of a pet",
"discriminator": {
"propertyName": "petTypeName"
}
}https://stackoverflow.com/questions/65732773
复制相似问题