{"action":"created","issue":{"url":"https://api.github.com/repos/go-swagger/go-swagger/issues/1537","repository_url":"https://api.github.com/repos/go-swagger/go-swagger","labels_url":"https://api.github.com/repos/go-swagger/go-swagger/issues/1537/labels{/name}","comments_url":"https://api.github.com/repos/go-swagger/go-swagger/issues/1537/comments","events_url":"https://api.github.com/repos/go-swagger/go-swagger/issues/1537/events","html_url":"https://github.com/go-swagger/go-swagger/issues/1537","id":324511623,"number":1537,"title":"No validation is called when the object referring to the array type parameter","user":{"login":"johnliu26","id":39390987,"avatar_url":"https://avatars3.githubusercontent.com/u/39390987?v=4","gravatar_id":"","url":"https://api.github.com/users/johnliu26","html_url":"https://github.com/johnliu26","followers_url":"https://api.github.com/users/johnliu26/followers","following_url":"https://api.github.com/users/johnliu26/following{/other_user}","gists_url":"https://api.github.com/users/johnliu26/gists{/gist_id}","starred_url":"https://api.github.com/users/johnliu26/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johnliu26/subscriptions","organizations_url":"https://api.github.com/users/johnliu26/orgs","repos_url":"https://api.github.com/users/johnliu26/repos","events_url":"https://api.github.com/users/johnliu26/events{/privacy}","received_events_url":"https://api.github.com/users/johnliu26/received_events","type":"User","site_admin":false},"labels":[{"id":148436504,"url":"https://api.github.com/repos/go-swagger/go-swagger/labels/bug","name":"bug","color":"fc2929","default":true},{"id":493024330,"url":"https://api.github.com/repos/go-swagger/go-swagger/labels/generator","name":"generator","color":"bfdadc","default":false}],"state":"open","locked":false,"assignee":{"login":"fredbi","id":14262513,"avatar_url":"https://avatars1.githubusercontent.com/u/14262513?v=4","gravatar_id":"","url":"https://api.github.com/users/fredbi","html_url":"https://github.com/fredbi","followers_url":"https://api.github.com/users/fredbi/followers","following_url":"https://api.github.com/users/fredbi/following{/other_user}","gists_url":"https://api.github.com/users/fredbi/gists{/gist_id}","starred_url":"https://api.github.com/users/fredbi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fredbi/subscriptions","organizations_url":"https://api.github.com/users/fredbi/orgs","repos_url":"https://api.github.com/users/fredbi/repos","events_url":"https://api.github.com/users/fredbi/events{/privacy}","received_events_url":"https://api.github.com/users/fredbi/received_events","type":"User","site_admin":false},"assignees":[{"login":"fredbi","id":14262513,"avatar_url":"https://avatars1.githubusercontent.com/u/14262513?v=4","gravatar_id":"","url":"https://api.github.com/users/fredbi","html_url":"https://github.com/fredbi","followers_url":"https://api.github.com/users/fredbi/followers","following_url":"https://api.github.com/users/fredbi/following{/other_user}","gists_url":"https://api.github.com/users/fredbi/gists{/gist_id}","starred_url":"https://api.github.com/users/fredbi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fredbi/subscriptions","organizations_url":"https://api.github.com/users/fredbi/orgs","repos_url":"https://api.github.com/users/fredbi/repos","events_url":"https://api.github.com/users/fredbi/events{/privacy}","received_events_url":"https://api.github.com/users/fredbi/received_events","type":"User","site_admin":false}],"milestone":null,"comments":4,"created_at":"2018-05-18T18:36:28Z","updated_at":"2018-05-18T20:34:12Z","closed_at":null,"author_association":"NONE","body":"## Problem statement\r\nThe issue is similar to the Issue #1392 and #1093 but not the same.\r\nWhen the body parameter is an under properties in object type, referencing array data type, none of the validation is called. But if we mark the body parameter required, the validation will show in the auto-generated code.\r\n\r\n## Swagger specification\r\n**Case : 1**\r\nprofileCfg: \r\n           type: object\r\n           properties:\r\n               value1:\r\n                   type: integer\r\n                   format: int32\r\n              value2:\r\n                  type: integer\r\n                  format: int32                    \r\nprofileCfgs:\r\n           type: array\r\n           x-omitempty: true\r\n           items:\r\n              $ref: '#definitions/profileCfg'\r\nProfile:\r\n           type: object\r\n           properties: \r\n                  profileCfg:\r\n                       $ref: '#definitions/profileCfgs'\r\n\r\n**Case: 2**\r\nprofileCfg: \r\n           type: object\r\n           properties:\r\n               value1:\r\n                   type: integer\r\n                   format: int32\r\n              value2:\r\n                  type: integer\r\n                  format: int32                    \r\nprofileCfgs:\r\n           type: array\r\n           x-omitempty: true\r\n           items:\r\n              $ref: '#definitions/profileCfg'\r\nProfile:\r\n           type: object\r\n           required:\r\n               - profileCfg\r\n           properties: \r\n                  profileCfg:\r\n                       $ref: '#definitions/profileCfgs'\r\n\r\n**Case 3**\r\nprofileCfg: \r\n           type: object\r\n           properties:\r\n               value1:\r\n                   type: integer\r\n                   format: int32\r\n              value2:\r\n                  type: integer\r\n                  format: int32            \r\nProfile:\r\n           type: object\r\n           required:\r\n               - profileCfg\r\n           properties: \r\n                  profileCfg:\r\n                       type: array\r\n                       x-omitempty: true\r\n                       items:\r\n                         $ref: '#definitions/profileCfg'\r\n                    \r\n## Steps to reproduce\r\nGenerate the server based on this swagger\r\nIn the Case1, the validation will not be generated.\r\nfunc (m *Profile) Validate(formats strfmt.Registry) error {\r\n        var res []error\r\n        if len(res) > 0 {\r\n                              return errors\r\n        }\r\n         return nil\r\n}\r\nIn the Case2, the validation will be generated successfully.\r\nfunc (m *profile) Validate(formats strfmt.Registry) error {\r\n      var res []error\r\n      if err := m.validateProfile(formats); err != nil {\r\n                res = append(res, err)\r\n      }\r\n     if len(res) > 0 {\r\n                              return errors\r\n        }\r\n         return nil\r\n}\r\n\r\nIn the Case3, if we remove the refer to the array struct, and without mark the area required the validation will still be generated same as the code in the Case 2. (Case 3 validation generation is by the fix in the issue #1392 and #1093.\r\n\r\nSo I think there may an issue that I have to mark the parameter required which it referring to the array struct if I want the validation to generate. Thanks very much for your help!\r\n\r\n## Environment\r\nswagger version: 0.13.0\r\ngo version: go1.10.2 linux/amd64\r\nOS:  Linux Centos\r\n"},"comment":{"url":"https://api.github.com/repos/go-swagger/go-swagger/issues/comments/390324622","html_url":"https://github.com/go-swagger/go-swagger/issues/1537#issuecomment-390324622","issue_url":"https://api.github.com/repos/go-swagger/go-swagger/issues/1537","id":390324622,"user":{"login":"fredbi","id":14262513,"avatar_url":"https://avatars1.githubusercontent.com/u/14262513?v=4","gravatar_id":"","url":"https://api.github.com/users/fredbi","html_url":"https://github.com/fredbi","followers_url":"https://api.github.com/users/fredbi/followers","following_url":"https://api.github.com/users/fredbi/following{/other_user}","gists_url":"https://api.github.com/users/fredbi/gists{/gist_id}","starred_url":"https://api.github.com/users/fredbi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fredbi/subscriptions","organizations_url":"https://api.github.com/users/fredbi/orgs","repos_url":"https://api.github.com/users/fredbi/repos","events_url":"https://api.github.com/users/fredbi/events{/privacy}","received_events_url":"https://api.github.com/users/fredbi/received_events","type":"User","site_admin":false},"created_at":"2018-05-18T20:34:12Z","updated_at":"2018-05-18T20:34:12Z","author_association":"CONTRIBUTOR","body":"I'll fix both over the week end (#1536 and #1537 if I can get to reproduce it). #1536 is already on the way."}}
{"actor":{"display_login":"fredbi"}}