Skip to content

Commit 5836d20

Browse files
committed
docs: improve swagger docs
1 parent f6c9de9 commit 5836d20

File tree

10 files changed

+62
-60
lines changed

10 files changed

+62
-60
lines changed

techchallenge/src/main/java/br/com/grupo63/techchallenge/adapter/in/controller/client/ClientController.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,50 +26,50 @@ public class ClientController extends AbstractController {
2626
private final IClientUseCase useCase;
2727

2828
@Operation(
29-
summary = "Find a client by their national id",
30-
description = "Get client data by their national id.")
29+
summary = "Recuperar cliente por CPF",
30+
description = "Exibe os dados de um cliente a partir de seu CPF")
3131
@GetMapping("/cpf/{nationalId}")
3232
public ClientDTO findByNationalId(@PathVariable String nationalId) throws NotFoundException {
3333
return useCase.getByNationalId(nationalId);
3434
}
3535

3636
@Operation(
37-
tags = "1ª chamada - fluxo principal",
37+
tags = "1ª chamada - Fluxo principal - Pedido",
3838
summary = "Identificação: Identifica um cliente",
39-
description = "Registra um cliente com seu CPF")
39+
description = "Registra um cliente através de seu CPF")
4040
@PostMapping("/criar")
4141
public ResponseEntity<ClientDTO> create(@RequestParam String nationalId) throws NotFoundException {
4242
ClientDTO clientDTO = new ClientDTO(nationalId);
4343
return ResponseEntity.ok(useCase.create(clientDTO));
4444
}
4545

4646
@Operation(
47-
summary = "Get a client by it's id",
48-
description = "Find a client by their id.")
47+
summary = "Recuperar cliente",
48+
description = "Exibe os dados de um produto a partir de seu id")
4949
@GetMapping("/{id}")
5050
public ResponseEntity<ClientDTO> read(@PathVariable("id") Long id) throws NotFoundException {
5151
return ResponseEntity.ok(useCase.read(id));
5252
}
5353

5454
@Operation(
55-
summary = "List all clients",
56-
description = "List all clients.")
55+
summary = "Listar clientes",
56+
description = "Lista todos os clientes")
5757
@GetMapping("/listar")
5858
public ResponseEntity<List<ClientDTO>> list() {
5959
return ResponseEntity.ok(useCase.list());
6060
}
6161

6262
@Operation(
63-
summary = "Update a client",
64-
description = "Update a client in the database with the DTO data.")
63+
summary = "Atualizar cliente",
64+
description = "Atualiza um cliente por id com os dados enviados")
6565
@PutMapping("/{id}")
6666
public ResponseEntity<ClientDTO> update(@RequestBody ClientDTO dto, @PathVariable("id") Long id) throws NotFoundException {
6767
return ResponseEntity.ok(useCase.update(dto, id));
6868
}
6969

