Problem/Motivation
Instructions for dependency library installation no longer appear to work properly. One possibility is the issue of dynamic package path issues in composer/installers.
Steps to reproduce
From the homepage:
Installation with Composer
To install the library via composer, you will need to configure composer to put the library in the correct location for Drupal. This requests the composer/installers and mnsami/composer-custom-directory-installer packages. You can run the following command to ensure they are installed.
composer require composer/installers mnsami/composer-custom-directory-installer
Then modify your project's composer.json to include the following configuration.
"extra": {
"installer-paths": {
...
"web/libraries/{$name}": ["swagger-api/swagger-ui", "type:drupal-library"],
...
}
}
I did both of those things, and then
composer require 'drupal/openapi_ui_swagger:1.x-dev@dev'
When I visit the openapi page view with swagger at /admin/config/services/openapi/swagger/jsonapi I get an empty page. I think I am missing the actual swagger library but I want to do it withe composer. Is there a composer command missing from the above instructions to install the library from github in the "do it with composer" section?
Proposed resolution
Because swagger-api/swagger-ui is not published as "type": "drupal-module"
, it is being installed in the /vendor directory. Following an example from drupal/telephone_international_widget propose the inclusion of new file composer.libraries.json
to define a custom drupal library repository to pull the library and install where needed as expected when installing the module.
Steps to complete
This requires Composer Merge Plugin plugin available on GitHub.
composer require wikimedia/composer-merge-plugin
Edit the composer.json
file of your website and under the "extra": {}
section add:
// *Note: the web/ directory represents the Drupal root
"merge-plugin": {
"include": [
"web/modules/contrib/openapi_ui_swagger/composer.libraries.json"
]
},
From now on, every time the composer.json
file is updated, it will also read the content of composer.libraries.json
file located at web/modules/contrib/openapi_ui_swagger/ and update accordingly.
Remaining tasks
- Create fork to implement changes (pending)
- Update documentation page