-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
184 additions
and
3 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
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
55 changes: 55 additions & 0 deletions
55
src/main/java/com/webservice/mobile/app/SwaggerConfig.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,55 @@ | ||
package com.webservice.mobile.app; | ||
|
||
|
||
|
||
|
||
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.service.VendorExtension; | ||
import springfox.documentation.spi.DocumentationType; | ||
import springfox.documentation.spring.web.plugins.Docket; | ||
import springfox.documentation.swagger2.annotations.EnableSwagger2; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.HashSet; | ||
import java.util.List; | ||
|
||
|
||
@Configuration | ||
@EnableSwagger2 | ||
public class SwaggerConfig { | ||
|
||
Contact contact = new Contact( | ||
"Raj Singha", | ||
"https://rajsingha.codes", | ||
"[email protected]" | ||
); | ||
|
||
List<VendorExtension> vendorExtensions = new ArrayList<>(); | ||
|
||
ApiInfo apiInfo = new ApiInfo( | ||
"Mobile App WebService - RESTful Web Service Documentation ", | ||
"This pages documents Mobile App WebService RESTful Web Service Endpoints", | ||
"1.0",null, | ||
contact, | ||
"Apache 2.0", | ||
"http://www.apache.org/licenses/LICENSE-2.0", | ||
vendorExtensions); | ||
|
||
@Bean | ||
public Docket apiDocket(){ | ||
Docket docket = new Docket(DocumentationType.SWAGGER_2) | ||
.protocols(new HashSet<>(Arrays.asList("HTTP","HTTPs"))) | ||
.apiInfo(apiInfo) | ||
.select() | ||
.apis(RequestHandlerSelectors.basePackage("com.webservice.mobile.app")) | ||
.paths(PathSelectors.any()) | ||
.build(); | ||
return docket; | ||
} | ||
} |
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
37 changes: 37 additions & 0 deletions
37
src/main/java/com/webservice/mobile/app/ui/controller/AuthenticationController.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,37 @@ | ||
package com.webservice.mobile.app.ui.controller; | ||
|
||
|
||
import com.webservice.mobile.app.ui.model.request.LoginRequestModel; | ||
import io.swagger.annotations.ApiOperation; | ||
import io.swagger.annotations.ApiResponse; | ||
import io.swagger.annotations.ApiResponses; | ||
import io.swagger.annotations.ResponseHeader; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
public class AuthenticationController { | ||
|
||
|
||
@ApiOperation("User Login") | ||
@ApiResponses(value = { | ||
@ApiResponse(code = 200, | ||
message = "Response Headers", | ||
responseHeaders = { | ||
@ResponseHeader(name = "authorization", | ||
description = "Bearer<JWT value her>", | ||
response = String.class), | ||
@ResponseHeader(name = "userId", | ||
description = "<Public user id value here>", | ||
response = String.class) | ||
}) | ||
}) | ||
@PostMapping("/users/login") | ||
public void theFakeLogin(@RequestBody LoginRequestModel loginRequestModel){ | ||
throw new IllegalStateException("This method should not be called." + | ||
"This method is implemented by Spring Security"); | ||
|
||
} | ||
|
||
} |
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
22 changes: 22 additions & 0 deletions
22
src/main/java/com/webservice/mobile/app/ui/model/request/LoginRequestModel.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,22 @@ | ||
package com.webservice.mobile.app.ui.model.request; | ||
|
||
public class LoginRequestModel { | ||
private String email; | ||
private String password; | ||
|
||
public String getEmail() { | ||
return email; | ||
} | ||
|
||
public void setEmail(String email) { | ||
this.email = email; | ||
} | ||
|
||
public String getPassword() { | ||
return password; | ||
} | ||
|
||
public void setPassword(String password) { | ||
this.password = password; | ||
} | ||
} |
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