Rest/Restful Api Interview Questions and Answers | Part 2| Swagger Spring boot tutorial |Code Decode

preview_player
Показать описание
In this video code decode have explained rest api interview questions for experienced candidate along with swagger implementation.

Udemy Course of Code Decode on Microservice k8s AWS CICD link:

Course Description Video :

How Do you share REST API contracts you created with Front end team?

There are multiple ways to share the created Rest API contract with front end or any other backend team who wants to access your service.

You can share the CURL from postman.

Best practice is to Implement the Swagger and configure it in such a way that as soon as you start your server the APIs must be automatically documented in Swagger UI.

What is SWAGGER
Documentation From Your API Design

As your project grows with the time, The number of rest end points to fulfilment new functionalities also increases. And so does the headache of maintaining API docs

Swagger tools takes the hard work out of generating and maintaining your API docs, ensuring your documentation stays up-to-date as your API evolves.

For existing APIs: Documentation can be auto-generated from an API definition.
For new APIs - on startup that too will be auto generated.

You can maintain multiple versions too.

What is SWAGGER UI
Swagger UI allows

Developers
Front end team members
Other Service users who calls your Rest endpoints for some data / functionality

to visualize and interact with the API’s resources without having any of the implementation logic in place

Understanding Code

@EnableSwagger2 - Enables Springfox swagger 2

return new Docket(DocumentationType.SWAGGER_2) - Springfox’s, primary api configuration mechanism is initialized for swagger specification 2.0

groupName("public-api") - Docket helps configure a subset of the services to be documented and groups them by name. Like - public-api , private-apis, business-api, admin-specific-apis

apiInfo(apiInfo()) - return ApiInfoBuilder - Builds the api information - like title, description, version, license etc.

select() - select() returns an instance of ApiSelectorBuilder to give fine grained control over the endpoints exposed via swagger.

apis() allows selection of RequestHandler's using a predicate. The example here uses an any predicate (default). Out of the box predicates provided are any, none, withClassAnnotation, withMethodAnnotation and basePackage.

Steps used - Summarize
add dependency in POM file in Rest API demo project
Add swagger config file in Rest API demo project
3) Hit :

4) now u see
Basic error controller :
configure Swagger in a Spring Boot application to hide paths exposed by the BasicErrorController.

solutions'
1) 4.1. Exclude with basePackage()


2) I think, the most elegant solution is to include only @RestController controllers into swagger, only thing to bear in mind, is to annotate all the REST controllers with that annotation:

As BasicErrorController is annotated with @Controller only, swagger would avoid BasicErrorController in definition file in Rest APi demo project

Subscriber and Follow Code Decode

#restapi #codedecode #swaggerrestapi
Рекомендации по теме
Комментарии
Автор

Cool stuff.. Thanks.. Waiting for the next one. Junit n executor framework

malaiarasi
Автор

Wow that was a surprise for me to learn swagger while just glancing rest. I have tried learning it through some websites before but this was easily explained. Thanks for spreading the knowledge. Just wow 🧑‍💻 😳🤗

johnnybreathe
Автор

You are such an angel ♥️🥺
These are the best contents which my seniors in office hesitated to teach ✨ very grateful dor for your work. Love you. I am following your videos to crack top companies. ✨

_cse_k.jayalakshmi
Автор

Nice explanation with short n sweet code...all swagger become easy within 5 min video

ravirajpradhan
Автор

Simply Awesome. Learned a lot. keep producing videos 😎

rakeshkachhadiya
Автор

Thank you so much mam. Great tutorials. Explained in a great n easy way

durgabhavani
Автор

Thank you for sharing useful videos, Code Decode is a Next you

srinuk
Автор

Great video. We want more practical part of project.😀

mysteriouscartoontales
Автор

It was very helpful, please add similar content, thank you

hyeedhz
Автор

Thanks for such an easy tutorial...u just made me understand swagger in just few minutes..

swapnilmishra
Автор

Really great explanation very straight forward points in your Video Thank you 🙂👌

saichakra
Автор

Thank you for all hard work you do!! Please create some videos on mockito and testing.. thanks

bhavikjoshi
Автор

Please make an additional video on advanced Rest API like options, header, patch vs put etc

abc.-_
Автор

Hi, thank you for your videos they are really helpful. Please create more such practical scenario based video on rest api.

vaishnaveetopale
Автор

Very good tutorial, I'd like to see tutorials with spring framework and with intwrview questions of spring framework too

violetavss
Автор

Please cover difference between PUT and PATCH. What is OPTION? Thank You.

leoking
Автор

Great 👍 please create subsequent videos.

sourabhjinde
Автор

Nice Explanation mam, if possible plz make video on maintaining versions using swagger also.

bathulanagendra
Автор

Please make video on swagger implementation with spring security

ranjayray
Автор

thank you so much mam for this video. i faced one question on swagger during the Accenture L1 interview. what is the use of $ in swagger. plz answer...

fsvxmre