Model not generated with the right type (allOf)
Created by: JFCote
Description
A member of a model is not using the model type requested by the spec. Please check the example for a better explanation
openapi-generator version
Master (3.1.1-SNAPSHOT)
OpenAPI declaration file content or url
This is a self contained file that reproduce the issue
swagger: "2.0"
info:
description: "dfsdfsdfs"
version: "1.0.0"
title: "Swagger Petstore"
termsOfService: "http://swagger.io/terms/"
contact:
email: "apiteam@swagger.io"
license:
name: "Apache 2.0"
url: "http://www.apache.org/licenses/LICENSE-2.0.html"
host: "petstore.swagger.io"
basePath: "/v2"
schemes:
- "https"
- "http"
paths:
/lifecycles:
put:
tags:
- Device
summary: xxxxxxx
operationId: editDeviceLifecycles
parameters:
- in: body
name: device-lifecycle-update-info
required: true
schema:
$ref: "#/definitions/DeviceLifecycleCore"
responses:
200:
description: OK
schema:
$ref: "#/definitions/DeviceLifecycleCore"
definitions:
DeviceLifecycleCore:
type: object
description: "DeviceLifecycleCore"
properties:
aaa:
type: string
description: "aaa"
bbb:
type: string
description: "bbb"
ccc:
type: string
description: "ccc"
returnSoftwareStatus:
$ref: "#/definitions/DeviceLifecycleStatus"
DeviceLifecycleStatus:
type: object
description: "DeviceLifecycleStatus"
allOf:
- $ref: "#/definitions/DeviceLifecycleStatusCore"
- type: object
required:
- id
properties:
id:
type: integer
format: int64
description: "Id associated with the status"
example: 123
DeviceLifecycleStatusCore:
type: object
description: "DeviceLifecycleStatusCore"
properties:
name:
type: string
description: "Name"
details:
type: string
description: "Any additional information needed for the status"
example: "Something is wrong"
As you can see returnSoftwareStatus
is supposed to be of type DeviceLifecycleStatus
. If you look in the generated code, you will see that it is of type DeviceLifecycleStatusCore
instead:
public DeviceLifecycleCore returnSoftwareStatus(DeviceLifecycleStatusCore returnSoftwareStatus) {
this.returnSoftwareStatus = returnSoftwareStatus;
return this;
}
/**
* DeviceLifecycleStatus
* @return returnSoftwareStatus
**/
@Valid
public DeviceLifecycleStatusCore getReturnSoftwareStatus() {
return returnSoftwareStatus;
}
public void setReturnSoftwareStatus(DeviceLifecycleStatusCore returnSoftwareStatus) {
this.returnSoftwareStatus = returnSoftwareStatus;
}
Command line used for generation
java -jar openapi-generator-cli.jar generate -i ./swagger.yaml --generator-name java-play-framework -o generatedServer -DhideGenerationTimestamp=true,booleanGetterPrefix=is
Steps to reproduce
Just run the command above
Related issues/PRs
None
Suggest a fix/enhancement
?