7070
@Operation(
71-
summary = "Delete a client",
72-
description = "Delete a client in the database by their id.")
71+
summary = "Excluir cliente",
72+
description = "Exclui um cliente por id")
7373
@DeleteMapping("/{id}")
7474
public ResponseEntity<DefaultResponseDTO> delete(@PathVariable("id") Long id) throws NotFoundException {
7575
useCase.delete(id);

techchallenge/src/main/java/br/com/grupo63/techchallenge/adapter/in/controller/order/OrderController.java

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import io.swagger.v3.oas.annotations.Operation;
1313
import io.swagger.v3.oas.annotations.Parameter;
1414
import io.swagger.v3.oas.annotations.tags.Tag;
15+
import jakarta.validation.Valid;
1516
import lombok.RequiredArgsConstructor;
1617
import org.springframework.http.HttpStatus;
1718
import org.springframework.http.ResponseEntity;
@@ -28,25 +29,25 @@ public class OrderController extends AbstractController {
2829
private final IOrderUseCase useCase;
2930

3031
@Operation(
31-
tags = "5ª chamada - fluxo principal",
32-
summary = "Listar pedidos pagos porém não finalizados.",
33-
description = "Seria utilizado pelo monitor no restaurante para exibir os pedidos em preparação e prontos")
32+
tags = "5ª chamada - Fluxo principal - Acompanhamento e entrega",
33+
summary = "Listar pedidos pagos porém não finalizados",
34+
description = "Seria utilizado para acompanha os pedido Recebidos, Em preparação e Prontos")
3435
@GetMapping("/listar-fila")
3536
public ResponseEntity<List<OrderDTO>> listUnfinishedOrders() {
3637
return ResponseEntity.ok(useCase.listUnfinishedOrders());
3738
}
3839

3940
@Operation(
40-
tags = "5ª chamada - fluxo principal",
41-
summary = "Avançar com o status do pedido.",
41+
tags = "5ª chamada - Fluxo principal - Acompanhamento e entrega",
42+
summary = "Avança com o status do pedido",
4243
description = "Após o pedido ser recebido, esse endpoint seria utilizado pelo funcionário para avançar o status do pedido")
4344
@PostMapping("/avancar-status")
4445
public AdvanceOrderStatusResponseDTO advanceOrderStatusFromOrderId(@Parameter(description = "Id do pedido.") @RequestParam Long orderId) throws NotFoundException, ValidationException {
4546
return new AdvanceOrderStatusResponseDTO(useCase.advanceStatus(orderId));
4647
}
4748

4849
@Operation(
49-
tags = "2ª chamada - fluxo principal",
50+
tags = "2ª chamada - Fluxo principal - Pedido",
5051
summary = "Fake checkout: Tela de resumo do pedido",
5152
description = "Registra um pedido a ser realizado, retorna o valor total")
5253
@PostMapping("/criar")
@@ -57,33 +58,33 @@ public ResponseEntity<OrderDTO> create(@RequestParam Long clientId,
5758
}
5859

5960
@Operation(
60-
tags = { "3ª chamada - fluxo principal", "5ª chamada - fluxo principal" },
61-
summary = "Get a order by it's id",
62-
description = "Find a order by their id.")
61+
tags = { "3ª chamada - Fluxo principal - Pagamento", "5ª chamada - Fluxo principal - Acompanhamento e entrega" },
62+
summary = "Recupera pedido",
63+
description = "Exibe os dados de um pedido a partir de seu id")
6364
@GetMapping("/{id}")
6465
public ResponseEntity<OrderDTO> read(@PathVariable("id") Long id) throws NotFoundException {
6566
return ResponseEntity.ok(useCase.read(id));
6667
}
6768

6869
@Operation(
69-
summary = "List all order",
70-
description = "List all orders.")
70+
summary = "Listar pedidos",
71+
description = "Lista todos os pedidos")
7172
@GetMapping("/listar")
7273
public ResponseEntity<List<OrderDTO>> list() {
7374
return ResponseEntity.ok(useCase.list());
7475
}
7576

76-
@Operation(
77-
summary = "Update an order",
78-
description = "Update an order in the database with the DTO data.")
77+
// @Operation(
78+
// summary = "Atualizar pedido",
79+
// description = "Atualiza um pedido por id com os dados enviados")
7980
// @PutMapping("/{id}")
80-
public ResponseEntity<OrderDTO> update(@RequestBody OrderDTO dto, @PathVariable("id") Long id) throws NotFoundException {
81-
return ResponseEntity.ok(useCase.update(dto, id));
82-
}
81+
// public ResponseEntity<OrderDTO> update(@RequestBody OrderDTO dto, @PathVariable("id") Long id) throws NotFoundException {
82+
// return ResponseEntity.ok(useCase.update(dto, id));
83+
// }
8384

