-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] "allOf" including a $ref and a 'description' generates unwanted new java-models #16332
Comments
please try 7.0.0-beta, which should no longer created those allOf sub-schemas as models separately |
Hi @wing328, I tried 7.0.0-beta now, but it seems that it's still generating these files "CreateRequestDevicePorts". |
can you try the latest master instead? snapshot version can be found in the project's readme |
I used now 7.0.0-SNAPSHOT and even there CreateRequestDevicePorts is created. So it seems that this hasn't changed anything. It would be good at the end (even when it's created now) that it would extend from PortsSpecs. |
I did a test with the latest master and I got the following in
|
@wing328 I found now the issue, why it's working on your side but not on my side: CreateRequest:
type: object
properties:
devicePorts:
allOf:
- description: Here is some description which will cause a new ModelClass
- $ref: "#/components/schemas/PortsSpec"
appPorts:
allOf:
- $ref: "#/components/schemas/PortsSpec" It's because I have locally a description besides of the $ref. The classpublic class CreateRequest {
private CreateRequestDevicePorts devicePorts;
private PortsSpec appPorts;
public CreateRequest() {
}
public CreateRequest devicePorts(CreateRequestDevicePorts devicePorts) {
this.devicePorts = devicePorts;
return this;
}
@Schema(
name = "devicePorts",
requiredMode = RequiredMode.NOT_REQUIRED
)
@JsonProperty("devicePorts")
public @Valid CreateRequestDevicePorts getDevicePorts() {
return this.devicePorts;
}
public void setDevicePorts(CreateRequestDevicePorts devicePorts) {
this.devicePorts = devicePorts;
}
public CreateRequest appPorts(PortsSpec appPorts) {
this.appPorts = appPorts;
return this;
} |
I think you should do the following instead:
|
Yes that's working fine. |
Right |
Thanks for your help, @wing328 ! 🚀 |
👍 (optional) You may consider supporting this project financially via https://opencollective.com/openapi_generator. |
Hi again @wing328, it seems that this is only working with the 7.0.0-SNAPSHOT. It's not working with 7.0.0-beta. 2 questions now1.) When will be the next release of 7.0.0? Thanks in advance. |
v7.0.0 will be released this week or next |
Description
When I am using the generator for generating java classes, I face the problem that "allOf" creates unneccessarry classes.
I am not allowed to edit the schemas in this yaml.
So I need a way of configuration for the generator.
The Class "DevicePorts" should have a PortSpecs inside.
Instead now it will create a new class called "CreateRequestDevicePorts", which is not needed and unwanted here.
openapi-generator version
6.6.0
OpenAPI declaration file content or url
Generation Details
I am using the maven plugin in the pom.xml.
Steps to reproduce
Related issues/PRs
Suggest a fix
The text was updated successfully, but these errors were encountered: