Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Is it ok to merge swagger interface into the controller?

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 ?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading