Home > Software engineering >  Is it ok to merge swagger interface into the controller?
Is it ok to merge swagger interface into the controller?

Time:11-11

Looking for best practice suggestions with swagger interface. SO my lead suggests doing away entirely with the swagger interface and instead having all the swagger annotations within the Controller itself. Is this good practice or otherwise ?

CodePudding user response:

This is borderline opinion-based, but yes it is ok. Some people might tell you that they prefer to have all Swagger-related annotations in an interface and others might tell you they prefer to have it directly in the Controller code. I usually have them directly in the Controller code. The only reasons to have them in an interface are to make it simpler to remove it if we ever need to and to keep concerns segregated, but let's face it how many times did you remove Swagger from a service after adding it the first time? Nevertheless, both options are ok.

  • Related