Rest/Restful Api Interview Questions and Answers | Part 2| Swagger Spring boot tutorial |Code Decode
Вставка
- Опубліковано 8 жов 2024
- 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:
openinapp.co/u...
Course Description Video :
yt.openinapp.c...
Rest Api part 2 : • Restful API Web Servic...
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 :
localhost:8080/swagger-ui.html#/
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()
//.apis(RequestHandlerSelectors.basePackage("com.codedecode.demo.controller"))
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:
.apis(RequestHandlerSelectors.withClassAnnotation(RestController.class))
As BasicErrorController is annotated with @Controller only, swagger would avoid BasicErrorController in definition file in Rest APi demo project
Most Asked Core Java Interview Questions and Answers : • Core Java frequently a...
Advance Java Interview Questions and Answers : • Advance Java Interview...
Java 8 Interview Questions and Answers : • Java 8 Interview Quest...
Hibernate Interview Questions and Answers : • Hibernate Interview Qu...
Spring Boot Interview Questions and Answers : • Advance Java Interview...
Angular Playlist : • Angular Course Introdu...
SQL Playlist : • SQL Interview Question...
GIT : • GIT
Subscriber and Follow Code Decode
Subscriber Code Decode : www.youtube.co...
LinkedIn : / codedecodeyoutube
Instagram : / codedecode25
#restapi #codedecode #swaggerrestapi
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. ✨
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 🧑💻 😳🤗
Haha glad to hear that 🙂 thanks a lot 🙂🙂things are really that easy, our task is to make it easy n present it to u 👍👍🙂🙂
Nice explanation with short n sweet code...all swagger become easy within 5 min .....great video
Glad to hear that Ravi 🙂👍👍🙂
Thanks for such an easy tutorial...u just made me understand swagger in just few minutes..
🙂🙂things are that simple here Swapnil. Either we are just afraid to start it or we fear we might not complete it successfully 🙂
Liked your video. I was trying to get some information on Rest Api Library . @@CodeDecode
Thank you for sharing useful videos, Code Decode is a Next leval.........Thank you
Thanks Srinu 🙂🙂
It was very helpful , please add similar content , thank you
Sure Kartik 👍👍
Really great explanation very straight forward points in your Video Thank you 🙂👌
Thanks a lot Sai 🙂🙂
Thank you for all hard work you do!! Please create some videos on mockito and testing.. thanks
sure bhavik we will create it soon
Thank you so much mam. Great tutorials. Explained in a great n easy way
Thanks durga
Hi, thank you for your videos they are really helpful. Please create more such practical scenario based video on rest api.
Sure Vaishnavee 🙂🙂👍👍
Great video. We want more practical part of project.😀
Sure Akash 🙂
Simply Awesome. Learned a lot. keep producing videos 😎
Sure Raakesh👍🙂
Simple and easy to understand 👌🏻
Thanks Nishant 🙂👍
wonderfully explanations. hatts of
Thanks Krupa 🙂👍
Nice Explanation mam,if possible plz make video on maintaining versions using swagger also.
Sure Nagendra 🙂👍
Great explanation, really helpful 🙏
you're welcome
Dear, make some videos on Junit it's very important in terms of interview
True Sushil. We will surely make video on junit part 🙂👍
@@CodeDecode hey eagerly waiting for this...
Cool stuff.. Thanks.. Waiting for the next one. Junit n executor framework
Please cover difference between PUT and PATCH. What is OPTION? Thank You.
Very good tutorial,I'd like to see tutorials with spring framework and with intwrview questions of spring framework too
👍👍sure
Please make an additional video on advanced Rest API like options, header, patch vs put etc
Thank and very useful content
Thanks 🙂🙂👍
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...
Please make video on swagger implementation with spring security
Great 👍 please create subsequent videos.
Sure thanks Sourabh 🙂👍
🙌 Thank you for sharing ❤️
🙂🙂
Great Explanation mam!
Thanks Ashish 🙂👍
Thanks a million
You're welcome rishi
i can confirm this is what is done in realtime
🙂
Dear Miss
Nice content . Why rushing ?
Please redo the video by going slowly and clearly .
Thanks Shankar . Sure we will try to reduce pace. Just that we don't want people to waste time before their interviews. We know how much it sucks when content creators just do time pass in videos for money. Rushing means less time, means less money. But if you want, we can take more time.
Hi it was very useful video..@code decode .. do you have git repo for the code you developed.. could you share if you have
Please provide next level of interview questions also.
Sure 🙂👍
Please make video on DevOps tools, waiting for that.
sure we will create it in near future
I have added the spring fox dependency to my project. But every time I run this project, I get data sources is not defined. If remove the dependency and it's respective class I do not get any error. Strage
Could you also make a video on how to integrate our spring boot application with splunk / dynatrace
Sure Teja 👍is it used in your project?
Yes ..but I am not aware about the integration
True. Lemme check how much feasible and optimum it is for prod ready deployments. 👍🙂
I have implemented dependency in pom.xml and congifgration file to but I am unable to access swagger UI window in console I am getting no mapping for get /swagger-ui please help me
Can you do a video on spring security .
ua-cam.com/play/PLyHJZXNdCXseGWynh6MlMrC_CmV0dR8mF.html
Also start a series on microservices madam
We already have it
ua-cam.com/play/PLyHJZXNdCXsd2e3NMW9sZbto8RB5foBtp.html
What else topic you need me to cover Prashanth?
@@CodeDecode Jwt and oAuth please
Sure we will cover it soon
Hi madam can you please create an video how anonymous inner class is used while using lamda expression like when we use lamda what happens internally?
Ok so you need internal working of lambda expression?
@@CodeDecode yes
Ok👍
I followed this swagger implementation with Spring version 2.7 and Java 8 and it was not working. It raised an exception at start of application. Is it because of version of Java and old version of spring boot?? Please respond for a clear understanding
Can you please respond with stack trace of error for better understanding the issue
Hi mam, i have only one question,how do you know all these things,i mean how can someone master in all these stuffs
Experience Ankit. With time it automatically comes. It's just we believe in sharing this knowledge so that our IT world can become a better place 👍👍🙂🙂
thanks
you're welcome
make a video on Junit and powermocks mokito
Sure Krishna 🙂👍
👍
🙂🙂
@codeDecode please share your github repo url
pls provide code if possible
The audio and video is too fast
Great man thanks for your effort. Your name Y___ Mohan?
I follow the same, But got this exception. Any idea? Tried in stack over flow but not yet find proper reason.
java.lang.NullPointerException: Cannot invoke "org.springframework.web.servlet.mvc.condition.PatternsRequestCondition.toString()" because the return value of "org.springframework.web.servlet.mvc.method.RequestMappingInfo.getPatternsCondition()" is null