Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

T8S3-49 Agregar documentación con Swagger #6

Draft
wants to merge 5 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.0.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
Expand Down Expand Up @@ -60,6 +65,11 @@
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.0.2</version>
</dependency>
</dependencies>

<build>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/alkemy/wallet/WalletApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ public class WalletApplication {

public static void main(String[] args) {
SpringApplication.run(WalletApplication.class, args);
System.out.println("\u001B[32mSwagger-UI: http://localhost:8080/swagger-ui/index.html\u001B[0m");
}

}
49 changes: 49 additions & 0 deletions src/main/java/com/alkemy/wallet/apidoc/UserDoc.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.alkemy.wallet.apidoc;

import com.alkemy.wallet.model.User;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import org.springframework.http.ResponseEntity;

import java.util.List;

public interface UserDoc {

@Operation(
summary = "Fetch all users",
description = "Fetches all users entities and their data from data source")
@ApiResponses(value = {
@ApiResponse(
responseCode = "200",
content = @Content,
description = "Users found"
),
@ApiResponse(
responseCode = "204",
content = @Content,
description = "No content"
),
})
ResponseEntity<List<User>> get();


@Operation(
summary = "Deletes a user by id",
description = "Deletes a user by id from data source. It is a logical delete)")
@ApiResponses(value = {
@ApiResponse(
responseCode = "204",
content = @Content,
description = "User deleted"
),
@ApiResponse(
responseCode = "404",
content = @Content,
description = "User not found"
),
})
ResponseEntity<Void> delete(Long id);

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.alkemy.wallet.controller;

import com.alkemy.wallet.apidoc.UserDoc;
import com.alkemy.wallet.model.User;
import com.alkemy.wallet.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -14,7 +15,7 @@
@RestController
@Validated
@RequestMapping(value = "/users", produces = MediaType.APPLICATION_JSON_VALUE)
public class UserController {
public class UserController implements UserDoc {

@Autowired
private UserService userService;
Expand Down