{"action":"created","issue":{"url":"https://api.github.com/repos/springdox/springdox/issues/621","labels_url":"https://api.github.com/repos/springdox/springdox/issues/621/labels{/name}","comments_url":"https://api.github.com/repos/springdox/springdox/issues/621/comments","events_url":"https://api.github.com/repos/springdox/springdox/issues/621/events","html_url":"https://github.com/springdox/springdox/issues/621","id":63785943,"number":621,"title":"Cycles in Java classes cause infinite loop in ModelAttributeParameterExpander","user":{"login":"candrews","id":194713,"avatar_url":"https://avatars.githubusercontent.com/u/194713?v=3","gravatar_id":"","url":"https://api.github.com/users/candrews","html_url":"https://github.com/candrews","followers_url":"https://api.github.com/users/candrews/followers","following_url":"https://api.github.com/users/candrews/following{/other_user}","gists_url":"https://api.github.com/users/candrews/gists{/gist_id}","starred_url":"https://api.github.com/users/candrews/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/candrews/subscriptions","organizations_url":"https://api.github.com/users/candrews/orgs","repos_url":"https://api.github.com/users/candrews/repos","events_url":"https://api.github.com/users/candrews/events{/privacy}","received_events_url":"https://api.github.com/users/candrews/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-03-23T17:37:42Z","updated_at":"2015-03-23T19:46:23Z","closed_at":null,"body":"When using JPA, Hibernate, and other ORMs, it's common for each side of a relationship to refer to the other. For example:\r\n```Java\r\nclass Person {\r\n\tprivate String firstName;\r\n\tprivate String lastName;\r\n\tprivate Address address;\r\n\r\n\tpublic String getFirstName() {\r\n\t\treturn firstName;\r\n\t}\r\n\r\n\tpublic void setFirstName(String firstName) {\r\n\t\tthis.firstName = firstName;\r\n\t}\r\n\r\n\tpublic String getLastName() {\r\n\t\treturn lastName;\r\n\t}\r\n\r\n\tpublic void setLastName(String lastName) {\r\n\t\tthis.lastName = lastName;\r\n\t}\r\n\tpublic Address getAddress() {\r\n\t\treturn address;\r\n\t}\r\n\r\n\tpublic void setAddress(Address address) {\r\n\t\tthis.address= address;\r\n\t}\r\n}\r\n\r\nclass Address {\r\n\tprivate String street;\r\n\t@ApiModelProperty(hidden = true)\r\n\tprivate Person person;\r\n\r\n\tpublic String getStreet() {\r\n\t\treturn street;\r\n\t}\r\n\r\n\tpublic void setStreet(String street) {\r\n\t\tthis.street = street;\r\n\t}\r\n\tpublic Person getPerson() {\r\n\t\treturn person;\r\n\t}\r\n\r\n\tpublic void setPerson(person person) {\r\n\t\tthis.person= person;\r\n\t}\r\n}\r\n```\r\nCurrently, this set of classes causes an infinite loop resulting in a StackOverflowError in com.mangofactory.swagger.readers.operation.parameter.ModelAttributeParameterExpander.expand(String, Class<?>, List<Parameter>). The problem is that the Java classes are expanded but the annotation which would cause the field to be excluded is being processed, so Person references Address references Person... and the expansion continues infinitely.\r\n\r\nI think the solution is to simply process @ApiModelProperty(hidden = true) annotations at expansion time. It may also be nice to detect when such cycles occur and throw a descriptive error (instead of getting a StackOverflowError) but that's just a nice to have... solving the problem would quite sufficient :-)\r\n\r\nThanks!"},"comment":{"url":"https://api.github.com/repos/springdox/springdox/issues/comments/85165524","html_url":"https://github.com/springdox/springdox/issues/621#issuecomment-85165524","issue_url":"https://api.github.com/repos/springdox/springdox/issues/621","id":85165524,"user":{"login":"candrews","id":194713,"avatar_url":"https://avatars.githubusercontent.com/u/194713?v=3","gravatar_id":"","url":"https://api.github.com/users/candrews","html_url":"https://github.com/candrews","followers_url":"https://api.github.com/users/candrews/followers","following_url":"https://api.github.com/users/candrews/following{/other_user}","gists_url":"https://api.github.com/users/candrews/gists{/gist_id}","starred_url":"https://api.github.com/users/candrews/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/candrews/subscriptions","organizations_url":"https://api.github.com/users/candrews/orgs","repos_url":"https://api.github.com/users/candrews/repos","events_url":"https://api.github.com/users/candrews/events{/privacy}","received_events_url":"https://api.github.com/users/candrews/received_events","type":"User","site_admin":false},"created_at":"2015-03-23T19:46:23Z","updated_at":"2015-03-23T19:46:23Z","body":"The team here and I are very psyched about using Swagger, and this issue is a blocker for us, so I have to ask - what's the timeline for 2.x?\r\n\r\nAlso, my naive impression is that if a check for the @ApiModel(hidden=true) annotation on the \"field\" variable in the \"expand\" method would solve this problem and doesn't seem like it could cause regressions, so is that solution workable, and would it be permitted in a near future non-2.x release?"}}