Skip to content
Snippets Groups Projects
Commit 97f485af authored by Karthik Kumar D K's avatar Karthik Kumar D K Committed by karthikdksrijan
Browse files

Issue #3377625 by heykarthikwithu: New features for API Docs module

parent 841d3725
Branches
Tags 2.0.0
No related merge requests found
User Registration Limit
------------
This module will provides API Docs to your Developer Portal, It is powered by Drupal content type, custom field formatters & views.
### Features covered
1. API Docs module will provide API Docs Content type, Redoc & Swagger UI Field Formatters & API Docs View.
2. Admins can create API Docs with the help of API Docs content type, by filling out the API Doc Name, Description, Status & Open API Spec.
3. Users can see the List the published API Docs with the help of API Docs View.
Installation
------------
* Install as you would normally install a contributed Drupal module. For further information, see [Installing Drupal Modules](https://www.drupal.org/docs/extending-drupal/installing-drupal-modules).
Configuration
-------------
* 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 list of API Docs published in the site, with filter 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 typs displays & API Docs View. If needed these can be customized at API Docs display level.
API Docs
name: 'API Docs' name: 'API Docs'
type: module type: module
description: 'This module will provides API Docs to your Developer Portal, It is powered by Drupal content type & custom field formatters.' description: 'This module will provides API Docs to your Developer Portal, It is powered by Drupal content type, custom field formatters & views.'
core_version_requirement: '>=8.9 <11.0.0-stable' core_version_requirement: '>=8.9 <11.0.0-stable'
...@@ -12,15 +12,49 @@ use Drupal\Core\Routing\RouteMatchInterface; ...@@ -12,15 +12,49 @@ use Drupal\Core\Routing\RouteMatchInterface;
*/ */
function api_docs_help($route_name, RouteMatchInterface $route_match) { function api_docs_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) { switch ($route_name) {
// Main module help for the api_docs module.
case 'help.page.api_docs': case 'help.page.api_docs':
$output = '<p>' . t('This module will provides API Docs to your Developer Portal, It is powered by Drupal content type & custom field formatters.') . '</p>'; $output = '<p>' . t('This module will provides API Docs to your Developer Portal, It is powered by Drupal content type, custom field formatters & views.') . '</p>';
$output .= '<h6>' . t('Features covered') . '</h6>'; $output .= '<h6>' . t('Features covered') . '</h6>';
$output .= '<ul>'; $output .= '<ul>';
$output .= '<li>' . t('API Docs Content type.') . '</li>'; $output .= '<li>' . t('API Docs module will provide API Docs Content type, Redoc & Swagger UI Field Formatters & API Docs View.') . '</li>';
$output .= '<li>' . t('Redoc & Swagger UI Field Formatters.') . '</li>'; $output .= '<li>' . t('Admins can create API Docs with the help of API Docs content type, by filling out the API Doc Name, Description, Status & Open API Spec.') . '</li>';
$output .= '<li>' . t('Users can see the List the published API Docs with the help of API Docs View.') . '</li>';
$output .= '</ul>';
$output .= '<h6>' . t('Installation') . '</h6>';
$output .= '<p>' . t('Install as you would normally install a contributed Drupal module. For further information, see <a href="https://www.drupal.org/docs/extending-drupal/installing-drupal-modules" target="_blank">Installing Drupal Modules.</a>') . '</p>';
$output .= '<h6>' . t('Configuration') . '</h6>';
$output .= '<ul>';
$output .= '<li>' . t('After enabling the module, navigate to Add API Docs <a href="/node/add/api_docs" target="_blank">/node/add/api_docs</a>.') . '</li>';
$output .= '<ul>';
$output .= '<li>' . t('Fill the API Doc Name, Description, Status & Open API Specification, Save the content by clicking Save.') . '</li>';
$output .= '<li>' . t('Similarly, Admin will be able to create as many API Docs.') . '</li>';
$output .= '</ul>';
$output .= '</ul>';
$output .= '<ul>';
$output .= '<li>' . t('Navigate to API Docs via <a href="/api-docs" target="_blank">/api-docs</a>.') . '</li>';
$output .= '<ul>';
$output .= '<li>' . t('Users can see list of API Docs published in the site, with filter by API Doc Status, with minimal details of the API Doc.') . '</li>';
$output .= '<li>' . t('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.') . '</li>';
$output .= '</ul>';
$output .= '</ul>';
$output .= '<h6>' . t('Customizations') . '</h6>';
$output .= '<ul>';
$output .= '<li>' . t('API Docs is providing a field formatters, Open API Field Formatter.') . '</li>';
$output .= '<ul>';
$output .= '<li>' . t('Open API field formatter can be used in for any file field type within your site') . '</li>';
$output .= '<li>' . t('Open API field formatter, can render the file in two possible ways') . '</li>';
$output .= '<ul>';
$output .= '<li>' . t('One with Redoc UI format.') . '</li>';
$output .= '<li>' . t('Other with Swagger UI format.') . '</li>';
$output .= '</ul>';
$output .= '</ul>';
$output .= '<ul>';
$output .= '<li>' . t('Admin will have the flexibility to change this configuration of the Open API field formatter.') . '</li>';
$output .= '</ul>';
$output .= '<li>' . t('API Docs is providing two View modes, they are Redoc UI & Swagger UI, these View modes are used in the API Docs content typs displays & API Docs View. If needed these can be customized at API Docs display level.') . '</li>';
$output .= '</ul>'; $output .= '</ul>';
return $output; return $output;
default: default:
} }
} }
......
...@@ -120,7 +120,7 @@ display: ...@@ -120,7 +120,7 @@ display:
plugin_id: text plugin_id: text
empty: true empty: true
content: content:
value: 'No API Docs found on this query.' value: 'No API Docs found.'
format: basic_html format: basic_html
tokenize: false tokenize: false
sorts: sorts:
......
...@@ -2,13 +2,13 @@ ...@@ -2,13 +2,13 @@
namespace Drupal\api_docs\Plugin\Field\FieldFormatter; namespace Drupal\api_docs\Plugin\Field\FieldFormatter;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\File\FileUrlGeneratorInterface; use Drupal\Core\File\FileUrlGeneratorInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\file\Plugin\Field\FieldFormatter\FileFormatterBase; use Drupal\file\Plugin\Field\FieldFormatter\FileFormatterBase;
use Symfony\Component\DependencyInjection\ContainerInterface;
/** /**
* Plugin implementation of the 'open_api_doc_field_formatter'. * Plugin implementation of the 'open_api_doc_field_formatter'.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment