-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added swagger documentation for all the existing API endpoints
- Loading branch information
Amit Kashyap
committed
Jan 29, 2019
1 parent
1bb9691
commit 25220a6
Showing
5 changed files
with
81 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
backend/src/main/java/com/onemda/onemdabackend/configuration/SpringFoxConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.onemda.onemdabackend.configuration; | ||
|
||
import java.util.Collections; | ||
|
||
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.service.ApiInfo; | ||
import springfox.documentation.service.Contact; | ||
import springfox.documentation.spi.DocumentationType; | ||
import springfox.documentation.spring.web.plugins.Docket; | ||
import springfox.documentation.swagger2.annotations.EnableSwagger2; | ||
|
||
@Configuration | ||
@EnableSwagger2 | ||
public class SpringFoxConfiguration { | ||
|
||
@Bean | ||
public Docket apiDocket() { | ||
return new Docket(DocumentationType.SWAGGER_2) | ||
.select() | ||
.apis(RequestHandlerSelectors.basePackage("com.onemda.onemdabackend")) //it will generate documentation for controllers as well as models | ||
.paths(PathSelectors.any()) | ||
.build() | ||
.apiInfo(getApiInfo()); // - This is to override default API infomation provided by Swagger | ||
} | ||
|
||
private ApiInfo getApiInfo() { | ||
return new ApiInfo( | ||
"Onemda API Details", //Title | ||
"This is the API specification page of OneMda", //Description | ||
"VERSION 1.0", | ||
"TERMS OF SERVICE URL", | ||
new Contact("OneMda","https://www.onemda.com.au/","[email protected]"), | ||
"Reg No A0025065T", | ||
"LICENSE URL", | ||
Collections.emptyList() | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters