{"action":"closed","issue":{"url":"https://api.github.com/repos/OpenAPITools/openapi-generator/issues/1358","repository_url":"https://api.github.com/repos/OpenAPITools/openapi-generator","labels_url":"https://api.github.com/repos/OpenAPITools/openapi-generator/issues/1358/labels{/name}","comments_url":"https://api.github.com/repos/OpenAPITools/openapi-generator/issues/1358/comments","events_url":"https://api.github.com/repos/OpenAPITools/openapi-generator/issues/1358/events","html_url":"https://github.com/OpenAPITools/openapi-generator/issues/1358","id":376144480,"node_id":"MDU6SXNzdWUzNzYxNDQ0ODA=","number":1358,"title":"[Java] \"allOf\" no longer supports inheritance AND composition","user":{"login":"clintfoster","id":1449737,"node_id":"MDQ6VXNlcjE0NDk3Mzc=","avatar_url":"https://avatars2.githubusercontent.com/u/1449737?v=4","gravatar_id":"","url":"https://api.github.com/users/clintfoster","html_url":"https://github.com/clintfoster","followers_url":"https://api.github.com/users/clintfoster/followers","following_url":"https://api.github.com/users/clintfoster/following{/other_user}","gists_url":"https://api.github.com/users/clintfoster/gists{/gist_id}","starred_url":"https://api.github.com/users/clintfoster/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clintfoster/subscriptions","organizations_url":"https://api.github.com/users/clintfoster/orgs","repos_url":"https://api.github.com/users/clintfoster/repos","events_url":"https://api.github.com/users/clintfoster/events{/privacy}","received_events_url":"https://api.github.com/users/clintfoster/received_events","type":"User","site_admin":false},"labels":[{"id":931403286,"node_id":"MDU6TGFiZWw5MzE0MDMyODY=","url":"https://api.github.com/repos/OpenAPITools/openapi-generator/labels/Feature:%20Composition%20/%20Inheritance","name":"Feature: Composition / Inheritance","color":"eeccff","default":false},{"id":931403399,"node_id":"MDU6TGFiZWw5MzE0MDMzOTk=","url":"https://api.github.com/repos/OpenAPITools/openapi-generator/labels/Issue:%20Bug","name":"Issue: Bug","color":"e11d21","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-10-31T20:21:24Z","updated_at":"2018-12-10T16:20:25Z","closed_at":"2018-12-10T16:20:25Z","author_association":"NONE","body":"#### Description\r\n\r\nI just attempted to migrate from swagger-codegen to openapi-generator. It was mostly successful, except the behavior of `allOf` has changed. Previously the generated Java class would inherit from the first `$ref` and compose from the rest. With the new generator the Java class still extends the first `$ref`, as expected. But all the other `$refs` are ignored. (Their fields are no longer composed directly into the Java class.)\r\n\r\n#### openapi-generator version\r\n\r\nI am using the new Gradle plugin: `openapi-generator-gradle-plugin:3.3.2` (much appreciated).\r\n\r\nThis previously worked with `swagger-codegen-cli:3.0.2`. In case you're wondering, since there is no official Gradle plugin I was using this `org.hidetake.swagger.generator`, which wraps the CLI as a Gradle plugin.\r\n\r\n#### OpenAPI declaration file\r\nSee comments next to each `$ref`:\r\n```yaml\r\n    Foo:\r\n      allOf:\r\n      - $ref: \"#/components/schemas/FooBase\"  # generated Java extended this class (still works)\r\n      - $ref: \"#/components/schemas/FooComposed1\"  # all fields inlined (no longer works)\r\n      - $ref: \"#/components/schemas/FooComposed2\"  # all fields inlined (no longer works)\r\n      - properties:  # other props also inlined (still works)\r\n          fooCount:\r\n            type: integer\r\n```\r\nNote: `FooBase` has a discriminator. The composed models do not:\r\n\r\n```yaml\r\n    FooBase:\r\n      discriminator:\r\n        propertyName: fooType\r\n      required:\r\n      - fooType\r\n      properties:\r\n        fooType:\r\n          type: string\r\n```\r\n\r\n##### Command line used for generation\r\n###### build.gradle excerpt\r\n```groovy\r\nopenApiGenerate {\r\n    generatorName = 'java'\r\n    configFile = 'open-api-cfg.json'\r\n}\r\n```\r\n\r\n###### config file\r\n```json\r\n{\r\n  \"modelPackage\"     : \"com.foo\",\r\n  \"serializableModel\": \"true\",\r\n  \"dateLibrary\"      : \"java8\",\r\n  \"java8\"            : \"true\"\r\n}\r\n```\r\n##### Suggest a fix/enhancement\r\n\r\nThe Java generator should support single inheritance, plus an arbitrary number of composed models, as it did before. This allows a great deal of flexibility. For example, I have models representing \"views\" returned to clients consisting of a database record that extends a base model, plus fields composed from other models. The client need not know which fields came directly from the db record, and which are calculated on-the-fly and returned from other models."}}
{"actor":{"display_login":"wing328"}}