-
-
Notifications
You must be signed in to change notification settings - Fork 119
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
feature/IL-77/Add-OpenAPI-for-cart-package #100
feature/IL-77/Add-OpenAPI-for-cart-package #100
Conversation
@@ -30,14 +31,14 @@ | |||
@RequiredArgsConstructor | |||
@Validated | |||
@RequestMapping(value = CartEndpoint.CART_URL) | |||
public class CartEndpoint { | |||
public class CartEndpoint implements CartsApi { | |||
|
|||
public static final String CART_URL = "/api/v1/cart"; | |||
|
|||
private final CartApi cartApi; | |||
|
|||
@PostMapping(value = "/items") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need to @OverRide the method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are overrided automaticly, isn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using this annotation is like a best practice
it is really good idea to add it
@@ -57,7 +58,7 @@ public ResponseEntity<ShoppingSessionDto> getShoppingSession(@AuthenticationPrin | |||
} | |||
|
|||
@PatchMapping(value = "/items") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need to @OverRide the method
@@ -69,7 +70,7 @@ public ResponseEntity<ShoppingSessionDto> updateProductsQuantityInShoppingSessio | |||
} | |||
|
|||
@DeleteMapping(value = "/items") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need to @OverRide the method
@@ -0,0 +1,192 @@ | |||
openapi: "3.0.3" | |||
|
|||
info: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need to write in a common style as in Zufar's example in product-openapi.yaml
info:
title: "Online-Store API"
version: "1.0.0"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
schema: | ||
$ref: "#/components/schemas/ShoppingSessionDto" | ||
|
||
delete: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better to write path as in a common style
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed
|
||
public static final String CART_URL = "/api/v1/cart"; | ||
|
||
private final CartApi cartApi; | ||
|
||
@PostMapping(value = "/items") | ||
public ResponseEntity<ShoppingSessionDto> addNewItemToShoppingSession(@RequestBody @Valid final AddNewItemsToShoppingSessionRequest request) { | ||
public ResponseEntity<ShoppingSessionDto> addNewItemToShoppingSession(@RequestBody final AddNewItemsToShoppingSessionRequest request) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you delete ‘@Valid'?
Rollback it, please
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this annotation we have a trouble in case when we try to use our API not in IDE (i use Postman): Hibernate validator HV000151 "A method overriding another method must not alter the parameter constraint configuration").
In our generated interface we have the same annotation, its incorrect.
More info: https://forum.hibernate.org/viewtopic.php?p=2469903
@@ -30,14 +31,14 @@ | |||
@RequiredArgsConstructor | |||
@Validated | |||
@RequestMapping(value = CartEndpoint.CART_URL) | |||
public class CartEndpoint { | |||
public class CartEndpoint implements CartsApi { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CartApi sounds better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are already have CartApi in this class (import com.zufar.onlinestore.cart.api.CartApi). Is it ok to use same names?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, there is no problem
@@ -57,7 +58,7 @@ public ResponseEntity<ShoppingSessionDto> getShoppingSession(@AuthenticationPrin | |||
} | |||
|
|||
@PatchMapping(value = "/items") | |||
public ResponseEntity<ShoppingSessionDto> updateProductsQuantityInShoppingSessionItem(@RequestBody @Valid final UpdateProductsQuantityInShoppingSessionItemRequest request) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rollback ‘@Valid' annotation, please
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
@@ -69,7 +70,7 @@ public ResponseEntity<ShoppingSessionDto> updateProductsQuantityInShoppingSessio | |||
} | |||
|
|||
@DeleteMapping(value = "/items") | |||
public ResponseEntity<ShoppingSessionDto> deleteItemsFromShoppingSession(@RequestBody @Valid final DeleteItemsFromShoppingSessionRequest request) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rollback ‘@Valid' annotation, please
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
- url: "http://localhost:8083" | ||
|
||
tags: | ||
- name: "Carts" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cart is better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
Shamardin Vladislav
(will be updated after merge)
3.1 CartEndpoint was updated (implemented CartsApi, removed @Valid annotations from methods)
3.2 cart-openapi.yaml was added
3.3 pom.xml was updated
Import cart-openapi.yaml in Postman, after authorization all responses 200 OK
5.1 Project was built with Apache Maven successfully.
5.2 Project was tested manually with Postman successfully.