SlideShare a Scribd company logo
1 of 3
Download to read offline
========
Swagger
========
-> Swagger is a third party api
-> Swagger is used to generate documentation for our REST APIs
Q) What is REST API documentation ?
Ans) REST API documentation will provide all the information about API like
below
a) API Base URL
b) Endpoints of API
c) Request Data Format
d) Response Data Format
-> API documentation will play major role in distributed applications
development.
Note: If we want to access any API then we need documentation for that.
Based on the documentation we can understand api and its structure.
===========
Use-Case
===========
-> IRCTC project developed by one company to book train tickets
-> MakeMyTrip applications developed by another company to book tickets.
-> MakeMyTrip wants to communicate with IRCTC to book train tickets.
-> To communicate with IRCTC, MakeMyTrip project developers should
understand IRCTC API details.
a) What is URL ?
b) What are the Endpoints ?
c) Request Data Structure
d) Response Data Structure
-> If MakeyMyTrip developers knows above details then only they can write
the logic to access IRCTC api.
Note: IRCTC team should provide API documentation to MakeMyTrip team.
-> Swagger-UI is used to test our REST APIs (We can use this as alternative
to POSTMAN)
============================================
How to setup Swagger in Spring Boot Application ?
============================================
############### 1) Add Swagger & Swagger-UI dependencies in pom.xml file
###############
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
################# 2) Create Swagger Config class ######################
package in.ashokit.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket apiDoc() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.basePackage("in.ashokit.rest"))
.paths(PathSelectors.any())
.build();
}
}
################ 3) Configure below property in application.properties file
#################
spring.mvc.pathmatch.matching-strategy = ANT_PATH_MATCHER
############### 4) Run the spring boot application and access below URL
###################
URL : http://localhost:8080/swagger-ui.html
============================================================================
=====

More Related Content

Similar to Swagger Notes.pdf

Why your next serverless project should use AWS AppSync
Why your next serverless project should use AWS AppSyncWhy your next serverless project should use AWS AppSync
Why your next serverless project should use AWS AppSyncYan Cui
 
Thiruvananthapuram Anypoint DataGraph 2 Sept.pdf
Thiruvananthapuram Anypoint DataGraph 2 Sept.pdfThiruvananthapuram Anypoint DataGraph 2 Sept.pdf
Thiruvananthapuram Anypoint DataGraph 2 Sept.pdfVikalp Bhalia
 
The Complete Guide to API Development in 2022.pdf
The Complete Guide to API Development in 2022.pdfThe Complete Guide to API Development in 2022.pdf
The Complete Guide to API Development in 2022.pdfConcetto Labs
 
Connect SharePoint Framework solutions to APIs secured with Azure AD
Connect SharePoint Framework solutions to APIs secured with Azure ADConnect SharePoint Framework solutions to APIs secured with Azure AD
Connect SharePoint Framework solutions to APIs secured with Azure ADBIWUG
 
Open API at Transavia
Open API at TransaviaOpen API at Transavia
Open API at TransaviaRoy Scheerder
 
API moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e webAPI moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e webAmazon Web Services
 
Supercharging Self-Service API Integration with AI
Supercharging Self-Service API Integration with AI Supercharging Self-Service API Integration with AI
Supercharging Self-Service API Integration with AI SnapLogic
 
Introduction to Google App Engine
Introduction to Google App EngineIntroduction to Google App Engine
Introduction to Google App Enginerajdeep
 
Iccsn2017 slideshare
Iccsn2017 slideshareIccsn2017 slideshare
Iccsn2017 slideshareRuo Ando
 
Service Mesh, 좀 더 쉽게 - AWS App Mesh :: 안주은 - AWS Community Day 2019
Service Mesh, 좀 더 쉽게 - AWS App Mesh :: 안주은 - AWS Community Day 2019Service Mesh, 좀 더 쉽게 - AWS App Mesh :: 안주은 - AWS Community Day 2019
Service Mesh, 좀 더 쉽게 - AWS App Mesh :: 안주은 - AWS Community Day 2019AWSKRUG - AWS한국사용자모임
 
