{"action":"created","issue":{"url":"https://api.github.com/repos/OpenAPITools/openapi-generator/issues/3771","repository_url":"https://api.github.com/repos/OpenAPITools/openapi-generator","labels_url":"https://api.github.com/repos/OpenAPITools/openapi-generator/issues/3771/labels{/name}","comments_url":"https://api.github.com/repos/OpenAPITools/openapi-generator/issues/3771/comments","events_url":"https://api.github.com/repos/OpenAPITools/openapi-generator/issues/3771/events","html_url":"https://github.com/OpenAPITools/openapi-generator/pull/3771","id":486039621,"node_id":"MDExOlB1bGxSZXF1ZXN0MzExNTcyMzU5","number":3771,"title":"[core] [regression] set parentName when a single possible parent exists","user":{"login":"mnahkies","id":2555533,"node_id":"MDQ6VXNlcjI1NTU1MzM=","avatar_url":"https://avatars0.githubusercontent.com/u/2555533?v=4","gravatar_id":"","url":"https://api.github.com/users/mnahkies","html_url":"https://github.com/mnahkies","followers_url":"https://api.github.com/users/mnahkies/followers","following_url":"https://api.github.com/users/mnahkies/following{/other_user}","gists_url":"https://api.github.com/users/mnahkies/gists{/gist_id}","starred_url":"https://api.github.com/users/mnahkies/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mnahkies/subscriptions","organizations_url":"https://api.github.com/users/mnahkies/orgs","repos_url":"https://api.github.com/users/mnahkies/repos","events_url":"https://api.github.com/users/mnahkies/events{/privacy}","received_events_url":"https://api.github.com/users/mnahkies/received_events","type":"User","site_admin":false},"labels":[{"id":931403198,"node_id":"MDU6TGFiZWw5MzE0MDMxOTg=","url":"https://api.github.com/repos/OpenAPITools/openapi-generator/labels/Enhancement:%20General","name":"Enhancement: General","color":"e5ffe5","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/OpenAPITools/openapi-generator/milestones/26","html_url":"https://github.com/OpenAPITools/openapi-generator/milestone/26","labels_url":"https://api.github.com/repos/OpenAPITools/openapi-generator/milestones/26/labels","id":4602072,"node_id":"MDk6TWlsZXN0b25lNDYwMjA3Mg==","number":26,"title":"4.1.2","description":"","creator":{"login":"wing328","id":934260,"node_id":"MDQ6VXNlcjkzNDI2MA==","avatar_url":"https://avatars2.githubusercontent.com/u/934260?v=4","gravatar_id":"","url":"https://api.github.com/users/wing328","html_url":"https://github.com/wing328","followers_url":"https://api.github.com/users/wing328/followers","following_url":"https://api.github.com/users/wing328/following{/other_user}","gists_url":"https://api.github.com/users/wing328/gists{/gist_id}","starred_url":"https://api.github.com/users/wing328/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wing328/subscriptions","organizations_url":"https://api.github.com/users/wing328/orgs","repos_url":"https://api.github.com/users/wing328/repos","events_url":"https://api.github.com/users/wing328/events{/privacy}","received_events_url":"https://api.github.com/users/wing328/received_events","type":"User","site_admin":false},"open_issues":62,"closed_issues":6,"state":"open","created_at":"2019-08-26T02:07:49Z","updated_at":"2019-08-28T07:51:17Z","due_on":"2019-09-13T07:00:00Z","closed_at":null},"comments":4,"created_at":"2019-08-27T21:19:00Z","updated_at":"2019-08-28T08:04:00Z","closed_at":null,"author_association":"NONE","pull_request":{"url":"https://api.github.com/repos/OpenAPITools/openapi-generator/pulls/3771","html_url":"https://github.com/OpenAPITools/openapi-generator/pull/3771","diff_url":"https://github.com/OpenAPITools/openapi-generator/pull/3771.diff","patch_url":"https://github.com/OpenAPITools/openapi-generator/pull/3771.patch"},"body":"### PR checklist\r\n\r\n- [X] Read the [contribution guidelines](https://github.com/openapitools/openapi-generator/blob/master/CONTRIBUTING.md).\r\n- [ ] Ran the shell script under `./bin/` to update Petstore sample so that CIs can verify the change. (For instance, only need to run `./bin/{LANG}-petstore.sh`, `./bin/openapi3/{LANG}-petstore.sh` if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in `.\\bin\\windows\\`. If contributing template-only or documentation-only changes which will change sample output, be sure to [build the project](https://github.com/OpenAPITools/openapi-generator#14---build-projects) first.\r\n- [X] Filed the PR against the [correct branch](https://github.com/OpenAPITools/openapi-generator/wiki/Git-Branches): `master`, `4.1.x`, `5.0.x`. Default: `master`.\r\n- [X] Copied the [technical committee](https://github.com/openapitools/openapi-generator/#62---openapi-generator-technical-committee) to review the pull request if your PR is targeting a particular programming language.\r\n\r\n### Description of the PR\r\nWhilst the spec states that the 'allOf' relationship does not imply a hierarchy:\r\n\r\n> While composition offers model extensibility, it does not imply a hierarchy between the models.\r\n> To support polymorphism, the OpenAPI Specification adds the discriminator field.\r\n\r\nUnfortunately this does not make sense for many existing use cases, that were supported by older\r\nversions of the generator. Therefore, I've restored the older behavior, specifically\r\nin the case that only a single possible parent schema is present.\r\n\r\nI think a more complete solution would generate interfaces for the composed schemas,\r\nand mark the generated class as implementing these.\r\n\r\n@wing328 I guess you're probably the best person to review this, given that you overhauled the support for `anyOf`, `allOf`, `oneOf` originally. \r\n\r\nI'd be interested if you had an alternative suggestion for achieving this without requiring the parent schema to know the identity of all the extending schema's - in our real definition collection, we have a set of common models that many different entities extend from in other definition files, and we have also build some common library functions that we use on the generated sub classes that accept objects extending from the parent.\r\n\r\nAdmittedly, our method of using allOf to express this feels awkward. Ideally I'd like a way to generate a generic `Page<T>` class that could then be used as `Page<Cat>`, `Page<Dog>`, etc but I'm not aware of anyway to do this with the openapi spec / code gen tooling.\r\n\r\nExample YAML:\r\n```\r\nopenapi: 3.0.0\r\ninfo:\r\n  title: example\r\n  description: example\r\n  version: 0.0.0\r\npaths:\r\n  /test:\r\n    get:\r\n      tags:\r\n        - Test\r\n      summary: test\r\n      description: test\r\n      operationId: getCats\r\n      responses:\r\n        '200':\r\n          description: successful\r\n          content:\r\n            application/json:\r\n              schema:\r\n                $ref: '#/components/schemas/PagedCats'\r\ncomponents:\r\n  schemas:\r\n    Page:\r\n      properties:\r\n        page:\r\n          type: integer\r\n      required:\r\n        - page\r\n    Cat:\r\n      properties:\r\n        id:\r\n          type: string\r\n          format: uuid\r\n        required:\r\n          - id\r\n    Dog:\r\n      properties:\r\n        id:\r\n          type: string\r\n          format: uuid\r\n        required:\r\n          - id\r\n    PagedCats:\r\n      allOf:\r\n        - $ref: '#/components/schemas/Page'\r\n        - properties:\r\n            items:\r\n              type: array\r\n              items:\r\n                $ref: '#/components/schemas/Cat'\r\n          required:\r\n            - items\r\n    PagedDogs:\r\n      allOf:\r\n        - $ref: '#/components/schemas/Page'\r\n        - properties:\r\n            items:\r\n              type: array\r\n              items:\r\n                $ref: '#/components/schemas/Dog'\r\n          required:\r\n            - items\r\n```\r\n\r\nfixes #2845, and fixes #3523"},"comment":{"url":"https://api.github.com/repos/OpenAPITools/openapi-generator/issues/comments/525631410","html_url":"https://github.com/OpenAPITools/openapi-generator/pull/3771#issuecomment-525631410","issue_url":"https://api.github.com/repos/OpenAPITools/openapi-generator/issues/3771","id":525631410,"node_id":"MDEyOklzc3VlQ29tbWVudDUyNTYzMTQxMA==","user":{"login":"wing328","id":934260,"node_id":"MDQ6VXNlcjkzNDI2MA==","avatar_url":"https://avatars2.githubusercontent.com/u/934260?v=4","gravatar_id":"","url":"https://api.github.com/users/wing328","html_url":"https://github.com/wing328","followers_url":"https://api.github.com/users/wing328/followers","following_url":"https://api.github.com/users/wing328/following{/other_user}","gists_url":"https://api.github.com/users/wing328/gists{/gist_id}","starred_url":"https://api.github.com/users/wing328/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wing328/subscriptions","organizations_url":"https://api.github.com/users/wing328/orgs","repos_url":"https://api.github.com/users/wing328/repos","events_url":"https://api.github.com/users/wing328/events{/privacy}","received_events_url":"https://api.github.com/users/wing328/received_events","type":"User","site_admin":false},"created_at":"2019-08-28T08:04:00Z","updated_at":"2019-08-28T08:04:00Z","author_association":"MEMBER","body":"Thanks for the PR but your commit (as shown in the Commits tab) is not linked to your Github account, which means this PR won't count as your contribution in https://github.com/OpenAPITools/openapi-generator/graphs/contributors.\r\n\r\nLet me know if you need help fixing it.\r\n\r\nRef: https://github.com/OpenAPITools/openapi-generator/wiki/FAQ#how-can-i-update-commits-that-are-not-linked-to-my-github-account"}}
{"actor":{"display_login":"wing328"}}