laminas-api-tools / api-tools-documentation
Laminas API Tools API documentation module
Fund package maintenance!
Community Bridge
Installs: 713 384
Dependents: 6
Suggesters: 0
Security: 0
Stars: 6
Watchers: 10
Forks: 15
Open Issues: 16
Requires
- php: ~8.0.0 || ~8.1.0 || ~8.2.0
- laminas-api-tools/api-tools-configuration: ^1.6
- laminas-api-tools/api-tools-content-negotiation: ^1.8
- laminas-api-tools/api-tools-provider: ^1.6
- laminas/laminas-inputfilter: ^2.13
- laminas/laminas-modulemanager: ^2.11
- laminas/laminas-mvc: ^3.3
- laminas/laminas-servicemanager: ^3.8
- laminas/laminas-view: ^2.13
- michelf/php-markdown: ^1.5
Requires (Dev)
- laminas/laminas-coding-standard: ~2.3.0
- laminas/laminas-db: ^2.13.4
- laminas/laminas-stdlib: ^3.6.4
- phpunit/phpunit: ^9.5.10
- psalm/plugin-phpunit: ^0.16.0
- vimeo/psalm: ^4.7
- webmozart/assert: ^1.10
Conflicts
README
π·πΊ Π ΡΡΡΠΊΠΈΠΌ Π³ΡΠ°ΠΆΠ΄Π°Π½Π°ΠΌ
ΠΡ, ΡΡΠ°ΡΡΠ½ΠΈΠΊΠΈ Laminas, ΡΠΎΠ΄ΠΈΠ»ΠΈΡΡ ΠΈ ΠΆΠΈΠ²Π΅ΠΌ Π² ΡΠ°Π·Π½ΡΡ ΡΡΡΠ°Π½Π°Ρ . Π£ ΠΌΠ½ΠΎΠ³ΠΈΡ ΠΈΠ· Π½Π°Ρ Π΅ΡΡΡ Π΄ΡΡΠ·ΡΡ, ΡΠΎΠ΄ΡΡΠ²Π΅Π½Π½ΠΈΠΊΠΈ ΠΈ ΠΊΠΎΠ»Π»Π΅Π³ΠΈ ΠΊΠ°ΠΊ Π² Π ΠΎΡΡΠΈΠΈ, ΡΠ°ΠΊ ΠΈ Π² Π£ΠΊΡΠ°ΠΈΠ½Π΅. ΠΠ΅ΠΊΠΎΡΠΎΡΡΠ΅ ΠΈΠ· Π½Π°Ρ ΡΠΎΠ΄ΠΈΠ»ΠΈΡΡ Π² Π ΠΎΡΡΠΈΠΈ. ΠΠ΅ΠΊΠΎΡΠΎΡΡΠ΅ ΠΈΠ· Π½Π°Ρ ΠΆΠΈΠ²ΡΡ Π² Π ΠΎΡΡΠΈΠΈ. Π£ Π½Π΅ΠΊΠΎΡΠΎΡΡΡ Π±Π°Π±ΡΡΠΊΠΈ ΠΈ Π΄Π΅Π΄ΡΡΠΊΠΈ ΡΡΠ°ΠΆΠ°Π»ΠΈΡΡ Ρ ΡΠ°ΡΠΈΡΡΠ°ΠΌΠΈ Π²ΠΎ ΠΡΠΎΡΠΎΠΉ ΠΌΠΈΡΠΎΠ²ΠΎΠΉ Π²ΠΎΠΉΠ½Π΅. ΠΠ΄Π΅ΡΡ Π½ΠΈΠΊΡΠΎ Π½Π΅ ΠΏΠΎΠ΄Π΄Π΅ΡΠΆΠΈΠ²Π°Π΅Ρ ΡΠ°ΡΠΈΠ·ΠΌ.
Π£ ΠΎΠ΄Π½ΠΎΠ³ΠΎ ΠΈΠ· Π½Π°Ρ Π΅ΡΡΡ ΡΠΊΡΠ°ΠΈΠ½ΡΠΊΠ°Ρ ΡΠΎΠ΄ΡΡΠ²Π΅Π½Π½ΠΈΡΠ°, ΠΊΠΎΡΠΎΡΠ°Ρ ΡΠΏΠ°ΡΠ»Π°ΡΡ ΠΈΠ· Π΄ΠΎΠΌΠ° Π²ΠΌΠ΅ΡΡΠ΅ Ρ ΡΡΠ½ΠΎΠΌ. ΠΠΎΠ΅Π·Π΄ Π·Π°Π΄Π΅ΡΠΆΠ°Π»ΡΡ ΠΈΠ·-Π·Π° Π±ΠΎΠΌΠ±Π΅ΠΆΠΊΠΈ Π½Π° Π΄ΠΎΡΠΎΠ³Π΅ Π²ΠΏΠ΅ΡΠ΅Π΄ΠΈ. Π£ Π½Π°Ρ Π΅ΡΡΡ Π΄ΡΡΠ·ΡΡ, ΠΊΠΎΡΠΎΡΡΠ΅ ΠΏΡΡΡΡΡΡΡ Π² Π±ΠΎΠΌΠ±ΠΎΡΠ±Π΅ΠΆΠΈΡΠ°Ρ . ΠΡ Ρ ΡΡΠ΅Π²ΠΎΠ³ΠΎΠΉ ΠΆΠ΄Π΅ΠΌ Π²Π΅ΡΡΠΎΡΠΊΠΈ ΠΎΡ Π½ΠΈΡ ΠΏΠΎΡΠ»Π΅ Π²ΠΎΠ·Π΄ΡΡΠ½ΡΡ Π½Π°Π»Π΅ΡΠΎΠ², ΠΊΠΎΡΠΎΡΡΠ΅ Π±Π΅ΡΠΏΠΎΡΡΠ΄ΠΎΡΠ½ΠΎ Π½Π°Π½ΠΎΡΡΡ ΡΠ΄Π°ΡΡ ΠΈ ΠΏΠΎΠΏΠ°Π΄Π°ΡΡ ΠΏΠΎ Π±ΠΎΠ»ΡΠ½ΠΈΡΠ°ΠΌ, ΡΠΊΠΎΠ»Π°ΠΌ, Π΄Π΅ΡΡΠΊΠΈΠΌ ΡΠ°Π΄Π°ΠΌ ΠΈ Π΄ΠΎΠΌΠ°ΠΌ. ΠΡ Π½Π΅ Π±Π΅ΡΠ΅ΠΌ ΡΡΠΎ ΠΈΠ· ΠΊΠ°ΠΊΠΈΡ -Π»ΠΈΠ±ΠΎ Π‘ΠΠ. ΠΡ Π½Π°Π±Π»ΡΠ΄Π°Π΅ΠΌ ΡΡΠΎ Π½Π°ΠΏΡΡΠΌΡΡ.
ΠΡ Π΄ΠΎΠ²Π΅ΡΡΠ΅ΡΠ΅ Π½Π°ΠΌ Π΄ΠΎΡΡΠ°ΡΠΎΡΠ½ΠΎ, ΡΡΠΎΠ± ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ Π½Π°ΡΠΈ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ, ΠΈ ΠΌΡ ΠΏΡΠΎΡΠΈΠΌ Π²Π°Ρ Π΄ΠΎΠ²Π΅ΡΠΈΡΡΡΡ Π½Π°ΠΌ Π²Π½ΠΎΠ²Ρ. ΠΡ Π½ΡΠΆΠ΄Π°Π΅ΠΌΡΡ Π² ΠΏΠΎΠΌΠΎΡΠΈ. ΠΡΡ ΠΎΠ΄ΠΈΡΠ΅ ΠΈ ΠΏΡΠΎΡΠ΅ΡΡΡΠΉΡΠ΅ ΠΏΡΠΎΡΠΈΠ² ΡΡΠΎΠΉ Π±Π΅ΡΠΏΠΎΠ»Π΅Π·Π½ΠΎΠΉ Π²ΠΎΠΉΠ½Ρ. ΠΡΡΠ°Π½ΠΎΠ²ΠΈΡΠ΅ ΠΊΡΠΎΠ²ΠΎΠΏΡΠΎΠ»ΠΈΡΠΈΠ΅. Π‘ΠΊΠ°ΠΆΠΈΡΠ΅ "ΠΠ΅Ρ Π²ΠΎΠΉΠ½Π΅!"
πΊπΈ To Citizens of Russia
We at Laminas come from all over the world. Many of us have friends, family and colleagues in both Russia and Ukraine. Some of us were born in Russia. Some of us currently live in Russia. Some have grandparents who fought Nazis in World War II. Nobody here supports fascism.
One team member has a Ukrainian relative who fled her home with her son. The train was delayed due to bombing on the road ahead. We have friends who are hiding in bomb shelters. We anxiously follow up on them after the air raids, which indiscriminately fire at hospitals, schools, kindergartens and houses. We're not taking this from any media. These are our actual experiences.
You trust us enough to use our software. We ask that you trust us to say the truth on this. We need your help. Go out and protest this unnecessary war. Stop the bloodshed. Say "stop the war!"
Introduction
This Laminas module can be used with conjunction with Laminas API Tools in order to:
- provide an object model of all captured documentation information, including:
- All APIs available.
- All services available in each API.
- All operations available for each service.
- All required/expected
Accept
andContent-Type
request headers, and expectedContent-Type
response header, for each available operation. - All configured fields for each service.
- provide a configurable MVC endpoint for returning documentation.
- documentation will be delivered in both HTML or serialized JSON by default.
- end-users may configure alternate/additional formats via content-negotiation.
This module accomplishes all the above use cases by providing an endpoint to connect to
(/api-tools/documentation[/:api[-v:version][/:service]]
), using content-negotiation to provide
both HTML and JSON representations.
Requirements
Please see the composer.json file.
Installation
Run the following composer
command:
$ composer require laminas-api-tools/api-tools-documentation
Alternately, manually add the following to your composer.json
, in the require
section:
"require": { "laminas-api-tools/api-tools-documentation": "^1.2-dev" }
And then run composer update
to ensure the module is installed.
Finally, add the module name to your project's config/application.config.php
under the modules
key:
return [ /* ... */ 'modules' => [ /* ... */ 'Laminas\ApiTools\Documentation', ], /* ... */ ];
laminas-component-installer
If you use laminas-component-installer, that plugin will install api-tools-documentation as a module for you.
Configuration
User Configuration
This module does not utilize any user configuration.
System Configuration
The following configuration is defined by the module to ensure operation within a Laminas MVC application.
namespace Laminas\ApiTools\Documentation; use Laminas\ServiceManager\Factory\InvokableFactory; use Laminas\View\Model\ViewModel; return [ 'router' => [ 'routes' => [ 'api-tools' => [ 'child_routes' => [ 'documentation' => [ 'type' => 'segment', 'options' => [ 'route' => '/documentation[/:api[-v:version][/:service]]', 'constraints' => [ 'api' => '[a-zA-Z][a-zA-Z0-9_.]+', ], 'defaults' => [ 'controller' => Controller::class, 'action' => 'show', ], ], ], ], ], ], ], 'service_manager' => [ 'factories' => [ ApiFactory::class => Factory\ApiFactoryFactory::class, ], ], 'controllers' => [ 'factories' => [ Controller::class => ControllerFactory::class, ], ], 'api-tools-content-negotiation' => [ 'controllers' => [ Controller::class => 'Documentation', ], 'accept_whitelist' => [ Controller::class => [ 0 => 'application/vnd.swagger+json', 1 => 'application/json', ], ], 'selectors' => [ 'Documentation' => [ ViewModel::class => [ 'text/html', 'application/xhtml+xml', ], JsonModel::class => [ 'application/json', ], ], ], ], 'view_helpers' => [ 'aliases' => [ 'agacceptheaders' => View\AgAcceptHeaders::class, 'agAcceptHeaders' => View\AgAcceptHeaders::class, 'agcontenttypeheaders' => View\AgContentTypeHeaders::class, 'agContentTypeHeaders' => View\AgContentTypeHeaders::class, 'agservicepath' => View\AgServicePath::class, 'agServicePath' => View\AgServicePath::class, 'agstatuscodes' => View\AgStatusCodes::class, 'agStatusCodes' => View\AgStatusCodes::class, 'agtransformdescription' => View\AgTransformDescription::class, 'agTransformDescription' => View\AgTransformDescription::class, ], 'factories' => [ View\AgAcceptHeaders::class => InvokableFactory::class, View\AgContentTypeHeaders::class => InvokableFactory::class, View\AgServicePath::class => InvokableFactory::class, View\AgStatusCodes::class => InvokableFactory::class, View\AgTransformDescription::class => InvokableFactory::class, ], ], 'view_manager' => [ 'template_path_stack' => [ __DIR__ . '/../view', ], ], ];
Laminas Events
This module has no events or listeners.
Laminas Services
View Helpers
The following list of view helpers assist in making API documentation models presentable in view scripts.
Laminas\ApiTools\Documentation\View\AgAcceptHeaders
(a.k.aagAcceptHeaders
) for making a list ofAccept
headers, escaped for HTML.Laminas\ApiTools\Documentation\View\AgContentTypeHeaders
(a.k.aagContentTypeHeaders
) for making a list ofContent-Type
headers, escaped for HTML.Laminas\ApiTools\Documentation\View\AgServicePath
(a.k.aagServicePath
) for making an HTML view representation of the route configuration of a service path.Laminas\ApiTools\Documentation\View\AgStatusCodes
(a.k.aagStatusCodes
) for making an escaped list of status codes and their messages.Laminas\ApiTools\Documentation\View\AgTransformDescription
(a.k.aagTransformDescription
) for transforming the written descriptions into Markdown.
Factories
Laminas\ApiTools\Documentation\ApiFactory
The ApiFactory
service is capable of producing an object-graph representation of the desired
API documentation that is requested. This object-graph will be composed of the following types:
Laminas\ApiTools\Documentation\Api
: the root node of an API.Laminas\ApiTools\Documentation\Services
: an array of services in the API (a service can be one of a REST or RPC style service).Laminas\ApiTools\Documentation\Operations
: an array of operations in the service.Laminas\ApiTools\Documentation\Fields
: an array of fields for a service.