Skip to content

Package the Swagger UI 5.32.14 dist build as a drupal-library that replaces swagger-api/swagger-ui, so a consuming project needs no extra plugin and no per-package installer path #1

Description

@Natshah

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

  1. Create a project whose only library installer path is the generic
    "web/libraries/{$name}": ["type:drupal-library"].
  2. composer require drupal/openapi_ui_swagger:~1.
  3. swagger-api/swagger-ui resolves into vendor/swagger-api/swagger-ui/ — it is type: library, so
    composer/installers does not place it.
  4. 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:

  • File an issue
  • Addition/Change/Update/Fix
  • Testing to ensure no regression
  • Automated unit testing coverage
  • Automated functional testing coverage
  • UX/UI designer responsibilities
  • Readability
  • Accessibility
  • Performance
  • Security
  • Developer Documentation
  • User Guide Documentation
  • Reviewed by human
  • Code review by maintainers
  • Full testing and approval
  • Credit contributors
  • Review with the product owner
  • Release notes snippet
  • Release

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions