Skip to content

Commit a89cc5b

Browse files
cnovakJaesin
authored andcommitted
DRUP-709: Rename API Docs to API Catalog (#4)
* DRUP-709: Rename API Docs to API Catalog * Code review fixes Also added missing CONTRIBUTING and LICENSE files * Code fixes for README
1 parent 4fee302 commit a89cc5b

26 files changed

+521
-126
lines changed

CONTRIBUTING.md

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# How to Contribute
2+
3+
We'd love to accept your patches and contributions to this project. There are
4+
just a few small guidelines you need to follow.
5+
6+
## Contributor License Agreement
7+
8+
Contributions to this project must be accompanied by a Contributor License
9+
Agreement. You (or your employer) retain the copyright to your contribution,
10+
this simply gives us permission to use and redistribute your contributions as
11+
part of the project. Head over to <https://cla.developers.google.com/> to see
12+
your current agreements on file or to sign a new one.
13+
14+
You generally only need to submit a CLA once, so if you've already submitted one
15+
(even if it was for a different project), you probably don't need to do it
16+
again.
17+
18+
## Code reviews
19+
20+
All submissions, including submissions by project members, require review. We
21+
use GitHub pull requests for this purpose. Consult
22+
[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more
23+
information on using pull requests.
24+
25+
## Community Guidelines
26+
27+
This project follows [Google's Open Source Community Guidelines](https://opensource.google.com/conduct/).

LICENSE.txt

+339
Large diffs are not rendered by default.

README.md

+40-9
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,69 @@
1-
# API Docs for Apigee Edge
1+
# Apigee API Catalog for Drupal
22

3-
A module to render OpenAPI specs as documentation to your API developers.
3+
Render OpenAPI specs as documentation to your API developers.
44

55
## Overview
66

77
When you enable this module, it creates a new Drupal entity in your system named
8-
"API Doc". You can add new API Docs under Structure > API Docs in the admin menu.
8+
"API Doc". You can add new API docs under __Configuration > API catalog__ in the admin menu.
99

1010
Once added, the API name and description for each API Doc will be displayed in the
11-
"APIs" menu item on the site to all visitors.
11+
"APIs" menu item on the site using a Drupal view. Make sure to change the
12+
"View published API docs" permissions if you want to allow registered or anonymous users
13+
to be able to view published API documentation.
1214

1315
The OpenAPI spec by default is shown on the API Doc detail page by default.
1416
To render the OpenAPI spec using Swagger UI:
1517

1618
1. Install an enable the [Swagger UI Field Formatter](https://www.drupal.org/project/swagger_ui_formatter) module.
1719
2. Install the Swagger UI JS library as documented [on the module page](https://www.drupal.org/project/swagger_ui_formatter).
18-
3. Go to Structure > API Doc settings > Manage display in the admin menu.
20+
3. Go to __Configuration > API catalog > Manage display__ in the admin menu.
1921
4. Change "OpenAPI specification" field format to use the Swagger UI field formatter.
2022

21-
The API Doc is an entity, you can configure it at Structure > API Doc settings in the admin
23+
The API Doc is an entity, you can configure it at __Configuration > API catalog__ in the admin
2224
menu.
2325

24-
The "APIs" menu link is a view, you can modify it by editing the "API Documentation" view
26+
The "APIs" menu link is a view, you can modify it by editing the "API Catalog" view
2527
under Structure > Views in the admin menu.
2628

2729
## Planned Features
2830

2931
- Create additional field formatters to use for rendering OpenAPI specs
3032
- Integration with Apigee API Products
31-
- Allow OpenAPI specs to be associated to a source location such as Apigee Edge or
32-
a URL
33+
- Allow OpenAPI specs to be associated to a source location such as Apigee Edge or a URL
3334
- Add visual notifications when source URL specs have changed on the API Doc admin screen
3435
- Ability to update API Docs when source location changes
3536

3637
### Known issues
3738

3839
- none
40+
41+
## Installing
42+
43+
This module must be installed on a Drupal site that is managed by Composer. Drupal.org has documentation on how to
44+
[use Composer to manage Drupal site dependencies](https://www.drupal.org/docs/develop/using-composer/using-composer-to-manage-drupal-site-dependencies)
45+
to get you started quickly.
46+
47+
1. Install the module using [Composer](https://getcomposer.org/).
48+
Composer will download the this module and all its dependencies.
49+
**Note**: Composer must be executed at the root of your Drupal installation.
50+
For example:
51+
```
52+
cd /path/to/drupal/root
53+
composer require drupal/apigee_api_catalog
54+
```
55+
For more information about installing contributed modules using Composer, read
56+
[how to download contributed modules and themes using Composer](https://www.drupal.org/docs/develop/using-composer/using-composer-to-manage-drupal-site-dependencies#managing-contributed).
57+
2. Choose **Extend** in the Drupal administration menu.
58+
3. Select the **Apigee API catalog** module.
59+
4. Choose **Install**.
60+
61+
## Development
62+
63+
Development is happening in our [GitHub repository](https://github.com/apigee/apigee-api-catalog-drupal). The Drupal.org issue
64+
queue is disabled; we use the [Github issue queue](https://github.com/apigee/apigee-api-catalog-drupal) to coordinate
65+
development. See [CONTRIBUTING.md] for more information on contributing through development.
66+
67+
## Disclaimer
68+
69+
This is not an officially supported Google product.

apigee_edge_apidocs.info.yml renamed to apigee_api_catalog.info.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
name: 'Apigee Edge API Docs'
1+
name: 'Apigee API Catalog'
22
type: module
33
description: 'Display OpenAPI documentation of your APIs to your developers.'
44
core: 8.x
5-
package: 'Apigee (Experimental)'
6-
configure: apidocs.settings
5+
package: 'Apigee'
6+
configure: apigee_api_catalog.settings
77
dependencies:
88
- drupal:text
99
- drupal:file

apigee_api_catalog.links.menu.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
entity.apidoc.collection:
2+
title: 'API catalog'
3+
route_name: entity.apidoc.collection
4+
description: 'List of all API documentation.'
5+
parent: system.admin_structure
6+
weight: 100
7+
8+
apigee_api_catalog.settings:
9+
title: 'API catalog'
10+
description: 'Configure API catalog settings.'
11+
route_name: apigee_api_catalog.settings
12+
parent: system.admin_config_edge

apigee_edge_apidocs.links.task.yml renamed to apigee_api_catalog.links.task.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# API Doc routing definition
2-
apigee_edge_apidocs.settings:
3-
route_name: apigee_edge_apidocs.settings
2+
apigee_api_catalog.settings:
3+
route_name: apigee_api_catalog.settings
44
title: 'Settings'
5-
base_route: apigee_edge_apidocs.settings
5+
base_route: apigee_api_catalog.settings
66

77
entity.apidoc.canonical:
88
route_name: entity.apidoc.canonical

apigee_edge_apidocs.module renamed to apigee_api_catalog.module

+5-5
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,21 @@
2020

2121
/**
2222
* @file
23-
* Module file for Apigee Edge API Docs.
23+
* Module file for Apigee Edge: API Docs.
2424
*/
2525

2626
use Drupal\Core\Routing\RouteMatchInterface;
2727

2828
/**
2929
* Implements hook_help().
3030
*/
31-
function apigee_edge_apidocs_help($route_name, RouteMatchInterface $route_match) {
31+
function apigee_api_catalog_help($route_name, RouteMatchInterface $route_match) {
3232
switch ($route_name) {
33-
// Main module help for the apigee_edge_apidocs module.
34-
case 'help.page.apigee_edge_apidocs':
33+
// Main module help for the apigee_api_catalog module.
34+
case 'help.page.apigee_api_catalog':
3535
$output = '';
3636
$output .= '<h3>' . t('About') . '</h3>';
37-
$output .= '<p>' . t('Display OpenAPI documentation of your APIs to your developers.') . '</p>';
37+
$output .= '<p>' . t('Display documentation of your APIs to your developers using OpenAPI documentation.') . '</p>';
3838
return $output;
3939

4040
default:

apigee_api_catalog.permissions.yml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
add apidoc entities:
2+
title: 'Create new API docs'
3+
4+
administer apigee api catalog:
5+
title: 'Administer API catalog'
6+
description: 'Change configuration the API catalog.'
7+
restrict access: true
8+
9+
delete apidoc entities:
10+
title: 'Delete API docs'
11+
12+
edit apidoc entities:
13+
title: 'Edit API docs'
14+
15+
view published apidoc entities:
16+
title: 'View published API docs'
17+
18+
view unpublished apidoc entities:
19+
title: 'View unpublished API docs'

apigee_api_catalog.services.yml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
services:
2+
logger.channel.apigee_api_catalog:
3+
parent: logger.channel_base
4+
arguments: ['apigee_api_catalog']

apigee_edge_apidocs.links.menu.yml

-13
This file was deleted.

apigee_edge_apidocs.permissions.yml

-19
This file was deleted.

apigee_edge_apidocs.services.yml

-4
This file was deleted.

config/optional/views.view.apigee_edge_api_docs.yml renamed to config/optional/views.view.apigee_api_catalog.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ dependencies:
44
config:
55
- system.menu.main
66
module:
7-
- apigee_edge_apidocs
7+
- apigee_api_catalog
88
- text
9-
id: apigee_edge_api_docs
10-
label: 'Apigee Edge API Docs'
9+
id: apigee_api_catalog
10+
label: 'API Catalog'
1111
module: views
12-
description: 'APIs published using the API Docs Apigee Edge module.'
12+
description: 'APIs published using the Apigee API Catalog module.'
1313
tag: ''
1414
base_table: apidoc_field_data
1515
base_field: id
@@ -280,7 +280,7 @@ display:
280280
entity_field: name
281281
plugin_id: string
282282
sorts: { }
283-
title: 'API Documentation'
283+
title: 'API Catalog'
284284
header: { }
285285
footer: { }
286286
empty:
@@ -319,7 +319,7 @@ display:
319319
menu:
320320
type: normal
321321
title: APIs
322-
description: 'API documentation'
322+
description: 'API Catalog'
323323
expanded: false
324324
parent: ''
325325
weight: 0

src/ApiDocAccessControlHandler.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
* MA 02110-1301, USA.
1919
*/
2020

21-
namespace Drupal\apigee_edge_apidocs;
21+
namespace Drupal\apigee_api_catalog;
2222

2323
use Drupal\Core\Entity\EntityAccessControlHandler;
2424
use Drupal\Core\Entity\EntityInterface;
@@ -28,7 +28,7 @@
2828
/**
2929
* Access controller for the API Doc entity.
3030
*
31-
* @see \Drupal\apigee_edge_apidocs\Entity\ApiDoc.
31+
* @see \Drupal\apigee_api_catalog\Entity\ApiDoc.
3232
*/
3333
class ApiDocAccessControlHandler extends EntityAccessControlHandler {
3434

@@ -39,7 +39,7 @@ protected function checkAccess(EntityInterface $entity, $operation, AccountInter
3939
$parent_access = parent::checkAccess($entity, $operation, $account);
4040

4141
if (!$parent_access->isAllowed()) {
42-
/** @var \Drupal\apigee_edge_apidocs\Entity\ApiDocInterface $entity */
42+
/** @var \Drupal\apigee_api_catalog\Entity\ApiDocInterface $entity */
4343
switch ($operation) {
4444
case 'view':
4545
if (!$entity->isPublished()) {
@@ -64,7 +64,7 @@ protected function checkAccess(EntityInterface $entity, $operation, AccountInter
6464
*/
6565
protected function checkCreateAccess(AccountInterface $account, array $context, $entity_bundle = NULL) {
6666
return AccessResult::allowedIfHasPermission($account, 'add apidoc entities')
67-
->orIf(AccessResult::allowedIfHasPermission($account, 'administer apidoc entities'));
67+
->orIf(AccessResult::allowedIfHasPermission($account, 'administer apigee api catalog'));
6868
}
6969

7070
}

src/ApiDocHtmlRouteProvider.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
* MA 02110-1301, USA.
1919
*/
2020

21-
namespace Drupal\apigee_edge_apidocs;
21+
namespace Drupal\apigee_api_catalog;
2222

23-
use Drupal\apigee_edge_apidocs\Controller\ApiDocController;
23+
use Drupal\apigee_api_catalog\Controller\ApiDocController;
2424
use Drupal\Core\Entity\EntityTypeInterface;
2525
use Drupal\Core\Entity\Routing\AdminHtmlRouteProvider;
2626
use Symfony\Component\Routing\Route;
@@ -40,7 +40,7 @@ public function getRoutes(EntityTypeInterface $entity_type) {
4040
$collection = parent::getRoutes($entity_type);
4141

4242
if ($settings_form_route = $this->getSettingsFormRoute($entity_type)) {
43-
$collection->add('apigee_edge_apidocs.settings', $settings_form_route);
43+
$collection->add('apigee_api_catalog.settings', $settings_form_route);
4444
}
4545

4646
if ($apidoc_collection_route = $collection->get('entity.apidoc.collection')) {
@@ -61,10 +61,10 @@ public function getRoutes(EntityTypeInterface $entity_type) {
6161
*/
6262
protected function getSettingsFormRoute(EntityTypeInterface $entity_type) {
6363
if (!$entity_type->getBundleEntityType()) {
64-
$route = new Route('admin/config/apigee-edge/api-docs-settings');
64+
$route = new Route('admin/config/api-catalog-settings');
6565
$route
6666
->setDefaults([
67-
'_form' => 'Drupal\apigee_edge_apidocs\Form\ApiDocSettingsForm',
67+
'_form' => 'Drupal\apigee_api_catalog\Form\ApiDocSettingsForm',
6868
'_title_callback' => ApiDocController::class . '::title',
6969
])
7070
->setRequirement('_permission', $entity_type->getAdminPermission())

src/ApiDocListBuilder.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
* MA 02110-1301, USA.
1919
*/
2020

21-
namespace Drupal\apigee_edge_apidocs;
21+
namespace Drupal\apigee_api_catalog;
2222

2323
use Drupal\Core\Entity\EntityInterface;
2424
use Drupal\Core\Entity\EntityTypeInterface;
@@ -52,7 +52,7 @@ public static function createInstance(ContainerInterface $container, EntityTypeI
5252
public function render() {
5353
$build['description'] = [
5454
'#markup' => $this->t('Manage your API documentation. You can manage the fields on the <a href=":url">API Docs settings page</a>.', [
55-
':url' => Url::fromRoute('apigee_edge_apidocs.settings')->toString(),
55+
':url' => Url::fromRoute('apigee_api_catalog.settings')->toString(),
5656
]),
5757
];
5858
$build['table'] = parent::render();
@@ -72,7 +72,7 @@ public function buildHeader() {
7272
* {@inheritdoc}
7373
*/
7474
public function buildRow(EntityInterface $entity) {
75-
/* @var $entity \Drupal\apigee_edge_apidocs\Entity\ApiDoc */
75+
/* @var $entity \Drupal\apigee_api_catalog\Entity\ApiDoc */
7676
$row['id'] = $entity->id();
7777
$row['name'] = Link::createFromRoute(
7878
$entity->label(),

src/Controller/ApiDocController.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@
1818
* MA 02110-1301, USA.
1919
*/
2020

21-
namespace Drupal\apigee_edge_apidocs\Controller;
21+
namespace Drupal\apigee_api_catalog\Controller;
2222

2323
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
2424
use Drupal\Core\Entity\EntityTypeManagerInterface;
2525
use Drupal\Core\StringTranslation\StringTranslationTrait;
2626
use Symfony\Component\DependencyInjection\ContainerInterface;
2727

2828
/**
29-
* Generic controller for the apigee_edge_apidocs module.
29+
* Generic controller for the apidoc entity.
3030
*/
3131
class ApiDocController implements ContainerInjectionInterface {
3232
use StringTranslationTrait;
@@ -60,6 +60,8 @@ public static function create(ContainerInterface $container) {
6060
*
6161
* @return \Drupal\Core\StringTranslation\TranslatableMarkup
6262
* The translated title.
63+
*
64+
* @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
6365
*/
6466
public function title() {
6567
return $this->t('@label settings', [

0 commit comments

Comments
 (0)