Why every backend freelancer should use swagger

in GEMS3 years ago (edited)

Let me start off by saying I am no swagger expert :) Just sharing a simple life experience.

I am a Java developer not because its the only programming language I like, but my work relates more towards Java/J2EE and spring-boot application.

I first saw swagger in a random project I had to maintain for a few weeks. I picked up some pointers from there and I thought to my self, "This is good shit!". Self documenting and executable API's right in the browser with a little bit of styling. This is the holy grail for communication between frontend and backend devs. I thought this was really clever and I would use it in the next project.

screenshot - 2021-06-06T222123.965.jpg

Swagger first looks


Recently, me and my bud started a freelance project as a side hussle. We had never done a project together. Anyway, he does the frontend in vue and he had never heard of swagger. This was my first time using it as well. And now we are hooked! He does another side project with another dev in node, and he hates it there now because the API are in the form of messenger chats there.

screenshot - 2021-06-06T222216.259.jpg

It lets you try newly created API's or modified API's, you dont even need to open postman. the JSON body fields reflects the changes according to the expected body in the backend. It is a great debugging tool too in my opinion. The only downfall I saw is when doing form-data REST API's since it only accepted strings and I had to use an object mapper to change the json into my desired object. Also no dto fields there

screenshot - 2021-06-06T222433.828.jpg

Click 'try it out'


screenshot - 2021-06-06T223352.718.jpg

give your json body and press execute



screenshot - 2021-06-06T223535.579.jpg
and Voilà! See the result!


It is a great tool to have especially when the project is starting out and we have lots of dtos' and API's to refactor every week. Any changes in the backend is immediately reflected and the frontend dev can easily find out what changes were made instead of both arguing over small changes from 'adminID' to 'adminId'. Certainly saves a lot of time for everyone.

We did find out that swagger is supported in other backend languages such as node, python, php, etc.
I plan to make some tutorials about it soon :) Im just too lazy nowadays. Sorry haven't posted in a while xD

Sort:  

Yay! 🤗
Your content has been boosted with Ecency Points, by @the100.
Use Ecency daily to boost your growth on platform!

Support Ecency
Vote for Proposal
Delegate HP and earn more