2

I'm trying to document my java APIs using Swagger plugin in gradle with : "compile "io.swagger:swagger-annotations:1.5.0". I am using @ApiModelProperty annotation to achieve attribute's description, in my static html document.

I have a common DTO for multiple projects to use, but the problem is that, in some projects a particular attribute is required, but for other projects, its not required. So, I am looking to put some condition for attribute based on other attribute in that same package.

Rohit Bagjani
  • 1,264
  • 2
  • 11
  • 14
  • 1
    We had the same problem on my project. We manage this by creating a second DTO extending the first DTO with @ NotNull annotation. – Gremi64 Aug 11 '17 at 12:13
  • Thanks for responding @Gremi64 . But for that, I would need to duplicate code, which I am trying to save here. I need to use the attribute at 5 to 10 different places in other projects. In some they are required and in others they are not. If I will extend it each time, it will be having lots of duplicate code. I am trying to find solution without changing my DTO structure. If some condition I can put through annotations or if any other tool is available to achieve this. – Rohit Bagjani Aug 15 '17 at 07:22
  • It's not "duplicate code", we just override getter with the @ NotNull annotation and we call the super.getter. If you find another solution, please, put it here :) – Gremi64 Aug 16 '17 at 08:29

0 Answers0