8485
@Operation(
85-
summary = "Delete a client",
86-
description = "Delete a client in the database by their id.")
86+
summary = "Excluir cliente",
87+
description = "Exclui um cliente por id")
8788
@DeleteMapping("/{id}")
8889
public ResponseEntity<DefaultResponseDTO> delete(@PathVariable("id") Long id) throws NotFoundException {
8990
useCase.delete(id);

techchallenge/src/main/java/br/com/grupo63/techchallenge/adapter/in/controller/payment/PaymentController.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public class PaymentController extends AbstractController {
2323
private final IPaymentUseCase useCase;
2424

2525
@Operation(
26-
tags = "3ª chamada - fluxo principal",
26+
tags = "3ª chamada - Fluxo principal - Pagamento",
2727
summary = "Fake checkout: Confirma pedido",
2828
description = "Registra um pedido e o associa a um pedido. Retorna o QRCode gerado via Mercado Pago para exibição ao cliente.")
2929
@PostMapping("/iniciar")
@@ -35,7 +35,7 @@ public QRCodeResponseDTO startPayment(
3535
}
3636

3737
@Operation(
38-
tags = "4ª chamada - fluxo principal",
38+
tags = "4ª chamada - Fluxo principal - Pagamento",
3939
summary = "Fake checkout: Finalizar pagamento",
4040
description = "Atualiza o status do pagamento e do pedido. Seria utilizado pelo sistema externo Mercado Pago para simular uma integração de Webhook IPN para notificar o sistema que o pagamento foi concluido.")
4141
@PostMapping("/finalizar")
@@ -46,7 +46,7 @@ public void confirmPaymentFromOrderId(@Parameter(description = "Id do pedido ass
4646
}
4747

4848
@Operation(
49-
tags = "4ª chamada - fluxo principal",
49+
tags = "4ª chamada - Fluxo principal - Pagamento",
5050
summary = "Recuperar status do pagamento",
5151
description = "Recupera o status atual do pagamento. Seria utilizado na tela de pagamento do cliente para verificar se o pagamento foi realizado.")
5252
@GetMapping("/status")

techchallenge/src/main/java/br/com/grupo63/techchallenge/adapter/in/controller/product/ProductController.java

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,17 @@ public class ProductController extends AbstractController {
2424

2525
private final IProductUseCase useCase;
2626

27+
@Operation(
28+
tags = "2ª chamada - Fluxo principal - Pedido",
29+
summary = "Listar produtos por categoria",
30+
description = "Lista todos os produtos por nome da categoria")
31+
@GetMapping("/listar-por-categoria")
32+
public ResponseEntity<List<ProductDTO>> listByCategoryName(
33+
@Schema(allowableValues = {"Lanche", "Acompanhamento", "Bebida", "Sobremesa"})
34+
@RequestParam(value = "categoria") String categoryName) {
35+
return ResponseEntity.ok(useCase.listByCategoryName(categoryName));
36+
}
37+
2738
@Operation(
2839
summary = "Criar um produto",
2940
description = "Cria um produto com nome, preço, estoque inicial e categoria. Possíveis categorias (IDs): " +
@@ -34,45 +45,35 @@ public ResponseEntity<ProductDTO> create(@Valid @RequestBody ProductDTO dto) thr
3445
}
3546

3647
@Operation(
37-
summary = "Get a product by it's id",
38-
description = "Find a product by their id.")
48+
summary = "Recuperar produto",
49+
description = "Exibe os dados de um produto a partir de seu id")
3950
@GetMapping("/{id}")
4051
public ResponseEntity<ProductDTO> read(@PathVariable("id") Long id) throws NotFoundException {
4152
return ResponseEntity.ok(useCase.read(id));
4253
}
4354

4455
@Operation(
45-
summary = "List all products",
46-
description = "List all products.")
56+
summary = "Listar produtos",
57+
description = "Lista todos os produtos")
4758
@GetMapping("/listar")
4859
public ResponseEntity<List<ProductDTO>> list() {
4960
return ResponseEntity.ok(useCase.list());
5061
}
5162

5263
@Operation(
53-
summary = "Update a product",
54-
description = "Update a product in the database with the DTO data.")
64+
summary = "Atualizar produto",
65+
description = "Atualiza um produto por id com os dados enviados")
5566
@PutMapping("/{id}")
5667
public ResponseEntity<ProductDTO> update(@RequestBody ProductDTO dto, @PathVariable("id") Long id) throws NotFoundException {
5768
return ResponseEntity.ok(useCase.update(dto, id));
5869
}
5970

6071
@Operation(
61-
summary = "Delete a product",
62-
description = "Delete a product in the database by their id.")
72+
summary = "Excluir produto",
73+
description = "Exclui um produto por id")
6374
@DeleteMapping("/{id}")
6475
public ResponseEntity<DefaultResponseDTO> delete(@PathVariable("id") Long id) throws NotFoundException {
6576
useCase.delete(id);
6677
return ResponseEntity.ok().build();
6778
}
68-
69-
@Operation(
70-
summary = "Listar produtos por categoria",
71-
description = "Lista todos os produtos por nome da categoria")
72-
@GetMapping("/listar-por-categoria")
73-
public ResponseEntity<List<ProductDTO>> listByCategoryName(
74-
@Schema(allowableValues = {"Lanche", "Acompanhamento", "Bebida", "Sobremesa"})
75-
@RequestParam(value = "categoria") String categoryName) {
76-
return ResponseEntity.ok(useCase.listByCategoryName(categoryName));
77-
}
7879
}

