You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In our contract, we use $ref to point to shared models. If we use openapi:3.1.0 then it gives duplicate models in the java code we generate. For example, we have a Client.java and a Client1.java.
We have found that if we use $ref along with allOf: that we do not get duplicate models.
Is this a bug and is our use of allOf a correct solution?
openapi-generator version
We are using the npm wrapper "@openapitools/openapi-generator-cli": "^2.15.3".
I think this defaults to the latest version.
OpenAPI declaration file content or url
This results in Office.java and Office1.java
`type: object
title: IdentifiedClientOrRelation
properties:
id:
type: string
number:
type: string
name:
type: string
office:
$ref: '../../../openapi.yml#/components/schemas/Office'
required:
I was able to fix the issue by removing a cycle in my schemas: one of the nested schema was referring to another type outside. And the outside type was referring to another schema inside. I moved the outside schema to inside directory which fixed the issue for me.
Description
In our contract, we use $ref to point to shared models. If we use openapi:3.1.0 then it gives duplicate models in the java code we generate. For example, we have a Client.java and a Client1.java.
We have found that if we use $ref along with allOf: that we do not get duplicate models.
Is this a bug and is our use of allOf a correct solution?
openapi-generator version
We are using the npm wrapper "@openapitools/openapi-generator-cli": "^2.15.3".
I think this defaults to the latest version.
OpenAPI declaration file content or url
This results in Office.java and Office1.java
`type: object
title: IdentifiedClientOrRelation
properties:
id:
type: string
number:
type: string
name:
type: string
office:
$ref: '../../../openapi.yml#/components/schemas/Office'
required:
`
But this results in only Office.java
`type: object
title: IdentifiedClientOrRelation
properties:
id:
type: string
number:
type: string
name:
type: string
office:
allOf:
- $ref: '../../../openapi.yml#/components/schemas/Office'
required:
`
Generation Details
package.json
{ "name": "e2e", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "generate:server": "openapi-generator-cli generate -c generated-server-code/config.json" }, "author": "", "license": "ISC", "dependencies": { "@openapitools/openapi-generator-cli": "^2.15.3", "mustache": "^4.2.0" }, "devDependencies": { "rimraf": "^6.0.1" } }
Steps to reproduce
npm run generate:server
Related issues/PRs
Suggest a fix
The text was updated successfully, but these errors were encountered: