I would like to share routes that are already linked via tags via the “selected server”. clarify:
{
"openapi": "3.1.0",
"info": {
"title": "blue_traktor_api",
"description": "This API handles various functionalities for USEPI, Icons, Dashboard, Settings, Patterns, Devices, Widgets, and more.",
"version": "0.1.0",
"contact": {
"name": "API Support",
"url": "",
"email": ""
}
},
"servers": [
{
"url": "http://localhost:8000",
"description": "TCP server for main operations"
},
{
"url": "ws://localhost:8080",
"description": "WebSocket server for updated parameters"
}
],
"paths": {...},
"components":{...}
}
here is the first part of my openal file.json where I list servers. it will look like this:
and I also have several routes for example:
"paths": {
"/api/usepi/patterns/create": {
"post": {
"tags": ["patterns"],
"summary": "Create a new pattern",
"operationId": "createPattern",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/RequestStructure_PatternRequest"
},
"examples": {
"PatternExample": {
"summary": "An example of a PatternRequest",
"value": {
"data": {
"id": null,
"title": "test",
"description": "test desc",
"icon": "http://localhost:8000/api/icons/test.svg",
"createDate": null,
"updateDate": null,
"favourite": false,
"data": {
"ID": {},
"QR-Code": {},
"Position": {},
"DeviceParams": {}
}
}
}
}
}
}
}
},
"responses": {
"200": {
"description": "Pattern created.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/GoodResponse_Id"
}
}
}
},
"500": {
"description": "Internal Server Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
}
}
}
}, ...
}
and there are still such routes, but with a different tag:
"/api/widgets/get": {
"post": {
"tags": ["widgets"],
"summary": "Get widget details",
"operationId": "getWidget",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/RequestStructure_Id"
}
}
}
},
"responses": {
"200": {
"description": "Widget details.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/GoodResponse_GetWidgetResponse"
}
}
}
},
"500": {
"description": "Internal Server Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
}
}
}
},
I would like that when selecting a server, only the routes associated with it are shown. for example, if http://localhost:8000 then /api/usepi/patterns/create …
where I need to, I also got rid of the try it button and the parameter block in this way:
<script>
window.onload = function() {
const ui = SwaggerUIBundle({
url: "http://localhost:8000/openai.json",
dom_id: '#swagger-ui',
deepLinking: true,
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
layout: "StandaloneLayout"
});
window.ui = ui;
function hideTryItOutButtons() {
const pathsToDisable = [
'#operations-patterns-createPattern > div.no-margin > div > div.opblock-section > div.opblock-section-header > div.try-out > button',
'#operations-patterns-createPattern > div.no-margin > div > div.opblock-section > div.opblock-section-header',
'#operations-patterns-createPattern > div.no-margin > div > div.opblock-section > div.parameters-container', ];
pathsToDisable.forEach(selector => {
const button = document.querySelector(selector);
if (button) {
button.style.display = 'none';
}
});
}
const observer = new MutationObserver(hideTryItOutButtons);
observer.observe(document.getElementById('swagger-ui'), { childList: true, subtree: true });
hideTryItOutButtons();
};
</script>
This is what it looks like:
how can I make the display of only the necessary routes, if (as far as I remember) you can’t do subtags for tags? show routes when selecting a server, also grouping by tags*