This command generates the API documentation in JSON format using API Platform’s documentation generator. It produces an OpenAPI specification (formerly known as Swagger) for PrestaShop’s REST API.
php bin/console prestashop:generate:apidoc
The command outputs the complete API documentation in JSON format to stdout. The generated documentation includes:
$ php bin/console prestashop:generate:apidoc > api-docs.json
This saves the API documentation to api-docs.json file.
The generated JSON follows the OpenAPI 3.1 specification and can be used with tools like:
Sample output structure:
{
"openapi": "3.1.0",
"info": {
"title": "Backoffice API",
"description": "",
"version": "0.1.0"
},
"servers": [
{
"url": "/admin-api",
"description": ""
}
],
"paths": {
"/addresses": {
"get": {
"operationId": "api_addresses_get_collection",
"tags": ["Address"],
"responses": {
"200": {
"description": "AddressList collection",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {"$ref": "#/components/schemas/AddressList"}
}
}
}
}
},
"summary": "Retrieves the collection of AddressList resources.",
"parameters": [
{
"name": "page",
"in": "query",
"description": "The collection page number",
"required": false
}
]
}
}
},
"components": {
"schemas": {},
"securitySchemes": {
"oauth": {
"type": "oauth2",
"flows": {}
}
}
},
"security": [{"oauth": []}],
"tags": [],
"webhooks": {}
}
The output is a single-line JSON (not pretty-printed). The structure includes all registered API endpoints under /admin-api.
View the generated documentation in Swagger UI:
php bin/console prestashop:generate:apidoc > public/api-docs.json
Then access it via Swagger UI at your API Platform documentation endpoint.
Use the generated documentation with OpenAPI Generator:
php bin/console prestashop:generate:apidoc > api-spec.json
openapi-generator-cli generate -i api-spec.json -g php -o ./api-client
DocumentationAction to generate the specification