Skip to content

Commit 84ae0b6

Browse files
committed
Improve OpenAPI experience
1 parent 217f5fc commit 84ae0b6

File tree

11 files changed

+115
-22
lines changed

11 files changed

+115
-22
lines changed

query-engine/docs/Parameters/uk.co.spudsoft.query.main.Parameters.adoc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,4 +207,10 @@ Note that the default value for the outputCacheDir is probably a bad choice for
207207
| [[enableBearerAuth]]enableBearerAuth
208208
| boolean
209209
| If set to false any basic auth header will be ignored.
210+
| [[openApiExplorerUrl]]openApiExplorerUrl
211+
| link:https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/String.html[String]
212+
| Get the URL to the minified OpenAPI Explorer JS that is to be used for displaying The API documentation.The default value is (something like) "https://unpkg.com/openapi-explorer@2.2.733/dist/browser/openapi-explorer.min.js".
213+
214+
215+
It is not usually necessary to set this.
210216
|===

query-engine/docs/query-engine-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ services:
5050
- 16686:16686
5151

5252
query-engine:
53-
image: ghcr.io/yaytay/query-engine-design-mode:0.0.46
53+
image: ghcr.io/yaytay/query-engine-design-mode:0.0.46-5-main
5454
ports:
5555
- 2000:8080
5656
volumes:

query-engine/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
<dependency>
100100
<groupId>uk.co.spudsoft</groupId>
101101
<artifactId>vertx-resteasy-helpers</artifactId>
102-
<version>0.0.25</version>
102+
<version>0.0.27</version>
103103
<exclusions>
104104
<exclusion>
105105
<groupId>jakarta.activation</groupId>

query-engine/src/main/java/uk/co/spudsoft/query/main/Main.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ protected Future<Integer> innerMain(String[] args, PrintStream stdout) {
514514
);
515515

516516
OpenAPIConfiguration openApiConfig = createOpenapiConfiguration(controllers);
517-
OpenApiHandler openApiHandler = new OpenApiHandler(this, openApiConfig, "/api");
517+
OpenApiHandler openApiHandler = new OpenApiHandler(this, openApiConfig, "/api", params.getOpenApiExplorerUrl());
518518
ModelConverters.getInstance(true).addConverter(new OpenApiModelConverter());
519519

520520
PipelineExecutor pipelineExecutor = new PipelineExecutorImpl(filterFactory, params.getSecrets());