techchallenge/src/main/java/br/com/grupo63/techchallenge/core/application/usecase/dto/OrderDTO.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import br.com.grupo63.techchallenge.core.domain.model.order.OrderStatus;
77
import br.com.grupo63.techchallenge.core.domain.model.payment.Payment;
88
import io.swagger.v3.oas.annotations.media.Schema;
9+
import jakarta.validation.constraints.NotNull;
910
import lombok.AllArgsConstructor;
1011
import lombok.Getter;
1112
import lombok.NoArgsConstructor;
@@ -28,6 +29,7 @@ public class OrderDTO extends AbstractUseCaseDomainDTO<Order> {
2829

2930
private ClientDTO client;
3031

32+
@NotNull
3133
private List<OrderItemDTO> items = new ArrayList<>();
3234

3335
private PaymentDTO payment;

techchallenge/src/main/java/br/com/grupo63/techchallenge/core/application/usecase/dto/PaymentDTO.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public class PaymentDTO extends AbstractUseCaseDomainDTO<Payment> {
2424
public static PaymentDTO toDto(Payment payment) {
2525
PaymentDTO paymentDTO = new PaymentDTO();
2626

27+
paymentDTO.setId(payment.getId());
2728
paymentDTO.setStatus(payment.getStatus());
2829
paymentDTO.setMethod(payment.getMethod());
2930
paymentDTO.setQrData(payment.getQrData());

techchallenge/src/main/java/br/com/grupo63/techchallenge/core/application/usecase/order/OrderUseCase.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import br.com.grupo63.techchallenge.core.domain.model.order.OrderItem;
1111
import br.com.grupo63.techchallenge.core.domain.model.order.OrderStatus;
1212
import br.com.grupo63.techchallenge.core.domain.model.payment.PaymentStatus;
13+
import jakarta.validation.Valid;
1314
import jakarta.validation.constraints.NotNull;
1415
import lombok.RequiredArgsConstructor;
1516
import org.springframework.stereotype.Service;
@@ -63,7 +64,7 @@ public List<OrderDTO> listUnfinishedOrders() {
6364
}
6465

6566
@Override
66-
public OrderDTO create(OrderDTO orderDTO) throws NotFoundException {
67+
public OrderDTO create(@Valid OrderDTO orderDTO) throws NotFoundException {
6768
Order order = new Order();
6869
orderDTO.fillDomain(order);
6970

techchallenge/src/main/java/br/com/grupo63/techchallenge/core/domain/model/order/OrderStatus.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
@AllArgsConstructor
66
public enum OrderStatus {
7-
RECEIVED("Recebido"), PREPARING("Em preparação"), READY("Pronto"), FINISHED("Finalizado");
8-
9-
private final String name;
7+
RECEIVED, PREPARING, READY, FINISHED;
108

119
}

techchallenge/src/main/java/br/com/grupo63/techchallenge/core/domain/model/payment/PaymentMethod.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
@AllArgsConstructor
66
public enum PaymentMethod {
7-
MERCADO_PAGO_QR_CODE("QR Code Mercado Pago");
7+
MERCADO_PAGO_QR_CODE
88

9-
private String name;
109
}

techchallenge/src/main/java/br/com/grupo63/techchallenge/core/domain/model/payment/PaymentStatus.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
@AllArgsConstructor
66
public enum PaymentStatus {
7-
PENDING("Pendente"), PAID("Pago");
7+
PENDING, PAID;
88

9-
private String name;
109
}

0 commit comments

Comments
 (0)