Skip to content

Commit

Permalink
add public-capella target
Browse files Browse the repository at this point in the history
create decorators to do munging in couchbase/docs-capella#58
  • Loading branch information
torcolvin committed Aug 6, 2024
1 parent 045ddbb commit 456edbb
Show file tree
Hide file tree
Showing 11 changed files with 164 additions and 23 deletions.
11 changes: 10 additions & 1 deletion .redocly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ apis:
root: "./docs/api/admin.yaml"
admin-capella:
root: "./docs/api/admin-capella.yaml"
decorators:
remove-x-internal: on
public:
root: "./docs/api/public.yaml"
decorators:
Expand All @@ -26,11 +28,14 @@ apis:
public-capella:
root: "./docs/api/public.yaml"
decorators:
remove-x-internal: on
filter-out:
property: x-capella
value: false
plugin/replace-servers-capella:
plugin/replace-server-capella:
serverUrl: 'https://{hostname}:4984'
plugin/replace-info-capella:
title: "App Services Public API"
metric:
root: "./docs/api/metric.yaml"
decorators:
Expand All @@ -39,6 +44,10 @@ apis:
root: "./docs/api/metric.yaml"
metric-capella:
root: "./docs/api/metric-capella.yaml"
decorators:
plugin/excise-rbac-capella: on
plugin/replace-description-capella: on
remove-x-internal: on
diagnostic:
root: "./docs/api/diagnostic.yaml"
decorators:
Expand Down
4 changes: 2 additions & 2 deletions docs/api/admin-capella.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

openapi: 3.0.3
info:
title: Sync Gateway
description: Sync Gateway manages access and synchronization between Couchbase Lite and Couchbase Server
title: App Services Admin API
description: 'App Services manages access and synchronization between Couchbase Lite and Couchbase Capella'
version: 3.3.0
license:
name: Business Source License 1.1 (BSL)
Expand Down
4 changes: 2 additions & 2 deletions docs/api/metric-capella.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

openapi: 3.0.3
info:
title: Sync Gateway
description: Sync Gateway manages access and synchronization between Couchbase Lite and Couchbase Server
title: App Services Metrics API
description: 'App Services manages access and synchronization between Couchbase Lite and Couchbase Capella'
version: 3.3.0
license:
name: Business Source License 1.1 (BSL)
Expand Down
32 changes: 32 additions & 0 deletions docs/api/plugins/decorators/excise-rbac-capella.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* Copyright 2024-Present Couchbase, Inc.
*
* Use of this software is governed by the Business Source License included
* in the file licenses/BSL-Couchbase.txt. As of the Change Date specified
* in that file, in accordance with the Business Source License, use of this
* software will be governed by the Apache License, Version 2.0, included in
* the file licenses/APL2.txt.
*/

/**
* Removes the RBAC roles from capella API docs. This expects the RBAC information to be at the end of the documentation string. This is not a robust way of doing this.
* @module ExciseRBACCapella
*/

module.exports = ExciseRBACCapella;

const re = new RegExp("Required Sync Gateway RBAC roles");

/** @type {import('@redocly/cli').OasDecorator} */
function ExciseRBACCapella() {
return {
Operation: {
leave(Operation) {
idx = Operation.description.search(re);
if (idx > 0) {
Operation.description = Operation.description.substr(0, idx);
}
},
},
};
}
30 changes: 30 additions & 0 deletions docs/api/plugins/decorators/replace-description-capella.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* Copyright 2024-Present Couchbase, Inc.
*
* Use of this software is governed by the Business Source License included
* in the file licenses/BSL-Couchbase.txt. As of the Change Date specified
* in that file, in accordance with the Business Source License, use of this
* software will be governed by the Apache License, Version 2.0, included in
* the file licenses/APL2.txt.
*/

/**
* Does a string replacement on all operations (GET,PUT,POST,etc) to replace Sync Gateway with App Services.
* @module ReplaceDescriptionCapella
*/

module.exports = ReplaceDescriptionCapella;

