-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathInfrastructureApiServer.java
More file actions
37 lines (30 loc) · 1.37 KB
/
InfrastructureApiServer.java
File metadata and controls
37 lines (30 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package io.openapimcp.example.api;
import io.javalin.Javalin;
import io.javalin.openapi.OpenApiInfo;
import io.javalin.openapi.OpenApiServer;
import io.javalin.openapi.plugin.OpenApiPlugin;
import io.javalin.openapi.plugin.swagger.SwaggerPlugin;
public class InfrastructureApiServer {
public static void main(String[] args) {
Javalin app = Javalin.create(config -> {
config.registerPlugin(new OpenApiPlugin(pluginConfig -> {
pluginConfig.withDefinitionConfiguration((version, definition) -> {
definition.withInfo((OpenApiInfo info) -> {
info.setTitle("Infrastructure API");
info.setVersion("1.0.0");
});
definition.withServer((OpenApiServer server) -> {
server.setUrl("http://localhost:7070");
});
});
}));
config.registerPlugin(new SwaggerPlugin(swaggerConfig -> {
swaggerConfig.setUiPath("/swagger-ui");
}));
});
app.get("/vms", VmController::listVms);
app.post("/vms", VmController::createVm);
app.post("/vms/{name}/start", VmController::startVm);
app.start(7070);
}
}