Skip to content

Commit

Permalink
Merge branch 'external-elasticsearch-docs' of https://github.com/camu…
Browse files Browse the repository at this point in the history
…nda/camunda-docs into external-elasticsearch-docs
  • Loading branch information
hamza-m-masood committed Apr 5, 2024
2 parents dfb17d1 + a7fe264 commit 1577a62
Show file tree
Hide file tree
Showing 359 changed files with 11,214 additions and 1,789 deletions.
58 changes: 58 additions & 0 deletions api/generate-api-docs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
const { execSync } = require("child_process");

// More strategies to come, for other APIs.
const operate = require("./operate/generation-strategy");
const zeebe = require("./zeebe/generation-strategy");
const tasklist = require("./tasklist/generation-strategy");
const apiStrategies = {
operate,
zeebe,
tasklist,
};

// Execute a command as if we were in the terminal
function runCommand(command) {
const result = execSync(command, { stdio: "inherit" });
return result;
}

// API name must be passed in as an arg.
const api = process.argv[2];
if (api === undefined) {
const validAPIs = string.join(apiStrategies.join, ", ");
console.log(`Please specify an API name. Valid names: ${validAPIs}`);
process.exit();
}

// The API name must be recognized.
const strategy = apiStrategies[api];
if (strategy === undefined) {
const validAPIs = string.join(apiStrategies.join, ", ");
console.error(`Invalid API name ${api}. Valid names: ${validAPIs}`);
process.exit();
}

// All APIs will execute these same steps, with custom-per-API steps
// implemented by each API's generation-strategy.js.
const steps = [
// Remove old docs
() => runCommand(`docusaurus clean-api-docs ${api} -p api-${api}-openapi`),

// Run any custom steps before generation
strategy.preGenerateDocs,

// Generate the docs
() => runCommand(`docusaurus gen-api-docs ${api} -p api-${api}-openapi`),

// Run any custom steps after generation
strategy.postGenerateDocs,

// Run prettier against the generated docs. Twice. Yes, twice.
// I don't know why, but the first run always leaves an extra blank line,
// which the second execution removes.
() => runCommand(`prettier --write ${strategy.outputDir}`),
() => runCommand(`prettier --write ${strategy.outputDir}`),
];

// Run the steps!
steps.forEach((step) => step());
27 changes: 27 additions & 0 deletions api/make-server-dynamic.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const replace = require("replace-in-file");

function makeServerDynamic(specFile) {
// The source spec has a hardcoded generated server URL.
// We can make it dynamic so that the user can edit it and get more accurate code samples.
console.log("making server dynamic....");

// Note that `v1` is included in this path.
const dynamicServerDefinition = ` - url: "{schema}://{host}:{port}"
variables:
host:
default: localhost
description: The hostname of the API server.
port:
default: "8080"
description: The port of the API server.
schema:
default: http
description: The schema of the API server.`;
replace.sync({
files: specFile,
// This regex includes the following `description` line, which becomes inaccurate when we make the server dynamic.
from: /^. - url:.*\n. description:.*$/m,
to: dynamicServerDefinition,
});
}
exports.makeServerDynamic = makeServerDynamic;
19 changes: 19 additions & 0 deletions api/operate/generation-strategy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const { makeServerDynamic } = require("../make-server-dynamic");
const removeDuplicateVersionBadge = require("../remove-duplicate-version-badge");

const outputDir = "docs/apis-tools/operate-api/specifications";
const specFile = "api/operate/operate-openapi.yaml";

function preGenerateDocs() {
makeServerDynamic(specFile);
}

function postGenerateDocs() {
removeDuplicateVersionBadge(`${outputDir}/operate-public-api.info.mdx`);
}