Monitoring Spark Applications
Monitoring Spark ApplicationsMonitoring Spark Applications
Monitoring Spark ApplicationsTzach Zohar
 
MuleSoft Surat Virtual Meetup#20 - Unleash the power of Anypoint DataGraph
MuleSoft Surat Virtual Meetup#20 - Unleash the power of Anypoint DataGraphMuleSoft Surat Virtual Meetup#20 - Unleash the power of Anypoint DataGraph
MuleSoft Surat Virtual Meetup#20 - Unleash the power of Anypoint DataGraphJitendra Bafna
 
Hard learned CSOM and REST tips
Hard learned CSOM and REST tipsHard learned CSOM and REST tips
Hard learned CSOM and REST tipsSPC Adriatics
 
api_101
api_101api_101
api_101samir
 
API Documentation.pptx
API Documentation.pptxAPI Documentation.pptx
API Documentation.pptxRahulCR31
 
API Documentation.pptx
API Documentation.pptxAPI Documentation.pptx
API Documentation.pptxRahulCR31
 

Similar to Swagger Notes.pdf (20)

Why your next serverless project should use AWS AppSync
Why your next serverless project should use AWS AppSyncWhy your next serverless project should use AWS AppSync
Why your next serverless project should use AWS AppSync
 
Thiruvananthapuram Anypoint DataGraph 2 Sept.pdf
Thiruvananthapuram Anypoint DataGraph 2 Sept.pdfThiruvananthapuram Anypoint DataGraph 2 Sept.pdf
Thiruvananthapuram Anypoint DataGraph 2 Sept.pdf
 
The Complete Guide to API Development in 2022.pdf
The Complete Guide to API Development in 2022.pdfThe Complete Guide to API Development in 2022.pdf
The Complete Guide to API Development in 2022.pdf
 
Connect SharePoint Framework solutions to APIs secured with Azure AD
Connect SharePoint Framework solutions to APIs secured with Azure ADConnect SharePoint Framework solutions to APIs secured with Azure AD
Connect SharePoint Framework solutions to APIs secured with Azure AD
 
Open API at Transavia
Open API at TransaviaOpen API at Transavia
Open API at Transavia
 
API moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e webAPI moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e web
 
Trusting an API Spec
Trusting an API SpecTrusting an API Spec
Trusting an API Spec
 
Supercharging Self-Service API Integration with AI
Supercharging Self-Service API Integration with AI Supercharging Self-Service API Integration with AI
Supercharging Self-Service API Integration with AI
 
Wt3 designing apis
Wt3 designing apisWt3 designing apis
Wt3 designing apis
 
Introduction to Google App Engine
Introduction to Google App EngineIntroduction to Google App Engine
Introduction to Google App Engine
 
AIR & API
AIR & APIAIR & API
AIR & API
 
Iccsn2017 slideshare
Iccsn2017 slideshareIccsn2017 slideshare
Iccsn2017 slideshare
 
Service Mesh, 좀 더 쉽게 - AWS App Mesh :: 안주은 - AWS Community Day 2019
Service Mesh, 좀 더 쉽게 - AWS App Mesh :: 안주은 - AWS Community Day 2019Service Mesh, 좀 더 쉽게 - AWS App Mesh :: 안주은 - AWS Community Day 2019
Service Mesh, 좀 더 쉽게 - AWS App Mesh :: 안주은 - AWS Community Day 2019
 
Monitoring Spark Applications
Monitoring Spark ApplicationsMonitoring Spark Applications
Monitoring Spark Applications
 
MuleSoft Surat Virtual Meetup#20 - Unleash the power of Anypoint DataGraph
MuleSoft Surat Virtual Meetup#20 - Unleash the power of Anypoint DataGraphMuleSoft Surat Virtual Meetup#20 - Unleash the power of Anypoint DataGraph
MuleSoft Surat Virtual Meetup#20 - Unleash the power of Anypoint DataGraph
 
Glympse Platform
Glympse PlatformGlympse Platform
Glympse Platform
 
