{"action":"created","issue":{"url":"https://api.github.com/repos/swagger-api/swagger-core/issues/1549","labels_url":"https://api.github.com/repos/swagger-api/swagger-core/issues/1549/labels{/name}","comments_url":"https://api.github.com/repos/swagger-api/swagger-core/issues/1549/comments","events_url":"https://api.github.com/repos/swagger-api/swagger-core/issues/1549/events","html_url":"https://github.com/swagger-api/swagger-core/issues/1549","id":118125695,"number":1549,"title":"Definitions using polymorphism seem incorrect","user":{"login":"rdiehl","id":9591293,"avatar_url":"https://avatars.githubusercontent.com/u/9591293?v=3","gravatar_id":"","url":"https://api.github.com/users/rdiehl","html_url":"https://github.com/rdiehl","followers_url":"https://api.github.com/users/rdiehl/followers","following_url":"https://api.github.com/users/rdiehl/following{/other_user}","gists_url":"https://api.github.com/users/rdiehl/gists{/gist_id}","starred_url":"https://api.github.com/users/rdiehl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rdiehl/subscriptions","organizations_url":"https://api.github.com/users/rdiehl/orgs","repos_url":"https://api.github.com/users/rdiehl/repos","events_url":"https://api.github.com/users/rdiehl/events{/privacy}","received_events_url":"https://api.github.com/users/rdiehl/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-11-20T21:05:33Z","updated_at":"2015-11-23T07:59:24Z","closed_at":null,"body":"I'm not sure whether this belongs here, or in the swagger-parser project, or in the swagger2markup project https://swagger2markup.readme.io/, but I'll start here.  We have a number of models that use polymorphism, some of them extend multiple levels.  We're using Java annotations and the JAX-RS integration to create our Swagger definition at runtime.  I'm running into issues running our spec through the swagger2markup tool, and I'm trying to figure out whether the issue is something we have defined incorrectly, or a bug in one of the 3 projects.  Here's our Java classes with the swagger annotations.\r\n\r\n```java\r\n@ApiModel(description = \"The representation of a Chart-like object.\", discriminator = \"_class\",\r\n        subTypes = { TextChartDTO.class, ChartDTO.class, TableChartDTO.class })\r\npublic abstract class BaseChartDTO implements Serializable {\r\n    private String id;\r\n    private String name;\r\n    public String getId() { return id;}\r\n    public void setId(final String id) {this.id = id;}\r\n    public String getName() { return name;}\r\n    public void setName(final String name) {this.name = name};\r\n    // Various other properties\r\n}\r\n\r\n@ApiModel(description = \"A parent class for all charts.\", parent = BaseChartDTO.class, discriminator = \"_class\",\r\n        subTypes = { PieChartDTO.class, BarChartDTO.class, AreaChartDTO.class, LineChartDTO.class,\r\n            MixedChartDTO.class, GaugeChartDTO.class })\r\npublic abstract class ChartDTO extends BaseChartDTO implements Serializable {\r\n    private ChartType chartType;\r\n    public ChartType getChartType() {return chartType;}\r\n    public void setChartType(final ChartType type) {this.chartType = type;}\r\n    // various other properties\r\n}\r\n\r\n@ApiModel(description = \"An area chart.\", parent = ChartDTO.class)\r\npublic class AreaChartDTO extends ChartDTO implements Serializable {\r\n    // various properties\r\n}\r\n```\r\n\r\nWhen our swagger definition is generated, the definition for AreaChartDTO looks like this:\r\n```json\r\n\"AreaChartDTO\": {\r\n\"allOf\": [\r\n{\r\n\"$ref\": \"#/definitions/ChartDTO\"\r\n},\r\n{\r\n\"type\": \"object\",\r\n\"properties\": {\r\n  \"id\": {\r\n    \"type\": \"string\"\r\n  },\r\n  \"name\": {\r\n    \"type\": \"string\"\r\n  },\r\n},\r\n.... more stuff\r\n```\r\n\r\nNote the existence of \"allOf\", referencing the ChartDTO definition, and then individual properties like \"id\" and \"name\".  The definition for ChartDTO looks like this:\r\n\r\n```json\r\n\"ChartDTO\": {\r\n\"allOf\": [\r\n{\r\n\"$ref\": \"#/definitions/BaseChartDTO\"\r\n},\r\n{\r\n\"type\": \"object\",\r\n\"properties\": {\r\n  \"id\": {\r\n    \"type\": \"string\"\r\n  },\r\n  \"name\": {\r\n    \"type\": \"string\"\r\n  },\r\n.... more stuff\r\n``` \r\n\r\nAgain note that id and name are defined here.  The definition for BaseChartDTO has them as well.  In effect what we're seeing is that properties from the base classes are being duplicated for each concrete class.\r\n\r\nWhen the swagger definition goes through the swagger-parser, it parses successfully, but if you look in definitions, the id and name fields are duplicated 3 times through existence of multiple ComposedModel and RefModel objects.  When I send the Swagger object that comes back from the parser into the Swagger2markup tool, it throws an exception about having multiple entries with the same key: \"id\".  \r\n\r\nIs this something that we are configuring incorrectly in our ApiModel annotations?  If not, does this issue belong in swagger-core, swagger-parser, or the 3rd party swagger2markup project?"},"comment":{"url":"https://api.github.com/repos/swagger-api/swagger-core/issues/comments/158872731","html_url":"https://github.com/swagger-api/swagger-core/issues/1549#issuecomment-158872731","issue_url":"https://api.github.com/repos/swagger-api/swagger-core/issues/1549","id":158872731,"user":{"login":"fehguy","id":249413,"avatar_url":"https://avatars.githubusercontent.com/u/249413?v=3","gravatar_id":"","url":"https://api.github.com/users/fehguy","html_url":"https://github.com/fehguy","followers_url":"https://api.github.com/users/fehguy/followers","following_url":"https://api.github.com/users/fehguy/following{/other_user}","gists_url":"https://api.github.com/users/fehguy/gists{/gist_id}","starred_url":"https://api.github.com/users/fehguy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fehguy/subscriptions","organizations_url":"https://api.github.com/users/fehguy/orgs","repos_url":"https://api.github.com/users/fehguy/repos","events_url":"https://api.github.com/users/fehguy/events{/privacy}","received_events_url":"https://api.github.com/users/fehguy/received_events","type":"User","site_admin":false},"created_at":"2015-11-23T07:59:24Z","updated_at":"2015-11-23T07:59:24Z","body":"hmm, to be honest, this sounds like a swagger2markup issue.  If you could, please open a ticket there.  I don't think this belongs in swagger-core, as the spec you're showing looks accurate."}}