module.exports = {
outputDir,
preGenerateDocs,
postGenerateDocs,
};
99 changes: 55 additions & 44 deletions api/operate/operate-openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,17 @@ info:
url: https://docs.camunda.io/docs/reference/licenses/
version: 1.0.0
servers:
- url: SERVER-URL
description: Generated server url
- url: "{schema}://{host}:{port}"
variables:
host:
default: localhost
description: The hostname of the API server.
port:
default: "8080"
description: The port of the API server.
schema:
default: http
description: The schema of the API server.
tags:
- name: ProcessDefinition
description: Process Definition API
Expand Down Expand Up @@ -89,8 +98,8 @@ paths:
application/problem+json:
schema:
"$ref": "#/components/schemas/Error"
"401":
description: Unauthorized
"403":
description: Forbidden
content:
"*/*":
schema:
Expand Down Expand Up @@ -173,8 +182,8 @@ paths:
application/problem+json:
schema:
"$ref": "#/components/schemas/Error"
"401":
description: Unauthorized
"403":
description: Forbidden
content:
"*/*":
schema:
Expand Down Expand Up @@ -266,8 +275,8 @@ paths:
application/problem+json:
schema:
"$ref": "#/components/schemas/Error"
"401":
description: Unauthorized
"403":
description: Forbidden
content:
"*/*":
schema:
Expand Down Expand Up @@ -367,8 +376,8 @@ paths:
application/problem+json:
schema:
"$ref": "#/components/schemas/Error"
"401":
description: Unauthorized
"403":
description: Forbidden
content:
"*/*":
schema:
Expand Down Expand Up @@ -464,8 +473,8 @@ paths:
application/problem+json:
schema:
"$ref": "#/components/schemas/Error"
"401":
description: Unauthorized
"403":
description: Forbidden
content:
"*/*":
schema:
Expand Down Expand Up @@ -558,8 +567,8 @@ paths:
application/problem+json:
schema:
"$ref": "#/components/schemas/Error"
"401":
description: Unauthorized
"403":
description: Forbidden
content:
"*/*":
schema:
Expand Down Expand Up @@ -650,8 +659,8 @@ paths:
application/problem+json:
schema:
"$ref": "#/components/schemas/Error"
"401":
description: Unauthorized
"403":
description: Forbidden
content:
"*/*":
schema:
Expand Down Expand Up @@ -742,8 +751,8 @@ paths:
application/problem+json:
schema:
"$ref": "#/components/schemas/Error"
"401":
description: Unauthorized
"403":
description: Forbidden
content:
"*/*":
schema:
Expand Down Expand Up @@ -790,8 +799,8 @@ paths:
application/problem+json:
schema:
"$ref": "#/components/schemas/Error"
"401":
description: Unauthorized
"403":
description: Forbidden
content:
"*/*":
schema:
Expand Down Expand Up @@ -838,8 +847,8 @@ paths:
application/problem+json:
schema:
"$ref": "#/components/schemas/Error"
"401":
description: Unauthorized
"403":
description: Forbidden
content:
"*/*":
schema:
Expand Down Expand Up @@ -885,8 +894,8 @@ paths:
application/problem+json:
schema:
"$ref": "#/components/schemas/Error"
"401":
description: Unauthorized
"403":
description: Forbidden
content:
"*/*":
schema:
Expand Down Expand Up @@ -937,8 +946,8 @@ paths:
application/problem+json:
schema:
"$ref": "#/components/schemas/Error"
"401":
description: Unauthorized
"403":
description: Forbidden
content:
"*/*":
schema:
Expand Down Expand Up @@ -987,8 +996,8 @@ paths:
application/problem+json:
schema:
"$ref": "#/components/schemas/Error"
"401":
description: Unauthorized
"403":
description: Forbidden
content:
"*/*":
schema:
Expand Down Expand Up @@ -1035,8 +1044,8 @@ paths:
application/problem+json:
schema:
"$ref": "#/components/schemas/Error"
"401":
description: Unauthorized
"403":
description: Forbidden
content:
"*/*":
schema:
Expand Down Expand Up @@ -1083,8 +1092,8 @@ paths:
application/problem+json:
schema:
"$ref": "#/components/schemas/Error"
"401":
description: Unauthorized
"403":
description: Forbidden
content:
"*/*":
schema:
Expand Down Expand Up @@ -1131,8 +1140,8 @@ paths:
application/problem+json:
schema:
"$ref": "#/components/schemas/Error"
"401":
description: Unauthorized
"403":
description: Forbidden
content:
"*/*":
schema:
Expand Down Expand Up @@ -1179,8 +1188,8 @@ paths:
application/problem+json:
schema:
"$ref": "#/components/schemas/Error"
"401":
description: Unauthorized
"403":
description: Forbidden
content:
"*/*":
schema:
Expand Down Expand Up @@ -1227,8 +1236,8 @@ paths:
application/problem+json:
schema:
"$ref": "#/components/schemas/Error"
"401":
description: Unauthorized
"403":
description: Forbidden
content:
"*/*":
schema:
Expand Down Expand Up @@ -1275,8 +1284,8 @@ paths:
application/problem+json:
schema:
"$ref": "#/components/schemas/Error"
"401":
description: Unauthorized
"403":
description: Forbidden
content:
"*/*":
schema:
Expand Down Expand Up @@ -1322,8 +1331,8 @@ paths:
application/problem+json:
schema:
"$ref": "#/components/schemas/Error"
"401":
description: Unauthorized
"403":
description: Forbidden
content:
"*/*":
schema:
Expand Down Expand Up @@ -1370,8 +1379,8 @@ paths:
application/problem+json:
schema:
"$ref": "#/components/schemas/Error"
"401":
description: Unauthorized
"403":
description: Forbidden
content:
"*/*":
schema:
Expand Down Expand Up @@ -1600,6 +1609,7 @@ components:
- MESSAGE_SIZE_EXCEEDED
- CALLED_DECISION_ERROR
- DECISION_EVALUATION_ERROR
- FORM_NOT_FOUND
message:
type: string
creationTime:
Expand All @@ -1608,6 +1618,7 @@ components:
type: string
enum:
- ACTIVE
- MIGRATED
- RESOLVED
- PENDING
jobKey:
Expand Down
12 changes: 0 additions & 12 deletions api/operate/operate-sidebars.js

This file was deleted.

Loading

0 comments on commit 1577a62

Please sign in to comment.