Hard learned CSOM and REST tips
Hard learned CSOM and REST tipsHard learned CSOM and REST tips
Hard learned CSOM and REST tips
 
api_101
api_101api_101
api_101
 
API Documentation.pptx
API Documentation.pptxAPI Documentation.pptx
API Documentation.pptx
 
API Documentation.pptx
API Documentation.pptxAPI Documentation.pptx
API Documentation.pptx
 

Recently uploaded

electrical installation and maintenance.
electrical installation and maintenance.electrical installation and maintenance.
electrical installation and maintenance.benjamincojr
 
The Entity-Relationship Model(ER Diagram).pptx
The Entity-Relationship Model(ER Diagram).pptxThe Entity-Relationship Model(ER Diagram).pptx
The Entity-Relationship Model(ER Diagram).pptxMANASINANDKISHORDEOR
 
Theory of Time 2024 (Universal Theory for Everything)
Theory of Time 2024 (Universal Theory for Everything)Theory of Time 2024 (Universal Theory for Everything)
Theory of Time 2024 (Universal Theory for Everything)Ramkumar k
 
Augmented Reality (AR) with Augin Software.pptx
Augmented Reality (AR) with Augin Software.pptxAugmented Reality (AR) with Augin Software.pptx
Augmented Reality (AR) with Augin Software.pptxMustafa Ahmed
 
Adsorption (mass transfer operations 2) ppt
Adsorption (mass transfer operations 2) pptAdsorption (mass transfer operations 2) ppt
Adsorption (mass transfer operations 2) pptjigup7320
 
Developing a smart system for infant incubators using the internet of things ...
Developing a smart system for infant incubators using the internet of things ...Developing a smart system for infant incubators using the internet of things ...
Developing a smart system for infant incubators using the internet of things ...IJECEIAES
 
litvinenko_Henry_Intrusion_Hong-Kong_2024.pdf
litvinenko_Henry_Intrusion_Hong-Kong_2024.pdflitvinenko_Henry_Intrusion_Hong-Kong_2024.pdf
litvinenko_Henry_Intrusion_Hong-Kong_2024.pdfAlexander Litvinenko
 
Dynamo Scripts for Task IDs and Space Naming.pptx
Dynamo Scripts for Task IDs and Space Naming.pptxDynamo Scripts for Task IDs and Space Naming.pptx
Dynamo Scripts for Task IDs and Space Naming.pptxMustafa Ahmed
 
Independent Solar-Powered Electric Vehicle Charging Station
Independent Solar-Powered Electric Vehicle Charging StationIndependent Solar-Powered Electric Vehicle Charging Station
Independent Solar-Powered Electric Vehicle Charging Stationsiddharthteach18
 
SLIDESHARE PPT-DECISION MAKING METHODS.pptx
SLIDESHARE PPT-DECISION MAKING METHODS.pptxSLIDESHARE PPT-DECISION MAKING METHODS.pptx
SLIDESHARE PPT-DECISION MAKING METHODS.pptxCHAIRMAN M
 
Raashid final report on Embedded Systems
Raashid final report on Embedded SystemsRaashid final report on Embedded Systems
Raashid final report on Embedded SystemsRaashidFaiyazSheikh
 
Artificial intelligence presentation2-171219131633.pdf
Artificial intelligence presentation2-171219131633.pdfArtificial intelligence presentation2-171219131633.pdf
Artificial intelligence presentation2-171219131633.pdfKira Dess
 
Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...
Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...
Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...drjose256
 
Autodesk Construction Cloud (Autodesk Build).pptx
Autodesk Construction Cloud (Autodesk Build).pptxAutodesk Construction Cloud (Autodesk Build).pptx
Autodesk Construction Cloud (Autodesk Build).pptxMustafa Ahmed
 
Fuzzy logic method-based stress detector with blood pressure and body tempera...
Fuzzy logic method-based stress detector with blood pressure and body tempera...Fuzzy logic method-based stress detector with blood pressure and body tempera...
Fuzzy logic method-based stress detector with blood pressure and body tempera...IJECEIAES
 
