Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add openapi support #698

Draft
wants to merge 32 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
1cd23de
install `docusaurus-plugin-openapi-docs` and `docusaurus-theme-openap…
Maschga Dec 25, 2024
246639b
update scripts
Maschga Dec 25, 2024
86972d1
Delete babel.config.js
Maschga Dec 25, 2024
8ff7f2d
Create _category_.json
Maschga Dec 25, 2024
689f83b
configure plugin
Maschga Dec 25, 2024
f47a40c
wip: rest-api.yaml
Maschga Dec 25, 2024
ec8261f
Update _category_.json
Maschga Dec 28, 2024
fd93826
Revert "configure plugin"
Maschga Jan 1, 2025
73e35b3
remove openapi-plugin
Maschga Jan 1, 2025
4586027
fix regex
Maschga Jan 1, 2025
ada02ff
setup swagger-ui
Maschga Jan 1, 2025
60d4e37
configure swagger ui
Maschga Jan 1, 2025
fa71e7a
remove title
Maschga Jan 1, 2025
f0fd1e1
wip: rest-api.yaml
Maschga Jan 1, 2025
2d3a581
swagger styles
naltatis Jan 1, 2025
09d7171
merge
naltatis Jan 1, 2025
7667bf8
wip: rest-api.yaml
Maschga Jan 2, 2025
68f2b1f
format and configure swagger ui
Maschga Jan 2, 2025
632dfd5
wip: rest-api.yaml
Maschga Jan 3, 2025
ffee2e2
wip: rest-api.yaml
Maschga Jan 3, 2025
ae4d20d
wip: rest-api.yaml
Maschga Jan 4, 2025
57b7b32
update docusaurus
Maschga Jan 6, 2025
440ac8f
add generateOpenApiFile.js
Maschga Jan 6, 2025
34cdb87
ignore generated files
Maschga Jan 6, 2025
cb3417d
add swagger ui to en docs
Maschga Jan 6, 2025
f085e3f
wip: rest-api.yaml
Maschga Jan 6, 2025
72da8e9
wip: rest-api.yaml
Maschga Jan 6, 2025
829a405
wip: rest-api.yaml
Maschga Jan 19, 2025
58318c5
remove documentation
Maschga Jan 19, 2025
ba1b37b
wip: rest-api.yaml
Maschga Jan 19, 2025
f1b1321
enable more request-snippets
Maschga Jan 19, 2025
5f9263c
wip: rest-api.yaml
Maschga Jan 19, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
# Generated files
.docusaurus
.cache-loader
/static/rest-api.yaml
/static/swagger-ui.css

# Misc
.DS_Store
Expand Down
3 changes: 0 additions & 3 deletions babel.config.js

This file was deleted.

65 changes: 0 additions & 65 deletions docs/integrations/rest-api.md

This file was deleted.

18 changes: 18 additions & 0 deletions docs/integrations/rest-api.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
sidebar_position: 1
---

import SwaggerUIWrapper from "../../src/components/SwaggerUiWrapper";

# REST API

Die HTTP REST API ist ein einfaches Interface um automatisiert Einstellungen zu ändern.
Diese Schnittstelle wird auch von der Weboberfläche genutzt.

<SwaggerUIWrapper
url="/rest-api.yaml"
showCommonExtensions
displayRequestDuration
defaultModelsExpandDepth={-1}
requestSnippetsEnabled={true}
/>

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
sidebar_position: 1
---

import SwaggerUIWrapper from "../../../../../src/components/SwaggerUiWrapper";

# REST API

The HTTP REST API is a simple interface for automatically changing settings.
This interface is also used by the web interface.

<SwaggerUIWrapper
url="/rest-api.yaml"
showCommonExtensions
displayRequestDuration
defaultModelsExpandDepth={-1}
/>
53 changes: 53 additions & 0 deletions openapi/generateOpenApiFile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Add a description of the referenced schema to each parameter that does not have a description field.

const fs = require("fs");
const yaml = require("js-yaml");

fs.readFile("./openapi/rest-api.yaml", "utf8", (err, data) => {
if (err) {
console.log("Error reading the file: ", err);
return;
}

const openapi = yaml.load(data);

function generateParameter(param) {
if (!param.description && param.schema && param.schema["$ref"]) {
const schemaName = param.schema.$ref.split("/").pop();
let schema = openapi.components.schemas[schemaName];
if (schema && schema.description) {
param.description = schema.description;
}
}
return param;
}

for (let url in openapi.paths) {
let pathItem = openapi.paths[url];

for (let method in pathItem) {
if (pathItem[method].parameters) {
for (let i = 0; i < pathItem[method].parameters.length; i++) {
pathItem[method].parameters[i] = generateParameter(
pathItem[method].parameters[i],
);
}
}
}
}

for (let paramName in openapi.components.parameters) {
let param = openapi.components.parameters[paramName];
openapi.components.parameters[paramName] = generateParameter(param);
}

console.log("Finished processing parameters");
const updatedYaml = yaml.dump(openapi);
fs.writeFile("./static/rest-api.yaml", updatedYaml, (err) => {
if (err) {
console.log("Error saving the modified file");
} else {
console.log("File saved successfully");
}
});
});
Loading