Skip to content

Commit

Permalink
refactor #420 Unify product routing (mamazu)
Browse files Browse the repository at this point in the history
This PR was merged into the 1.0-dev branch.

Discussion
----------

Closes #185 

Commits
-------

f10503b Adding new routes
728e41a Adding the new docs
c2599c3 Added redirect for deprecated route
bc2037d Fixing the generated routes in test
5f557a5 Fixing redirect
3d06a4d Removing the old routes and fixing the tests
28cdbb2 Adding the upgrade docs
4badec1 Fixing formatting of the upgrade.md
c7a5baf Fixing documentation issues
  • Loading branch information
lchrusciel authored Apr 10, 2019
2 parents fe33fb7 + c7a5baf commit c486038
Show file tree
Hide file tree
Showing 53 changed files with 441 additions and 168 deletions.
11 changes: 11 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@
* The commands are now dispatched using `dispatch()` method instead of `handle()`
* The method name in handlers has been changed from `handle()` to `__invoke()`

The product routes have been moved:

| Old Route | New route |
|:--------------------------------------|:-------------------------------------|
| `products/{code}` | `products/by-code/{code}` |
| `products-by-slug/{slug}` | `products/by-slug/{slug}` |
| `products/{code}/reviews` | `products/by-code/{code}/reviews` |
| `products-reviews-by-slug/{slug}` | `products/by-slug/{slug}/reviews` |
| `taxon-products/{code}` | `taxon-products/by-code/{code}` |
| `taxon-products-by-slug/{taxonSlug}` | `taxon-products/by-slug/{taxonSlug}` |

# UPGRADE FROM 1.0.0-beta.17 to 1.0.0-beta.18

* Customer registration payload changed:
Expand Down
218 changes: 211 additions & 7 deletions doc/swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ paths:
security:
- {}
- bearerAuth: []
/{channelCode}/taxon-products-by-slug/{slug}:
/{channelCode}/taxon-products/by-slug/{taxonSlug}:
parameters:
- $ref: "#/parameters/ChannelCode"
get:
Expand All @@ -462,7 +462,7 @@ paths:
description: "This endpoint will return a paginated list of products for given taxon."
operationId: "productCatalogBySlug"
parameters:
- name: "slug"
- name: "taxonSlug"
in: "path"
description: "Slug of taxonomy for which products should be listed."
required: true
Expand All @@ -487,7 +487,43 @@ paths:
description: "Paginated product list."
schema:
$ref: "#/definitions/ProductsPage"
/{channelCode}/taxon-products/{code}:
/{channelCode}/taxon-products-by-slug/{taxonSlug}:
parameters:
- $ref: "#/parameters/ChannelCode"
get:
deprecated: true
tags:
- "products"
summary: "Show product catalog."
description: "This endpoint will return a paginated list of products for given taxon."
operationId: "productCatalogBySlug_deprecated"
parameters:
- name: "taxonSlug"
in: "path"
description: "Slug of taxonomy for which products should be listed."
required: true
type: "string"
- name: "locale"
in: "query"
description: "Locale in which products should be shown."
required: false
type: "string"
- name: "limit"
in: "query"
description: "Number of expected products per page."
required: false
type: "integer"
- name: "page"
in: "query"
description: "Page number."
required: false
type: "integer"
responses:
200:
description: "Paginated product list."
schema:
$ref: "#/definitions/ProductsPage"
/{channelCode}/taxon-products/by-code/{code}:
parameters:
- $ref: "#/parameters/ChannelCode"
get:
Expand Down Expand Up @@ -522,7 +558,43 @@ paths:
description: "Paginated product list."
schema:
$ref: "#/definitions/ProductsPage"
/{channelCode}/products-by-slug/{slug}:
/{channelCode}/taxon-products/{code}:
parameters:
- $ref: "#/parameters/ChannelCode"
get:
deprecated: true
tags:
- "products"
summary: "Show product catalog."
description: "This endpoint will return a paginated list of products for given taxon."
operationId: "productCatalog_deprecated"
parameters:
- name: "code"
in: "path"
description: "Code of taxonomy for which products should be listed."
required: true
type: "string"
- name: "locale"
in: "query"
description: "Locale in which products should be shown."
required: false
type: "string"
- name: "limit"
in: "query"
description: "Number of expected products per page."
required: false
type: "integer"
- name: "page"
in: "query"
description: "Page number."
required: false
type: "integer"
responses:
200:
description: "Paginated product list."
schema:
$ref: "#/definitions/ProductsPage"
/{channelCode}/products/by-slug/{slug}:
parameters:
- $ref: "#/parameters/ChannelCode"
get:
Expand All @@ -547,7 +619,33 @@ paths:
description: "Show a product with the given slug."
schema:
$ref: "#/definitions/ProductDetails"
/{channelCode}/products/{code}:
/{channelCode}/products-by-slug/{slug}:
parameters:
- $ref: "#/parameters/ChannelCode"
get:
deprecated: true
tags:
- "products"
summary: "Show a product with the given slug."
description: "This endpoint will return a product with the given slug."
operationId: "productDetailsBySlug_deprecated"
parameters:
- name: "slug"
in: "path"
description: "Slug of expected product."
required: true
type: "string"
- name: "locale"
in: "query"
description: "Locale in which products should be shown."
required: false
type: "string"
responses:
200:
description: "Show a product with the given slug."
schema:
$ref: "#/definitions/ProductDetails"
/{channelCode}/products/by-code/{code}:
parameters:
- $ref: "#/parameters/ChannelCode"
get:
Expand All @@ -572,7 +670,33 @@ paths:
description: "Show a product with the given code."
schema:
$ref: "#/definitions/ProductDetails"
/{channelCode}/product-reviews-by-slug/{slug}:
/{channelCode}/products/{code}:
parameters:
- $ref: "#/parameters/ChannelCode"
get:
deprecated: true
tags:
- "products"
summary: "Show a product with the given code."
description: "This endpoint will return a product with the given code."
operationId: "productDetails_deprecated"
parameters:
- name: "code"
in: "path"
description: "Code of expected product."
required: true
type: "string"
- name: "locale"
in: "query"
description: "Locale in which products should be shown."
required: false
type: "string"
responses:
200:
description: "Show a product with the given code."
schema:
$ref: "#/definitions/ProductDetails"
/{channelCode}/product/by-slug/{slug}/reviews:
parameters:
- $ref: "#/parameters/ChannelCode"
- name: "slug"
Expand Down Expand Up @@ -610,7 +734,47 @@ paths:
description: "A paginated list of all reviews related to the product identified by slug."
schema:
$ref: "#/definitions/ProductReviewsPage"
/{channelCode}/product/{code}/reviews:
/{channelCode}/product-reviews-by-slug/{slug}:
parameters:
- $ref: "#/parameters/ChannelCode"
- name: "slug"
in: "path"
description: "Slug of expected product."
required: true
type: "string"
post:
deprecated: true
tags:
- "products"
summary: "Add a review to the product."
description: "This endpoint will allow you to add a new review to the product. Remember, that it should be accepted by an administrator before it will be available in the review list."
operationId: "productAddReviewBySlug_deprecated"
parameters:
- in: "body"
name: "content"
required: true
schema:
$ref: "#/definitions/AddReviewRequest"
responses:
201:
description: "Review has been added to the product."
400:
description: "Invalid input, validation failed."
schema:
$ref: "#/definitions/GeneralError"
get:
deprecated: true
tags:
- "products"
summary: "Show reviews."
description: "This endpoint will return a paginated list of all reviews related to the product identified by slug."
operationId: "productReviewsBySlug_deprecated"
responses:
200:
description: "A paginated list of all reviews related to the product identified by slug."
schema:
$ref: "#/definitions/ProductReviewsPage"
/{channelCode}/product/by-code/{code}/reviews:
parameters:
- $ref: "#/parameters/ChannelCode"
- name: "code"
Expand Down Expand Up @@ -648,6 +812,46 @@ paths:
description: "A paginated list of all reviews related to the product identified by slug."
schema:
$ref: "#/definitions/ProductReviewsPage"
/{channelCode}/product/{code}/reviews:
parameters:
- $ref: "#/parameters/ChannelCode"
- name: "code"
in: "path"
description: "Code of expected product."
required: true
type: "string"
post:
deprecated: true
tags:
- "products"
summary: "Add a review to the product."
description: "This endpoint will allow you to add a new review to the product. Remember, that it should be accepted by an administrator before it will be available in the review list."
operationId: "productAddReview_deprecated"
parameters:
- in: "body"
name: "content"
required: true
schema:
$ref: "#/definitions/AddReviewRequest"
responses:
201:
description: "Review has been added to the product."
400:
description: "Invalid input, validation failed."
schema:
$ref: "#/definitions/GeneralError"
get:
deprecated: true
tags:
- "products"
summary: "Show reviews."
description: "This endpoint will return a paginated list of all reviews related to the product identified by slug."
operationId: "productReviews_deprecated"
responses:
200:
description: "A paginated list of all reviews related to the product identified by slug."
schema:
$ref: "#/definitions/ProductReviewsPage"
/{channelCode}/taxons:
parameters:
- $ref: "#/parameters/ChannelCode"
Expand Down
33 changes: 29 additions & 4 deletions src/Resources/config/routing/productByCode.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,48 @@
sylius_shop_api_product_show_details_by_code:
sylius_shop_api_product_show_details_by_code_deprecated:
path: /products/{code}
methods: [GET]
defaults:
_controller: sylius.shop_api_plugin.controller.product.show_product_details_by_code_action