/** @type {import('@redocly/cli').OasDecorator} */
function ReplaceDescriptionCapella() {
return {
Operation: {
leave(Operation) {
Operation.description = Operation.description.replace(
"Sync Gateway",
"App Services",
);
},
},
};
}
31 changes: 31 additions & 0 deletions docs/api/plugins/decorators/replace-info-capella.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* Copyright 2024-Present Couchbase, Inc.
*
* Use of this software is governed by the Business Source License included
* in the file licenses/BSL-Couchbase.txt. As of the Change Date specified
* in that file, in accordance with the Business Source License, use of this
* software will be governed by the Apache License, Version 2.0, included in
* the file licenses/APL2.txt.
*/

/**
* Modifies the title of openapi object to value passed in.
* @module ReplaceInfoCapella
*/

module.exports = ReplaceInfoCapella;

/** @type {import('@redocly/cli').OasDecorator} */
function ReplaceInfoCapella({ title }) {
return {
Info: {
leave(Info) {
if (title) {
Info.title = title;
}
Info.description =
"App Services manages access and synchronization between Couchbase Lite and Couchbase Capella";
},
},
};
}
24 changes: 24 additions & 0 deletions docs/api/plugins/decorators/replace-server-capella.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* Copyright 2024-Present Couchbase, Inc.
*
* Use of this software is governed by the Business Source License included
* in the file licenses/BSL-Couchbase.txt. As of the Change Date specified
* in that file, in accordance with the Business Source License, use of this
* software will be governed by the Apache License, Version 2.0, included in
* the file licenses/APL2.txt.
*/

module.exports = ReplaceServersCapella;

/** @type {import('@redocly/cli').OasDecorator} */
function ReplaceServersCapella({ serverUrl }) {
return {
Server: {
leave(Server) {
if (serverUrl) {
Server.url = serverUrl;
}
},
},
};
}
9 changes: 0 additions & 9 deletions docs/api/plugins/decorators/replace-servers-capella.js

This file was deleted.

31 changes: 22 additions & 9 deletions docs/api/plugins/plugin.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
const ReplaceServersCapella = import("./decorators/replace-servers-capella.js");
const id = "plugin";
/**
* Copyright 2024-Present Couchbase, Inc.
*
* Use of this software is governed by the Business Source License included
* in the file licenses/BSL-Couchbase.txt. As of the Change Date specified
* in that file, in accordance with the Business Source License, use of this
* software will be governed by the Apache License, Version 2.0, included in
* the file licenses/APL2.txt.
*/

const decorators = {
oas3: {
"replace-servers-capella": ReplaceServersCapella,
},
};
const ExciseRBACCapella = require("./decorators/excise-rbac-capella.js");
const ReplaceDescriptionCapella = require("./decorators/replace-description-capella.js");
const ReplaceInfoCapella = require("./decorators/replace-info-capella.js");
const ReplaceServerCapella = require("./decorators/replace-server-capella.js");

module.exports = {
decorators,
id,
decorators: {
oas3: {
"excise-rbac-capella": ExciseRBACCapella,
"replace-description-capella": ReplaceDescriptionCapella,
"replace-info-capella": ReplaceInfoCapella,
"replace-server-capella": ReplaceServerCapella,
},
},
id: "plugin",
};
1 change: 1 addition & 0 deletions docs/api/public.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ tags:
description: Create and manage document attachments
- name: Replication
description: Create and manage inter-Sync Gateway replications
x-capella: false
- name: Unsupported
description: Endpoints that are not supported by Sync Gateway
x-capella: false
Expand Down
10 changes: 10 additions & 0 deletions docs/api/replace-servers-capella.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
/**
* Copyright 2024-Present Couchbase, Inc.
*
* Use of this software is governed by the Business Source License included
* in the file licenses/BSL-Couchbase.txt. As of the Change Date specified
* in that file, in accordance with the Business Source License, use of this
* software will be governed by the Apache License, Version 2.0, included in
* the file licenses/APL2.txt.
*/

module.exports = ReplaceServersCapella;

/** @type {import('@redocly/cli').OasDecorator} */
Expand Down

0 comments on commit 456edbb

Please sign in to comment.