diff --git a/.github/workflows/build_swagger.yml b/.github/workflows/build_swagger.yml
deleted file mode 100644
index 3d2f764132..0000000000
--- a/.github/workflows/build_swagger.yml
+++ /dev/null
@@ -1,31 +0,0 @@
-name: build Swagger documentation
-
-on:
- push:
- branches: [ "main", "develop" ]
- pull_request:
- branches: [ "main", "develop" ]
-
-jobs:
- build:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v4
- - name: Setup Maven and Java Action
- uses: s4u/setup-maven-action@v1.18.0
- with:
- java-version: '17'
- maven-version: '3.9.6'
- - name: Get swagger.json
- run: |
- cd ./services/alarm-logger
- mvn spring-boot:run &
- export jobpid="$!"
- sleep 30
- curl http://localhost:8080/v3/api-docs --output ../../docs/swagger.json
- kill "$jobpid"
- - name: Archive swagger.json
- uses: actions/upload-artifact@v4
- with:
- name: swagger.json
- path: docs/swagger.json
diff --git a/docs/pyproject.toml b/docs/pyproject.toml
index d96626d560..15e23d781f 100644
--- a/docs/pyproject.toml
+++ b/docs/pyproject.toml
@@ -8,6 +8,7 @@ dependencies = [
"sphinx_rtd_theme>=3.0",
"myst-parser>=4.0",
"setuptools",
+ "sphinxcontrib.openapi"
]
[tool.pixi.workspace]
diff --git a/docs/source/_ext/safe_openapi.py b/docs/source/_ext/safe_openapi.py
new file mode 100644
index 0000000000..ff55d55862
--- /dev/null
+++ b/docs/source/_ext/safe_openapi.py
@@ -0,0 +1,37 @@
+import os
+from docutils import nodes
+from docutils.parsers.rst import Directive
+from sphinx.util.nodes import nested_parse_with_titles
+
+class SafeOpenApiDirective(Directive):
+ """
+ Usage :
+ .. safe_openapi:: path/to/openapi.yaml
+ """
+ required_arguments = 1
+
+ def run(self):
+ env = self.state.document.settings.env
+ docdir = os.path.dirname(env.doc2path(env.docname))
+
+ # Argument from the directive
+ openapi_path = self.arguments[0]
+
+ # Find absolute path
+ full_path = os.path.normpath(os.path.join(docdir, openapi_path))
+
+ if os.path.exists(full_path):
+ # add the normal `openapi` directive
+ node = nodes.paragraph()
+ directive_text = f".. openapi:: {openapi_path}\n"
+ self.state_machine.insert_input([directive_text], self.state_machine.input_lines.source(0))
+ return []
+ else:
+ # add file not found
+ warning = nodes.paragraph(text=f"OpenAPI file {openapi_path} not found")
+ return [warning]
+
+
+def setup(app):
+ app.add_directive("safe_openapi", SafeOpenApiDirective)
+ return {"version": "1.0"}
diff --git a/docs/source/conf.py b/docs/source/conf.py
index 600ab1a195..dbef061c24 100644
--- a/docs/source/conf.py
+++ b/docs/source/conf.py
@@ -30,8 +30,10 @@
# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = [
+ "sphinxcontrib.openapi",
"myst_parser",
"preferences_listing",
+ "safe_openapi"
]
# Add any paths that contain templates here, relative to this directory.
diff --git a/services/alarm-logger/doc/index.rst b/services/alarm-logger/doc/index.rst
index 12a6bfa5f0..635384a036 100644
--- a/services/alarm-logger/doc/index.rst
+++ b/services/alarm-logger/doc/index.rst
@@ -47,4 +47,10 @@ The automatic purge is run using a cron expression defined in preference ``purge
An Elasticsearch index is considered eligible for deletion if the last inserted message date is before current time
minus the number of days computed from ``date_span_units`` and ``retain_indices_count``.
+***
+API
+***
+.. safe_openapi:: ../../../../../services/alarm-logger/target/spec-open-api.json
+
+
.. _SpringDocumentation: https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/scheduling/support/CronExpression.html
\ No newline at end of file
diff --git a/services/alarm-logger/pom.xml b/services/alarm-logger/pom.xml
index 0e6b10b68a..5980d534f9 100644
--- a/services/alarm-logger/pom.xml
+++ b/services/alarm-logger/pom.xml
@@ -173,6 +173,49 @@
+
+
+ io.github.kbuntrock
+ openapi-maven-plugin
+ 0.0.28
+
+
+ documentation
+
+ documentation
+
+
+
+
+
+
+ SPRING_MVC
+ json
+
+
+ RestController
+
+
+
+
+
+
+
+ src/main/java
+
+
+
+
+
+
+
+ org.phoebus.alarm.logging
+
+
+
+
+
+
diff --git a/services/alarm-logger/src/main/java/org/phoebus/alarm/logging/rest/SearchController.java b/services/alarm-logger/src/main/java/org/phoebus/alarm/logging/rest/SearchController.java
index 9ad6991ce7..771a594186 100644
--- a/services/alarm-logger/src/main/java/org/phoebus/alarm/logging/rest/SearchController.java
+++ b/services/alarm-logger/src/main/java/org/phoebus/alarm/logging/rest/SearchController.java
@@ -103,7 +103,7 @@ public List search(@Parameter(hidden = true) @RequestParam Map<
@Operation(summary = "Search alarms by PV name")
@RequestMapping(value = "/search/alarm/pv/{pv}", method = RequestMethod.GET)
- public List searchPv(@Parameter(description = "PV name") @PathVariable String pv) {
+ public List searchPv(@Parameter(name="pv", description = "PV name") @PathVariable String pv) {
Map searchParameters = new HashMap<>();
searchParameters.put("pv", pv);
List result = AlarmLogSearchUtil.search(ElasticClientHelper.getInstance().getClient(), searchParameters);