Maximizing Incident Investigation Efficacy in Oil & Gas: Techniques and Tools
Maximizing Incident Investigation Efficacy in Oil & Gas: Techniques and ToolsMaximizing Incident Investigation Efficacy in Oil & Gas: Techniques and Tools
Maximizing Incident Investigation Efficacy in Oil & Gas: Techniques and Toolssoginsider
 
engineering chemistry power point presentation
engineering chemistry  power point presentationengineering chemistry  power point presentation
engineering chemistry power point presentationsj9399037128
 
Working Principle of Echo Sounder and Doppler Effect.pdf
Working Principle of Echo Sounder and Doppler Effect.pdfWorking Principle of Echo Sounder and Doppler Effect.pdf
Working Principle of Echo Sounder and Doppler Effect.pdfSkNahidulIslamShrabo
 
UNIT 4 PTRP final Convergence in probability.pptx
UNIT 4 PTRP final Convergence in probability.pptxUNIT 4 PTRP final Convergence in probability.pptx
UNIT 4 PTRP final Convergence in probability.pptxkalpana413121
 
Interfacing Analog to Digital Data Converters ee3404.pdf
Interfacing Analog to Digital Data Converters ee3404.pdfInterfacing Analog to Digital Data Converters ee3404.pdf
Interfacing Analog to Digital Data Converters ee3404.pdfragupathi90
 

Recently uploaded (20)

electrical installation and maintenance.
electrical installation and maintenance.electrical installation and maintenance.
electrical installation and maintenance.
 
The Entity-Relationship Model(ER Diagram).pptx
The Entity-Relationship Model(ER Diagram).pptxThe Entity-Relationship Model(ER Diagram).pptx
The Entity-Relationship Model(ER Diagram).pptx
 
Theory of Time 2024 (Universal Theory for Everything)
Theory of Time 2024 (Universal Theory for Everything)Theory of Time 2024 (Universal Theory for Everything)
Theory of Time 2024 (Universal Theory for Everything)
 
Augmented Reality (AR) with Augin Software.pptx
Augmented Reality (AR) with Augin Software.pptxAugmented Reality (AR) with Augin Software.pptx
Augmented Reality (AR) with Augin Software.pptx
 
Adsorption (mass transfer operations 2) ppt
Adsorption (mass transfer operations 2) pptAdsorption (mass transfer operations 2) ppt
Adsorption (mass transfer operations 2) ppt
 
Developing a smart system for infant incubators using the internet of things ...
Developing a smart system for infant incubators using the internet of things ...Developing a smart system for infant incubators using the internet of things ...
Developing a smart system for infant incubators using the internet of things ...
 
litvinenko_Henry_Intrusion_Hong-Kong_2024.pdf
litvinenko_Henry_Intrusion_Hong-Kong_2024.pdflitvinenko_Henry_Intrusion_Hong-Kong_2024.pdf
litvinenko_Henry_Intrusion_Hong-Kong_2024.pdf
 
Dynamo Scripts for Task IDs and Space Naming.pptx
Dynamo Scripts for Task IDs and Space Naming.pptxDynamo Scripts for Task IDs and Space Naming.pptx
Dynamo Scripts for Task IDs and Space Naming.pptx
 
Independent Solar-Powered Electric Vehicle Charging Station
Independent Solar-Powered Electric Vehicle Charging StationIndependent Solar-Powered Electric Vehicle Charging Station
Independent Solar-Powered Electric Vehicle Charging Station
 
SLIDESHARE PPT-DECISION MAKING METHODS.pptx
SLIDESHARE PPT-DECISION MAKING METHODS.pptxSLIDESHARE PPT-DECISION MAKING METHODS.pptx
SLIDESHARE PPT-DECISION MAKING METHODS.pptx
 
Raashid final report on Embedded Systems
Raashid final report on Embedded SystemsRaashid final report on Embedded Systems
Raashid final report on Embedded Systems
 
Artificial intelligence presentation2-171219131633.pdf
Artificial intelligence presentation2-171219131633.pdfArtificial intelligence presentation2-171219131633.pdf
Artificial intelligence presentation2-171219131633.pdf
 
Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...
Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...
Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...
 