sylius_shop_api_product_show_catalog_by_code:
sylius_shop_api_product_show_catalog_by_code_deprecated:
path: /taxon-products/{code}
methods: [GET]
defaults:
_controller: sylius.shop_api_plugin.controller.product.show_product_catalog_by_taxon_code_action

sylius_shop_api_product_show_reviews_by_code:
sylius_shop_api_product_show_reviews_by_code_depricated:
path: /products/{code}/reviews
methods: [GET]
defaults:
_controller: sylius.shop_api_plugin.controller.product.show_product_reviews_by_code_action

sylius_shop_api_add_product_review_by_code:
sylius_shop_api_add_product_review_by_code_deprecated:
path: /products/{code}/reviews
methods: [POST]
defaults:
_controller: sylius.shop_api_plugin.controller.product.add_review_by_code_action

# New routes
sylius_shop_api_product_show_details_by_code:
path: /products/by-code/{code}
methods: [GET]
defaults:
_controller: sylius.shop_api_plugin.controller.product.show_product_details_by_code_action

sylius_shop_api_product_show_catalog_by_code:
path: /taxon-products/by-code/{code}
methods: [GET]
defaults:
_controller: sylius.shop_api_plugin.controller.product.show_product_catalog_by_taxon_code_action

sylius_shop_api_product_show_reviews_by_code:
path: /products/by-code/{code}/reviews
methods: [GET]
defaults:
_controller: sylius.shop_api_plugin.controller.product.show_product_reviews_by_code_action

sylius_shop_api_add_product_review_by_code:
path: /products/by-code/{code}/reviews
methods: [POST]
defaults:
_controller: sylius.shop_api_plugin.controller.product.add_review_by_code_action
Loading

0 comments on commit c486038

Please sign in to comment.