Skip to content

Commit fe74528

Browse files
[#71] API Doc conversion to a node type (#84)
* [#71] Create apidoc node bundle on install/update. * [#71] Apidoc conversion. * [#71] Apidoc conversion. * [#71] Apidoc conversion. * [#71] Apidoc - node path aliases. * [#71] Apidoc - tests. * [#71] Apidoc - README. * [#71] Apidoc - links/tasks/actions. * [#71] Apidoc - ApiDocsAdminTest. * [#71] Apidoc - ApiDocsJsonApi. * [#71] Apidoc - removing ApiDocsAccessTest as it is covered by core. * [#71] Apidoc - node form validation and conditionals. * [#71] Apidoc - add back the ApiDocFileLink constraint. * Update README.md Co-authored-by: Chris Novak <[email protected]> * Update apigee_api_catalog.install Co-authored-by: Chris Novak <[email protected]> * Update config/optional/views.view.apigee_api_catalog.yml Co-authored-by: Chris Novak <[email protected]> * Update config/optional/views.view.api_catalog_admin.yml Co-authored-by: Chris Novak <[email protected]> * [#71] Apidoc - replace "reimport apidoc specs" permission with edit node access check. * [#71] Apidoc - remove API product field, show body in display. * [#71] Apidoc - updtes to the spec fetcher form and logic. * [#71] Apidoc - fixing schema errors so tests can run with schema validation. * [#71] Apidoc - removing Apigee Edge module dependency. * [#71] Apidoc - fixing SmartdocRoutingTest. * [#71] Apidoc - phpcs and deprecation fixes. * [#71] Apidoc - README refers RBAC section to drupal.org docs . Co-authored-by: Chris Novak <[email protected]>
1 parent 618b770 commit fe74528

File tree

47 files changed

+1760
-2312
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1760
-2312
lines changed

README.md

+22-12
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@ Render OpenAPI specs as documentation to your API developers.
44

55
## Overview
66

7-
When you enable this module, it creates a new Drupal entity in your system named
7+
When you enable this module, it creates a new content type named
88
"API Doc". You can add new API docs under __Content > 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 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.
11+
"APIs" menu item on the site using a Drupal view.
1412

1513
The OpenAPI spec by default is rendered using Apigee's SmartDocs custom field formatter.
1614

@@ -26,27 +24,39 @@ To render the OpenAPI spec using Swagger UI:
2624
3. Go to __Configuration > API docs > Manage display__ in the admin menu.
2725
4. Change "OpenAPI specification" field format to use the Swagger UI field formatter.
2826

29-
The API Doc is an entity, you can configure it at __Structure > API docs__ in the admin
27+
The API Doc is an node type, you can configure it at __Structure > Content types > API Doc__ in the admin
3028
menu.
3129

3230
The "/apis" page ("APIs" menu link) is a view. You can modify it by editing the "API Catalog" view
3331
under __Structure > Views__ in the admin menu.
3432

33+
## API Docs RBAC (Role based access control)
34+
35+
_API Docs_ are a node type, so any node access control module from contrib will work to restrict access and play well
36+
with views.
37+
38+
To set up RBAC, we recommend ["Permissions by term"](https://www.drupal.org/project/permissions_by_term), which can
39+
cover the most frequent scenarios. Refer to the online documentation (to be updated as part of
40+
[#81](https://github.com/apigee/apigee-api-catalog-drupal/issues/81)) for a "How to" guide on setting up the RBAC:
41+
https://www.drupal.org/node/3058344
42+
3543
## Planned Features
3644

37-
- Integration with Apigee API Products
45+
- Integration with Apigee API Products.
3846
- Add visual notifications when source URL specs have changed on the API Doc admin screen
3947

4048
### Known issues
4149

50+
- [Backwards compatibility with the version 1.x of this module is a separate issue](https://github.com/apigee/apigee-api-catalog-drupal/issues/80), you can subscribe to notifications to follow the status.
51+
4252
- The Apigee SmartDocs formatter can only render one OpenAPI spec per page and the URL pattern
43-
must match `/api/{entityId}`. This means that the formatter will probably not work correctly if
44-
you modify the default API Docs view or try to use this file Formatter on nodes or other entities.
53+
must match `/api/{entityId}`. This means that the formatter will probably not work correctly if
54+
you modify the default API Docs view or try to use this file Formatter on other node types or entities.
4555

4656
## Installing
4757

4858
This module must be installed on a Drupal site that is managed by Composer. Drupal.org has documentation on how to
49-
[use Composer to manage Drupal site dependencies](https://www.drupal.org/docs/develop/using-composer/using-composer-to-manage-drupal-site-dependencies)
59+
[use Composer to manage Drupal site dependencies](https://www.drupal.org/docs/develop/using-composer/using-composer-to-manage-drupal-site-dependencies)
5060
to get you started quickly.
5161

5262
1. Install the module using [Composer](https://getcomposer.org/).
@@ -57,16 +67,16 @@ to get you started quickly.
5767
cd /path/to/drupal/root
5868
composer require drupal/apigee_api_catalog
5969
```
60-
For more information about installing contributed modules using Composer, read
70+
For more information about installing contributed modules using Composer, read
6171
[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).
6272
2. Choose **Extend** in the Drupal administration menu.
6373
3. Select the **Apigee API catalog** module.
6474
4. Choose **Install**.
6575

6676
## Development
6777

68-
Development is happening in our [GitHub repository](https://github.com/apigee/apigee-api-catalog-drupal). The Drupal.org issue
69-
queue is disabled; we use the [Github issue queue](https://github.com/apigee/apigee-api-catalog-drupal) to coordinate
78+
Development is happening in our [GitHub repository](https://github.com/apigee/apigee-api-catalog-drupal). The Drupal.org issue
79+
queue is disabled; we use the [Github issue queue](https://github.com/apigee/apigee-api-catalog-drupal) to coordinate
7080
development. See [CONTRIBUTING.md] for more information on contributing through development.
7181

7282
## Support

apigee_api_catalog.info.yml

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
name: 'Apigee API Catalog'
22
type: module
33
description: 'Display OpenAPI documentation of your APIs to your developers.'
4-
core: 8.x
4+
core_version_requirement: ^8.8.0 || ^9
55
package: 'Apigee'
66
configure: entity.apidoc.settings
77
dependencies:
88
- drupal:text
99
- drupal:file
10+
- drupal:user
11+
- drupal:node
12+
- drupal:path
13+
- drupal:options
1014
- drupal:file_link
11-
- apigee_edge:apigee_edge

apigee_api_catalog.install

+23
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,22 @@ function apigee_api_catalog_requirements($phase) {
3838
];
3939
}
4040

41+
// Prevent updating the module from 1.x, as there is no update path yet.
42+
// @see https://github.com/apigee/apigee-api-catalog-drupal/issues/80
43+
$schemaVersion = \Drupal::keyValue('system.schema')->get('apigee_api_catalog');
44+
if (in_array($phase, ['update', 'runtime']) && $schemaVersion < 8801) {
45+
return [
46+
'apigee_api_catalog_update_unsupported' => [
47+
'title' => t('Apigee API Catalog'),
48+
'description' =>t('The <a href=":link_module">Apigee API Catalog</a> 1.x version is enabled on this site but the module has been replaced with a 2.x version on the filesystem. Currently there is no way to upgrade from 1.x to 2.x. You will need to revert to the latest 1.x version of the module or uninstall the Apigee API Catalog module which will remove the module\'s current content and configuration then install the 2.x version. If you want to upgrade you will need to follow <a href=":link_issue">issue #80</a> for updates on the upgrade path functionality.', [
49+
':link_module' => 'https://github.com/apigee/apigee-api-catalog-drupal/issues/80',
50+
':link_issue' => 'https://github.com/apigee/apigee-api-catalog-drupal/issues/80',
51+
]),
52+
'severity' => REQUIREMENT_ERROR,
53+
],
54+
];
55+
}
56+
4157
return [];
4258
}
4359

@@ -85,3 +101,10 @@ function apigee_api_catalog_update_8701() {
85101
}
86102
}
87103
}
104+
105+
/**
106+
* Set module schema to 8801.
107+
*/
108+
function apigee_api_catalog_update_8801() {
109+
// Empty - only needed to set the 2.x module schema number.
110+
}

apigee_api_catalog.links.action.yml

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
entity.apidoc.add_form:
2-
route_name: entity.apidoc.add_form
1+
node.apidoc.add_form:
2+
route_name: node.add
33
title: 'Add API Doc'
4+
route_parameters:
5+
node_type: 'apidoc'
46
appears_on:
5-
- entity.apidoc.collection
7+
- view.api_catalog_admin.page_1

apigee_api_catalog.links.menu.yml

+3-36
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,6 @@
1-
entity.apidoc.collection:
1+
apigee_api_catalog.apidoc.collection:
22
title: 'API catalog'
3-
route_name: entity.apidoc.collection
3+
route_name: view.api_catalog_admin.page_1
44
description: 'List of all API documentation.'
55
parent: system.admin_content
6-
weight: 100
7-
8-
entity.apidoc.settings:
9-
title: 'API docs'
10-
description: 'Configure API doc entity settings.'
11-
route_name: entity.apidoc.settings
12-
parent: system.admin_structure
13-
14-
entity.apidoc.field_ui_fields:
15-
title: 'Manage fields'
16-
description: 'Manage fields for the apidoc entity.'
17-
route_name: entity.apidoc.field_ui_fields
18-
parent: entity.apidoc.settings
19-
weight: 10
20-
21-
entity.entity_form_display.apidoc:
22-
title: 'Manage form display'
23-
description: 'Configure form display modes for apidoc entities.'
24-
route_name: entity.entity_form_display.apidoc.default
25-
parent: entity.apidoc.settings
26-
weight: 20
27-
28-
entity.entity_view_display.apidoc:
29-
title: 'Manage display'
30-
description: 'Configure view display modes for apidoc entities.'
31-
route_name: entity.entity_view_display.apidoc.default
32-
parent: entity.apidoc.settings
33-
weight: 30
34-
35-
entity.apidoc.add:
36-
title: 'Add API doc'
37-
route_name: entity.apidoc.add_form
38-
description: 'Menu link to add an apidoc entity.'
39-
parent: entity.apidoc.collection
6+
weight: 200

apigee_api_catalog.links.task.yml

+5-33
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,11 @@
1-
# API Doc routing definition
2-
entity.apidoc.settings:
3-
route_name: entity.apidoc.settings
4-
title: 'Settings'
5-
base_route: entity.apidoc.settings
6-
7-
entity.apidoc.canonical:
8-
route_name: entity.apidoc.canonical
9-
base_route: entity.apidoc.canonical
10-
title: 'View'
11-
12-
entity.apidoc.edit_form:
13-
route_name: entity.apidoc.edit_form
14-
base_route: entity.apidoc.canonical
15-
title: 'Edit'
16-
17-
entity.apidoc.delete_form:
18-
route_name: entity.apidoc.delete_form
19-
base_route: entity.apidoc.canonical
20-
title: 'Delete'
21-
weight: 10
22-
231
apidoc.admin:
242
title: API catalog
25-
route_name: entity.apidoc.collection
3+
route_name: view.api_catalog_admin.page_1
264
base_route: system.admin_content
275
weight: 10
286

29-
entity.apidoc.version_history:
30-
route_name: entity.apidoc.version_history
31-
base_route: entity.apidoc.canonical
32-
title: 'Revisions'
33-
weight: 15
34-
35-
entity.apidoc.reimport_spec_form:
36-
route_name: entity.apidoc.reimport_spec_form
37-
base_route: entity.apidoc.canonical
7+
entity.node.apidoc.reimport_spec_form:
8+
route_name: entity.node.reimport_spec_form
9+
base_route: entity.node.canonical
3810
title: 'Re-import OpenAPI spec'
39-
weight: 15
11+
weight: 30

0 commit comments

Comments
 (0)