Autodesk Construction Cloud (Autodesk Build).pptx
Autodesk Construction Cloud (Autodesk Build).pptxAutodesk Construction Cloud (Autodesk Build).pptx
Autodesk Construction Cloud (Autodesk Build).pptx
 
Fuzzy logic method-based stress detector with blood pressure and body tempera...
Fuzzy logic method-based stress detector with blood pressure and body tempera...Fuzzy logic method-based stress detector with blood pressure and body tempera...
Fuzzy logic method-based stress detector with blood pressure and body tempera...
 
Maximizing Incident Investigation Efficacy in Oil & Gas: Techniques and Tools
Maximizing Incident Investigation Efficacy in Oil & Gas: Techniques and ToolsMaximizing Incident Investigation Efficacy in Oil & Gas: Techniques and Tools
Maximizing Incident Investigation Efficacy in Oil & Gas: Techniques and Tools
 
engineering chemistry power point presentation
engineering chemistry  power point presentationengineering chemistry  power point presentation
engineering chemistry power point presentation
 
Working Principle of Echo Sounder and Doppler Effect.pdf
Working Principle of Echo Sounder and Doppler Effect.pdfWorking Principle of Echo Sounder and Doppler Effect.pdf
Working Principle of Echo Sounder and Doppler Effect.pdf
 
UNIT 4 PTRP final Convergence in probability.pptx
UNIT 4 PTRP final Convergence in probability.pptxUNIT 4 PTRP final Convergence in probability.pptx
UNIT 4 PTRP final Convergence in probability.pptx
 
Interfacing Analog to Digital Data Converters ee3404.pdf
Interfacing Analog to Digital Data Converters ee3404.pdfInterfacing Analog to Digital Data Converters ee3404.pdf
Interfacing Analog to Digital Data Converters ee3404.pdf
 

Swagger Notes.pdf

  • 1. ======== Swagger ======== -> Swagger is a third party api -> Swagger is used to generate documentation for our REST APIs Q) What is REST API documentation ? Ans) REST API documentation will provide all the information about API like below a) API Base URL b) Endpoints of API c) Request Data Format d) Response Data Format -> API documentation will play major role in distributed applications development. Note: If we want to access any API then we need documentation for that. Based on the documentation we can understand api and its structure. =========== Use-Case =========== -> IRCTC project developed by one company to book train tickets -> MakeMyTrip applications developed by another company to book tickets. -> MakeMyTrip wants to communicate with IRCTC to book train tickets. -> To communicate with IRCTC, MakeMyTrip project developers should understand IRCTC API details. a) What is URL ? b) What are the Endpoints ? c) Request Data Structure d) Response Data Structure -> If MakeyMyTrip developers knows above details then only they can write the logic to access IRCTC api. Note: IRCTC team should provide API documentation to MakeMyTrip team. -> Swagger-UI is used to test our REST APIs (We can use this as alternative to POSTMAN) ============================================ How to setup Swagger in Spring Boot Application ? ============================================
  • 2. ############### 1) Add Swagger & Swagger-UI dependencies in pom.xml file ############### <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>2.9.2</version> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> <version>2.9.2</version> </dependency> ################# 2) Create Swagger Config class ###################### package in.ashokit.config; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import springfox.documentation.builders.PathSelectors; import springfox.documentation.builders.RequestHandlerSelectors; import springfox.documentation.spi.DocumentationType; import springfox.documentation.spring.web.plugins.Docket; import springfox.documentation.swagger2.annotations.EnableSwagger2; @Configuration @EnableSwagger2 public class SwaggerConfig { @Bean public Docket apiDoc() { return new Docket(DocumentationType.SWAGGER_2) .select() .apis(RequestHandlerSelectors.basePackage("in.ashokit.rest")) .paths(PathSelectors.any()) .build(); } } ################ 3) Configure below property in application.properties file ################# spring.mvc.pathmatch.matching-strategy = ANT_PATH_MATCHER ############### 4) Run the spring boot application and access below URL ################### URL : http://localhost:8080/swagger-ui.html