magento2 - Getting expected object definitions from Magento 2 REST API -
when calling magento 2 rest api schema working products using:
..rest/all/schema?services=catalogproductrepositoryv1
the response includes:
... "paths": { "/v1/products": { "post": { "tags": [ "catalogproductrepositoryv1" ], "description": "create product", "operationid": "catalogproductrepositoryv1savepost", "parameters": [ { "name": "$body", "in": "body", "schema": { "required": [ "product" ], "properties": { "product": { "$ref": "#/definitions/catalog-data-product-interface" }, "saveoptions": { "type": "boolean" } }, "type": "object" } } ],...
how go getting definition/schema "product" object expects during post call? i.e. following definition:
"properties": { "product": { "$ref": "#/definitions/catalog-data-product-interface" },
looks possible using swagger gui. replicate these steps , change search term whatever you're searching for:
- go to: http://devdocs.magento.com/swagger/index.html
- ctrl + f >> search whatever you're after. in case of above: catalogproductrepositoryv1
- expand api interface clicking it
- choose rest method
- under "parameters" there model/model schema showing payload expects.
welcome swagger! it's great when know how use it!
Comments
Post a Comment