query-engine/src/main/java/uk/co/spudsoft/query/main/Parameters.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,15 @@ public class Parameters {
246246
*/
247247
private String managementEndpointUrl;
248248

249+
/**
250+
* The URL to the minified OpenAPI Explorer JS that is to be used for displaying The API documentation.
251+
* <p>
252+
* The default value is (something like) "https://unpkg.com/openapi-explorer@2.2.733/dist/browser/openapi-explorer.min.js".
253+
* <p>
254+
* It is not usually necessary to set this.
255+
*/
256+
private String openApiExplorerUrl;
257+
249258
/**
250259
* Configuration of the session management for the UI and REST API.
251260
*/
@@ -929,6 +938,29 @@ public void setEnableBearerAuth(boolean enableBearerAuth) {
929938
this.enableBearerAuth = enableBearerAuth;
930939
}
931940

941+
/**
942+
* Get the URL to the minified OpenAPI Explorer JS that is to be used for displaying The API documentation.
943+
* The default value is (something like) "https://unpkg.com/openapi-explorer@2.2.733/dist/browser/openapi-explorer.min.js".
944+
* <p>
945+
* It is not usually necessary to set this.
946+
* @return the URL to the minified OpenAPI Explorer JS that is to be used for displaying The API documentation.
947+
*/
948+
public String getOpenApiExplorerUrl() {
949+
return openApiExplorerUrl;
950+
}
951+
952+
/**
953+
* Get the URL to the minified OpenAPI Explorer JS that is to be used for displaying The API documentation.
954+
* The default value is (something like) "https://unpkg.com/openapi-explorer@2.2.733/dist/browser/openapi-explorer.min.js".
955+
* <p>
956+
* It is not usually necessary to set this.
957+
*
958+
* @param openApiExplorerUrl the URL to the minified OpenAPI Explorer JS that is to be used for displaying The API documentation.
959+
*/
960+
public void setOpenApiExplorerUrl(String openApiExplorerUrl) {
961+
this.openApiExplorerUrl = openApiExplorerUrl;
962+
}
963+
932964
/**
933965
* Validate the provided parameters.
934966
*

query-engine/src/main/java/uk/co/spudsoft/query/main/Version.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public final class Version {
3434
/**
3535
* The project version, as set in the Maven pom.xml.
3636
*/
37-
public static final String MAVEN_PROJECT_VERSION = "0.0.45-12-main";
37+
public static final String MAVEN_PROJECT_VERSION = "0.0.46-5-main";
3838

3939
private Version() {
4040
}

query-engine/src/main/java/uk/co/spudsoft/query/pipeline/PipelineNodesTree.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,13 @@ private PipelineNodesTree() {
4949
@JsonSubTypes.Type(value = PipelineFile.class)
5050
})
5151
@Schema(description = """
52-
<P>
5352
Base class for pipelines and the directories that contain them.
54-
</P>
55-
""")
53+
"""
54+
, oneOf = {
55+
PipelineDir.class
56+
, PipelineFile.class
57+
}
58+
)
5659
public static class PipelineNode extends AbstractNode<PipelineNode> {
5760

5861
/**
@@ -103,11 +106,9 @@ public String getPath() {
103106
*/
104107
@Override
105108
@Schema(description = """
106-
<P>
107109
The children of the node.
108-
</P>
109110
<P>
110-
If this is null then the node is a file, otherwise it is a directory.
111+
If this is null then the node is a PipelineFile, otherwise it is a PipelineDir.
111112
</P>
112113
""")
113114
public List<PipelineNode> getChildren() {
@@ -195,9 +196,7 @@ public PipelineDir(String path, List<PipelineNode> children) {
195196
@Schema(nullable = false
196197
, requiredMode = Schema.RequiredMode.REQUIRED
197198
, description = """
198-
<P>
199199
The children of the directory.
200-
</P>
201200
""")
202201
public List<PipelineNode> getChildren() {
203202
return super.getChildren(); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/OverriddenMethodBody

query-engine/src/main/java/uk/co/spudsoft/query/web/rest/DocHandler.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,16 @@ public void getAvailable(
185185
@Operation(description = "Return some documentation")
186186
@ApiResponse(
187187
responseCode = "200"
188-
, description = "A documnent about Query Engine."
188+
, description = "A document about Query Engine."
189189
, content = @Content(mediaType = "text/markdown")
190190
)
191191
public void getDoc(
192192
@Suspended final AsyncResponse response
193-
, @PathParam("path") String path
193+
, @Schema(
194+
description = "The path to the document, as returned by a call to get /api/docs"
195+
)
196+
@PathParam("path")
197+
String path
194198
) {
195199

196200
try {

query-engine/src/main/java/uk/co/spudsoft/query/web/rest/DocNodesTree.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,12 @@ private DocNodesTree() {
4848
<P>
4949
Base class for documentation files and the directories that contain them.
5050
</P>
51-
""")
51+
"""
52+
, oneOf = {
53+
DocDir.class
54+
, DocFile.class
55+
}
56+
)
5257
public static class DocNode extends AbstractNode<DocNode> {
5358

5459
private final String path;

query-engine/src/main/java/uk/co/spudsoft/query/web/rest/FormIoHandler.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,20 @@ public FormIoHandler(PipelineDefnLoader loader, FilterFactory filterFactory, boo
137137
)
138138
public void getFormIO(
139139
@Suspended final AsyncResponse response
140-
, @PathParam("path") String path
141-
, @QueryParam("columns") Integer columns
140+
, @Schema(
141+
description = "The path to the quiery, as returned by a call to get /api/info/available"
142+
)
143+
@PathParam("path")
144+
String path
145+
, @Schema(
146+
description = "The number of columns to use when displaying arguments"
147+
, minimum = "1"
148+
, maximum = "12"
149+
, defaultValue = "1"
150+
, requiredMode = Schema.RequiredMode.NOT_REQUIRED
151+
)
152+
@QueryParam("columns")
153+
Integer columns
142154
) {
143155

144156
if (columns != null) {

0 commit comments

Comments
 (0)