-
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.
Merge pull request #5 from davidorellana98/develop
Integration of unit tests with Mockito and documentation with Swagger.
- Loading branch information
Showing
26 changed files
with
587 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,52 @@ | ||
<h1 align="center">Proyecto Integrador: Booking System Rest API con MongoDB</h1> | ||
<h1 style="text-align:center;">Proyecto Integrador: Booking System Rest API</h1> | ||
|
||
## Diagrama Microservicio User | ||
El proyecto fue realizado siguiendo las buenas prácticas de programación, además contiene las siguientes implementaciones: | ||
|
||
## Diagrama Microservicio Booking | ||
* Microservicios User, Booking y Authentication | ||
* Java versión 11 | ||
* Gestor de Dependencias Maven | ||
* Spring Boot versión 2.7.5 | ||
* Persistencia de datos con MongoDB | ||
* Jwt y Spring Security | ||
* Test unitarios con JUnit y Mockito | ||
* Documentación con Swagger | ||
|
||
## Documentación con Swagger | ||
|
||
Puedes visualizar la estructura de los controladores en la interfaz gráfica de [Swagger](http://localhost:8080/swagger-ui/), para consultar los endpoints del CRUD. | ||
|
||
Para tener acceso total se debe crear un usuario, teniendo en cuenta la siguiente estructura en formato JSON, por ejemplo: | ||
|
||
```xml | ||
{ | ||
"name": "luis", | ||
"lastName": "orellana", | ||
"age": 24, | ||
"identityCard": "123456789", | ||
"email": "luis@mail.com", | ||
"password": "12345" | ||
} | ||
``` | ||
|
||
Luego, en el microservicio **auth** se debe ingresar el email y password, creado con anterioridad para poder | ||
generar el token de acceso, que tendrá un tiempo de validez de 30 minutos (se puede modificar el tiempo de expiración) para poder interactuar con todos los controladores. | ||
```xml | ||
{ | ||
"email":"luis@mail.com", | ||
"password":"12345" | ||
} | ||
``` | ||
|
||
## Diagrama de clases | ||
|
||
### Microservicio User | ||
|
||
![user](https://raw.github.com/davidorellana98/booking-system-rest-api-spring-boot/main/src/main/resources/images/user.png "user") | ||
|
||
### Microservicio Booking | ||
|
||
![booking](https://raw.github.com/davidorellana98/booking-system-rest-api-spring-boot/main/src/main/resources/images/booking.png "booking") | ||
|
||
### Microservicio Authenticación | ||
|
||
![auth](https://raw.github.com/davidorellana98/booking-system-rest-api-spring-boot/main/src/main/resources/images/auth.png "auth") |
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
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
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
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
58 changes: 58 additions & 0 deletions
58
src/main/java/com/davidorellana/bookingsystemrestapi/swagger/SwaggerConfiguration.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,58 @@ | ||
package com.davidorellana.bookingsystemrestapi.swagger; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.http.HttpHeaders; | ||
import springfox.documentation.builders.PathSelectors; | ||
import springfox.documentation.builders.RequestHandlerSelectors; | ||
import springfox.documentation.service.*; | ||
import springfox.documentation.spi.DocumentationType; | ||
import springfox.documentation.spi.service.contexts.SecurityContext; | ||
import springfox.documentation.spring.web.plugins.Docket; | ||
import springfox.documentation.swagger2.annotations.EnableSwagger2; | ||
|
||
import java.util.Arrays; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
@Configuration | ||
@EnableSwagger2 | ||
public class SwaggerConfiguration { | ||
|
||
private ApiKey apiKey() { | ||
return new ApiKey("JWT", HttpHeaders.AUTHORIZATION, "header"); | ||
} | ||
|
||
private List<SecurityReference> defaultAuth() { | ||
AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything"); | ||
AuthorizationScope[] authorizationScopes = new AuthorizationScope[1]; | ||
authorizationScopes[0] = authorizationScope; | ||
return Arrays.asList(new SecurityReference("JWT", authorizationScopes)); | ||
} | ||
|
||
private SecurityContext securityContext() { | ||
return SecurityContext.builder().securityReferences(defaultAuth()).build(); | ||
} | ||
|
||
@Bean | ||
public Docket api() { | ||
return new Docket(DocumentationType.SWAGGER_2) | ||
.apiInfo(apiInfo()) | ||
.securityContexts(Arrays.asList(securityContext())) | ||
.securitySchemes(Arrays.asList(apiKey())) | ||
.select() | ||
.apis(RequestHandlerSelectors.basePackage("com.davidorellana.bookingsystemrestapi")) | ||
.paths(PathSelectors.any()) | ||
.build(); | ||
} | ||
|
||
private ApiInfo apiInfo() { | ||
return new ApiInfo( | ||
"Documentation - Integrator Project: Booking System Rest Api", | ||
"Booking System Rest Api Project: Implementation of User, Booking and Authentication microservices, with implementation to a NoSql MongoDB database, JWT and Security database, Unit Test.", | ||
"v1.0.0", | ||
"", | ||
new Contact("Luis David Orellana", "https://www.linkedin.com/in/luisdavidorellana/", ""), | ||
"Apache 2.0", "https://www.apache.org/licenses/LICENSE-2.0.html", Collections.emptyList()); | ||
} | ||
} |
Oops, something went wrong.