Problem/Motivation
This repository packages the dist-only Swagger UI 5.32.14 distribution build as a Composer
drupal-library. It exists because the upstream package cannot be placed where Drupal needs it.
drupal/openapi_ui_swagger requires swagger-api/swagger-ui, which upstream publishes as
"type": "library", not drupal-library. composer/installers will not place a plain library type,
so it lands in vendor/ where nothing can serve it, while the Drupal module loads
/libraries/swagger-ui/dist/….
The module's own README works around that with mnsami/composer-custom-directory-installer plus a
per-package installer path in the root project composer.json. The maintainer has rejected that
approach for Varbase 11: no extra Composer plugin, and no extra entries in the root project
composer.json. The libraries must work out of the box with the generic Drupal installer path every
project already has.
Separately, the Varbase project was also fetching swagger-ui-dist a second time from npm, so the
same library was being downloaded twice.
Steps to reproduce
- Create a project whose only library installer path is the generic
"web/libraries/{$name}": ["type:drupal-library"].
composer require drupal/openapi_ui_swagger:~1.
swagger-api/swagger-ui resolves into vendor/swagger-api/swagger-ui/ — it is type: library, so
composer/installers does not place it.
drupal/openapi_ui_swagger loads /libraries/swagger-ui/dist/swagger-ui-bundle.js and gets a 404.
Proposed resolution
Publish the distribution build as this package, which does two things:
- declares
"type": "drupal-library", so the generic rule places it at web/libraries/swagger-ui;
- declares
"replace": { "swagger-api/swagger-ui": "self.version" }, so requiring it satisfies
drupal/openapi_ui_swagger's requirement rather than duplicating it — the upstream package is never
downloaded.
Testing evidence, measured in a scratch project requiring drupal/openapi_ui_swagger:~1 plus this
package, with only the generic installer path:
- the files landed at
web/libraries/swagger-ui/dist/swagger-ui-bundle.js and dist/swagger-ui.css;
vendor/swagger-api was absent — the replace took effect and there was no second copy.
One consequence to record, because it is not obvious: the replace only takes effect if something
actually requires this package. A project that merely requires drupal/openapi_ui_swagger still resolves
the upstream swagger-api/swagger-ui into vendor/. So the recipe that installs the module
(drupal/varbase_api_base) must require vardot/swagger-ui.
Branch 5.x, released as tag 5.32.14. This repository is not a fork of the upstream project; it
carries the dist build only.
AI-Generated: Yes
Checkpoints:
Problem/Motivation
This repository packages the dist-only Swagger UI 5.32.14 distribution build as a Composer
drupal-library. It exists because the upstream package cannot be placed where Drupal needs it.drupal/openapi_ui_swaggerrequiresswagger-api/swagger-ui, which upstream publishes as"type": "library", notdrupal-library.composer/installerswill not place a plainlibrarytype,so it lands in
vendor/where nothing can serve it, while the Drupal module loads/libraries/swagger-ui/dist/….The module's own README works around that with
mnsami/composer-custom-directory-installerplus aper-package installer path in the root project
composer.json. The maintainer has rejected thatapproach for Varbase 11: no extra Composer plugin, and no extra entries in the root project
composer.json. The libraries must work out of the box with the generic Drupal installer path everyproject already has.
Separately, the Varbase project was also fetching
swagger-ui-dista second time from npm, so thesame library was being downloaded twice.
Steps to reproduce
"web/libraries/{$name}": ["type:drupal-library"].composer require drupal/openapi_ui_swagger:~1.swagger-api/swagger-uiresolves intovendor/swagger-api/swagger-ui/— it istype: library, socomposer/installersdoes not place it.drupal/openapi_ui_swaggerloads/libraries/swagger-ui/dist/swagger-ui-bundle.jsand gets a 404.Proposed resolution
Publish the distribution build as this package, which does two things:
"type": "drupal-library", so the generic rule places it atweb/libraries/swagger-ui;"replace": { "swagger-api/swagger-ui": "self.version" }, so requiring it satisfiesdrupal/openapi_ui_swagger's requirement rather than duplicating it — the upstream package is neverdownloaded.
Testing evidence, measured in a scratch project requiring
drupal/openapi_ui_swagger:~1plus thispackage, with only the generic installer path:
web/libraries/swagger-ui/dist/swagger-ui-bundle.jsanddist/swagger-ui.css;vendor/swagger-apiwas absent — thereplacetook effect and there was no second copy.One consequence to record, because it is not obvious: the
replaceonly takes effect if somethingactually requires this package. A project that merely requires
drupal/openapi_ui_swaggerstill resolvesthe upstream
swagger-api/swagger-uiintovendor/. So the recipe that installs the module(
drupal/varbase_api_base) must requirevardot/swagger-ui.Branch
5.x, released as tag5.32.14. This repository is not a fork of the upstream project; itcarries the dist build only.
AI-Generated: Yes
Checkpoints: