diff --git a/api/app/controllers/spree/api/option_values_controller.rb b/api/app/controllers/spree/api/option_values_controller.rb index 513c289e096..0feea2337e5 100644 --- a/api/app/controllers/spree/api/option_values_controller.rb +++ b/api/app/controllers/spree/api/option_values_controller.rb @@ -13,20 +13,11 @@ def index end def show - warn_if_nested_member_route - @option_value = scope.find(params[:id]) respond_with(@option_value) end def create - Spree::Deprecation.warn <<~MSG unless request.path.include?('/option_types/') - This route is deprecated, as it'll be no longer possible to create an - option_value without an associated option_type. Please, use instead: - - POST api/option_types/{option_type_id}/option_values - MSG - authorize! :create, Spree::OptionValue @option_value = scope.new(option_value_params) if @option_value.save @@ -37,8 +28,6 @@ def create end def update - warn_if_nested_member_route - @option_value = scope.accessible_by(current_ability, :update).find(params[:id]) if @option_value.update(option_value_params) render :show @@ -48,8 +37,6 @@ def update end def destroy - warn_if_nested_member_route - @option_value = scope.accessible_by(current_ability, :destroy).find(params[:id]) @option_value.destroy render plain: nil, status: 204 @@ -68,14 +55,6 @@ def scope def option_value_params params.require(:option_value).permit(permitted_option_value_attributes) end - - def warn_if_nested_member_route - Spree::Deprecation.warn <<~MSG if request.path.include?('/option_types/') - This route is deprecated. Use shallow version instead: - - #{request.method.upcase} api/option_values/:id - MSG - end end end end diff --git a/api/config/routes.rb b/api/config/routes.rb index 230ec5d724e..c90b6ba4ff0 100644 --- a/api/config/routes.rb +++ b/api/config/routes.rb @@ -54,12 +54,9 @@ end resources :option_types do - # TODO: Use shallow option on Solidus v4.0 - resources :option_values + resources :option_values, shallow: true end - # TODO: Use only: :index on Solidus v4.0 and use shallow option on the nested routes - # within option_types - resources :option_values + resources :option_values, only: :index get '/orders/mine', to: 'orders#mine', as: 'my_orders' get "/orders/current", to: "orders#current", as: "current_order" diff --git a/api/openapi/solidus-api.oas.yml b/api/openapi/solidus-api.oas.yml index 51717a04ef8..f89e127dc99 100644 --- a/api/openapi/solidus-api.oas.yml +++ b/api/openapi/solidus-api.oas.yml @@ -2541,38 +2541,6 @@ paths: - Option values security: - api-key: [] - post: - responses: - '200': - description: '' - content: - application/json: - schema: - $ref: '#/components/schemas/option-value' - '401': - $ref: '#/components/responses/invalid-api-key' - '422': - $ref: '#/components/responses/unprocessable-entity' - summary: Create option value - description: |- - **Deprecation Warning**: Use [nested version](/docs/solidus/810154673c613-create-option-type-value) instead - - Creates an option value. - - Only users with the `create` permission on `Spree::OptionValue` can perform this action. - operationId: create-option-value - tags: - - Option values - security: - - api-key: [] - requestBody: - content: - application/json: - schema: - type: object - properties: - option_value: - $ref: '#/components/schemas/option-value-input' '/option_values/{id}': get: responses: @@ -2715,99 +2683,6 @@ paths: properties: option_value: $ref: '#/components/schemas/option-value-input' - '/option_types/{option_type_id}/option_values/{id}': - get: - responses: - '200': - description: '' - content: - application/json: - schema: {} - '401': - $ref: '#/components/responses/invalid-api-key' - '404': - $ref: '#/components/responses/not-found' - summary: Get option type value - description: |- - **Deprecation Warning**: Use [shallow version](/docs/solidus/cbbc403ed08a3-get-option-value) instead - - Retrieves an option type's value. - operationId: get-option-type-value - tags: - - Option values - security: - - api-key: [] - parameters: - - name: option_type_id - in: path - required: true - schema: - type: string - description: 'The ID of the Spree::OptionType' - - name: id - in: path - required: true - schema: - type: string - description: The ID of the OptionValue - delete: - responses: - '204': - description: '' - content: - application/json: - schema: - $ref: '#/components/schemas/option-value' - '401': - $ref: '#/components/responses/invalid-api-key' - '404': - $ref: '#/components/responses/not-found' - '422': - $ref: '#/components/responses/delete-restriction' - summary: Delete option type value - description: |- - **Deprecation Warning**: Use [shallow version](/docs/solidus/0742e63219b1f-delete-option-value) instead - - Deletes an option type's value. - operationId: delete-option-type-value - tags: - - Option values - security: - - api-key: [] - patch: - responses: - '200': - description: '' - content: - application/json: - schema: - $ref: '#/components/schemas/option-value' - '401': - $ref: '#/components/responses/invalid-api-key' - '404': - $ref: '#/components/responses/not-found' - '422': - $ref: '#/components/responses/unprocessable-entity' - summary: Update option type value - description: |- - **Deprecation Warning**: Use [shallow version](/docs/solidus/b43f889175ebb-update-option-value) instead - - Updates an option type's value. - - Only users with the `update` permission on the option value can perform this action. - operationId: update-option-type-value - tags: - - Option values - security: - - api-key: [] - requestBody: - content: - application/json: - schema: - type: object - properties: - option_value: - $ref: '#/components/schemas/option-value-input' '/products/{product_id}/product_properties': get: responses: diff --git a/api/spec/requests/spree/api/option_values_spec.rb b/api/spec/requests/spree/api/option_values_spec.rb index 39b095fcab4..aeb0d60a1ec 100644 --- a/api/spec/requests/spree/api/option_values_spec.rb +++ b/api/spec/requests/spree/api/option_values_spec.rb @@ -53,12 +53,6 @@ module Spree::Api expect(json_response).to have_attributes(attributes) end - it "deprecates listing a single option value through a nested route" do - expect(Spree::Deprecation).to receive(:warn).with(%r[deprecated.*GET api/option_values/:id]m) - - get spree.api_option_type_option_value_path(option_type, option_value) - end - it "cannot create a new option value" do post spree.api_option_type_option_values_path(option_type), params: { option_value: { @@ -116,26 +110,6 @@ module Spree::Api expect(option_value.name).to eq("Option Value") end - it "deprecates updating an option value through a nested route" do - expect(Spree::Deprecation).to receive(:warn).with(%r[deprecated.*PUT api/option_values/:id]m) - - put spree.api_option_type_option_value_path(option_type, option_value), params: { option_value: { - name: "Option Value" - } } - end - - it "can create but deprecates creating an option value without option type" do - expect(Spree::Deprecation).to receive(:warn).with(/deprecated/).at_least(:once) - - post spree.api_option_values_path, params: { option_value: { - name: "Option Value", - presentation: 'option value' - } } - expect(response.status).to eq(201) - - expect(json_response).to have_attributes(attributes) - end - it "permits the correct attributes" do expect_any_instance_of(Spree::Api::OptionValuesController).to receive(:permitted_option_value_attributes) put spree.api_option_value_path(option_value), params: { option_value: { name: "" } } @@ -152,12 +126,6 @@ module Spree::Api delete spree.api_option_value_path(option_value) expect(response.status).to eq(204) end - - it "deprecates deleting an option value through a nested route" do - expect(Spree::Deprecation).to receive(:warn).with(%r[deprecated.*DELETE api/option_values/:id]m) - - delete spree.api_option_type_option_value_path(option_type, option_value) - end end end end