We have two controller actions currently in our system, which:
Are not needed for the user interface
Provide the API-like representation of the information in the system
All this makes these actions perfect targets for our practice in building modules. Let's make an API module that will contain the actions currently reachable by the /services/json
and /services/yaml
routes.
The following use cases should be supported:
The GET request to the
/api/services/json
route should return the list of attributes of all registered services in the JSON formatThe GET request to the
/api/services/yaml
route should return the list of attributes of all registered services in the YAML format
We define result in JSON format
as the string that can be converted to the PHP data structures without error using the yii\helpers\Json::decode()
method.
We define the result in YAML format
as the string that can be converted to the PHP data structures without error using the Symfony\Component\Yaml\Yaml...