Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
31 changes: 0 additions & 31 deletions .github/workflows/build_swagger.yml

This file was deleted.

1 change: 1 addition & 0 deletions docs/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ dependencies = [
"sphinx_rtd_theme>=3.0",
"myst-parser>=4.0",
"setuptools",
"sphinxcontrib.openapi"
]

[tool.pixi.workspace]
Expand Down
37 changes: 37 additions & 0 deletions docs/source/_ext/safe_openapi.py
Original file line number Diff line number Diff line change
@@ -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"}
2 changes: 2 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 6 additions & 0 deletions services/alarm-logger/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
43 changes: 43 additions & 0 deletions services/alarm-logger/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,49 @@
</execution>
</executions>
</plugin>
<!-- Plugin declaration -->
<plugin>
<groupId>io.github.kbuntrock</groupId>
<artifactId>openapi-maven-plugin</artifactId>
<version>0.0.28</version>
<executions>
<execution>
<id>documentation</id>
<goals>
<goal>documentation</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- This section defines the general configuration, which can be overriden for each generated document. -->
<apiConfiguration>
<library>SPRING_MVC</library> <!-- SPRING_MVC is the default value. Here this tag could be deleted. Other possible values are JAKARTA_RS and JAVAX_RS -->
<fileFormat>json</fileFormat>
<tagAnnotations> <!-- Only useful if you use Spring MVC -->
<!-- RestController is the default value, but can be replaced by RequestMapping -->
<annotation>RestController</annotation>
</tagAnnotations>
</apiConfiguration>
<!-- This section defines which folders contains the source code to be read to extract the javadoc. -->
<javadocConfiguration>
<scanLocations>
<!-- Other 'location' tag can be added to reference javadoc in other modules. -->
<!-- Path is relative to the project root path. -->
<location>src/main/java</location>
</scanLocations>
</javadocConfiguration>
<!-- This section defines a list of documentations to generate. In this exemple, only one is generated. -->
<apis>
<api>
<locations>
<!-- Replace here by a package relevant for your project. -->
<location>org.phoebus.alarm.logging</location>
</locations>
</api>
</apis>
</configuration>
</plugin>

</plugins>
</build>
</profile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public List<AlarmLogMessage> search(@Parameter(hidden = true) @RequestParam Map<

@Operation(summary = "Search alarms by PV name")
@RequestMapping(value = "/search/alarm/pv/{pv}", method = RequestMethod.GET)
public List<AlarmLogMessage> searchPv(@Parameter(description = "PV name") @PathVariable String pv) {
public List<AlarmLogMessage> searchPv(@Parameter(name="pv", description = "PV name") @PathVariable String pv) {
Map<String, String> searchParameters = new HashMap<>();
searchParameters.put("pv", pv);
List<AlarmLogMessage> result = AlarmLogSearchUtil.search(ElasticClientHelper.getInstance().getClient(), searchParameters);
Expand Down