This module will provide API Docs to your Developer Portal, It is powered by Drupal content type, custom field formatters & views.
Here's a step-by-step guide to help you to download, enable, configure and use the module for your developer portal.
Download & Enable the Module:
- Visit the Drupal.org website and navigate to the API Docs module's page that you want to download, here’s the module link - https://www.drupal.org/project/api_docs.
- Use the composer command to download the module
composer require 'drupal/api_docs:^2.0'
- Log in to your Drupal site as an administrator.
- Navigate to the "Extend" page by clicking on "Manage" and then "Extend" or by visiting
/admin/modules
on your site. - Find the module in the list of available modules and check the checkbox next to the module's name and click the "Install" button. This will enable the module.
Configure the Module:
- After enabling the module, navigate to Add API Docs
/node/add/api_docs
.- Fill the API Doc Name, Description, Status & Open API Specification, Save the content by clicking Save.
- Similarly, Admin will be able to create as many API Docs.
- Navigate to API Docs via
/api-docs
.- Users can see a list of API Docs published in the site, filtered by API Doc Status, with minimal details of the API Doc.
- Each API Doc in this list will have View Redoc UI & View Swagger UI, users will be able to navigate to respective API Doc pages.
Customizations:
- API Docs is providing a Field Formatter, Open API Field Formatter.
- Open API field formatter can be used in for any file field type within your site
- Open API field formatter, can render the file in two possible ways
- One with Redoc UI format.
- Other with Swagger UI format.
- Admin will have the flexibility to change this configuration of the Open API field formatter.
- API Docs is providing two View modes, they are Redoc UI & Swagger UI, these View modes are used in the API Docs content type displays & API Docs View. If needed these can be customized at API Docs display level.
This is how the API Docs module will help you to maintain the Open API spec as API Docs in your Developer Portal.
Thanks for reading the article, for more drupal related articles read and subscribe to peoples blog articles.