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

Magento REST API Schema (Swagger) is not compatible with Search Criteria #7511

Closed
careys7 opened this issue Nov 21, 2016 · 6 comments
Closed
Labels
bug report Component: Framework/Webapi USE ONLY for FRAMEWORK RELATED BUG! E.g If bug related to Catalog WEB API use just Catalog Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development

Comments

@careys7
Copy link
Member

careys7 commented Nov 21, 2016

Preconditions

  1. Magento 2 CE or EE (all versions)

Steps to reproduce

  1. View Magento-generated Swagger Specification

Expected result

  1. Search criteria described in working format

Actual result

  1. HTTP 400 response from Magento when request sent in described format.

The Magento dev docs correctly describe REST API search criteria field groups and filters usage as needing an index per-field group / filter:

searchCriteria[filter_groups][<index>][filters][<index>][field=<field_name>]
searchCriteria[filter_groups][<index>][filters][<index>][value=<search_value>]
searchCriteria[filter_groups][<index>][filters][<index>][condition_type=<operator>]

When viewing the generated Swagger documentation, search criteria is described as follows (without a numerical index):

searchCriteria[filterGroups][][filters][][field]

Sending a request using searchCriteria in the format described by schema.json (without the numerical index) produces an HTTP 400 response. It also does not allow a user to define more than one filterGroup or filter, and breaks swagger-codegen clients.

The current searchCriteria implementation doesn't appear to be compatible with the Open API Specification in the current format.

@veloraven veloraven added 2.0.x bug report Component: Framework/Webapi USE ONLY for FRAMEWORK RELATED BUG! E.g If bug related to Catalog WEB API use just Catalog labels Nov 23, 2016
@olysenko olysenko self-assigned this Nov 23, 2016
@olysenko
Copy link

olysenko commented Nov 23, 2016

Hi @careysizer , thank you for your report. Internal ticket was created DDOC-11

@olysenko olysenko added Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development and removed in progress labels Nov 23, 2016
@olysenko olysenko removed their assignment Nov 23, 2016
@careys7
Copy link
Member Author

careys7 commented Nov 23, 2016

Thanks @olysenko -

I've just updated the issue to be clear that the input described in the devdocs description is correct in terms of the input that Magento expects, and it is the Swagger schema produced by Magento/Webapi/Model/Rest/Swagger/Generator.php that is not.

@konstantinblaesi
Copy link

What's the current status? Is anyone working on fixing the search interface using swagger/swagger-codegen?

@springimport
Copy link

You can use my extension with fix for searchcriteria

"springimport/swagger-magento2-client": "dev-fix-searchcriteria-index"

@magento-engcom-team magento-engcom-team added 2.0.x Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development bug report Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Component: Framework/Webapi USE ONLY for FRAMEWORK RELATED BUG! E.g If bug related to Catalog WEB API use just Catalog labels Sep 11, 2017
@magento-engcom-team magento-engcom-team added the Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed label Oct 13, 2017
@magento-engcom-team
Copy link
Contributor

@careys7, thank you for your report.
We were not able to reproduce this issue by following the steps you provided. If you'd like to update it, please reopen the issue.
We tested the issue on 2.3.0-dev, 2.2.0, 2.1.9

@careys7
Copy link
Member Author

careys7 commented Oct 15, 2017

Thanks @magento-engcom-team . This is still an issue so have reopened #11477 with more comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Component: Framework/Webapi USE ONLY for FRAMEWORK RELATED BUG! E.g If bug related to Catalog WEB API use just Catalog Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development
Projects
None yet
Development

No branches or pull requests

6 participants