dependabot[bot] on maven
dependabot[bot] on maven
build(deps): bump spotless-mave… (compare)
dependabot[bot] on maven
dependabot[bot] on maven
build(deps): bump tiles-maven-p… (compare)
dependabot[bot] on maven
12:19:50.294 [Test worker] INFO app.privitar.InvPortTest - [test]
└── system properties
└── env variables
└── conf/application.conf
└── defaults
class MyApp extends Jooby {
{
mvc(new MyController());
}
}
@jknack Here is my application code
@OpenAPIDefinition(
info = @Info(
title = "Title",
description = "description",
termsOfService = "Terms",
contact = @Contact(
name = "Jooby",
url = "https://jooby.io",
email = "support@jooby.io"
),
license = @License(
name = "Apache",
url = "https://jooby.io/LICENSE"
),
version = "10"
),
tags = @Tag(name = "mytag")
)
public class App extends Jooby{
public static void main(String[] args) {
Jooby.runApp(args, app -> {
// app name
app.setName(App.class.getSimpleName());
// configs
app.install(new AppConfig());
app.install(new RouterConfig());
});
}
}
here is the class that import the mvc controller
public class RouterConfig implements Extension {
@Override
public void install(@Nonnull Jooby app) throws Exception {
app.mvc(CustomerController.class);
}
}
here is the controller
@Path("/customer")
public class CustomerController {
@Operation(
summary = "Find a pet by ID",
description = "Find a pet by ID or throws a 404"
)
@Path("/v")
@GET
public Object test() {
return "!";
}
}
but the generated api specs return this
openapi: 3.0.1
info:
title: Title
description: description
termsOfService: Terms
contact:
name: Jooby
url: https://jooby.io
email: support@jooby.io
license:
name: Apache
url: https://jooby.io/LICENSE
version: "10"
tags:
- name: mytag
paths: {}
public class RouterConfig implements Extension {
@Override
public void install(@Nonnull Jooby app) throws Exception {
app.mvc(CustomerController.class);
}
}
public class App extends Jooby{
public static void main(String[] args) {
Jooby.runApp(args, app -> {
// app name
app.setName(App.class.getSimpleName());
// configs
app.install(new AppConfig());
app.mvc(CustomController.class);
});
}
}
i've work around this problem by move the OpenAPIDefinition to the RouterConfig class
@OpenAPIDefinition(
info = @Info(
title = "Title",
description = "description",
termsOfService = "Terms",
contact = @Contact(
name = "Jooby",
url = "https://jooby.io",
email = "support@jooby.io"
),
license = @License(
name = "Apache",
url = "https://jooby.io/LICENSE"
),
version = "10"
),
tags = @Tag(name = "mytag")
)
public class RouterConfig implements Extension {
@Override
public void install(@Nonnull Jooby app) throws Exception {
app.mvc(CustomerController.class);
}
}
and create my customized openapi module
public class CustomOpenAPIModule extends OpenAPIModule {
private Class<?> apiDefinitionClass;
public CustomOpenAPIModule(Class<?> apiDefinitionClass) {
super();
this.apiDefinitionClass = apiDefinitionClass;
}
@Override
public void install(@Nonnull Jooby application) throws Exception {
String dir = Optional.ofNullable(apiDefinitionClass.getPackage()).map(Package::getName).orElse("/").replace(".", "/");
String appname = apiDefinitionClass.getSimpleName();
Field fFormat = getClass().getSuperclass().getDeclaredField("format");
fFormat.setAccessible(true);
EnumSet<Format> format = (EnumSet<Format>) fFormat.get(this);
Field fopenAPIPath = getClass().getSuperclass().getDeclaredField("openAPIPath");
fopenAPIPath.setAccessible(true);
String openAPIPath = (String) fopenAPIPath.get(this);
for (Format ext : format) {
String filename = String.format("/%s.%s", appname, ext.name().toLowerCase());
String openAPIFileLocation = Router.normalizePath(dir) + filename;
application.assets(Router.noTrailingSlash(Router.normalizePath(openAPIPath + "/openapi." + ext.name().toLowerCase())), openAPIFileLocation);
}
Method mConfigureUI = getClass().getSuperclass().getDeclaredMethod("configureUI", Jooby.class);
mConfigureUI.setAccessible(true);
mConfigureUI.invoke(this, application);
}
}
and this is work fine except my code will be bad
public static void main(String[] args) {
Jooby.runApp(args, app -> {
// app name
app.setName(App.class.getSimpleName());
app.install(new GracefulShutdown());
app.decorator(new AccessLogHandler());
app.error(new HttpDefaultJsonHandler());
// metrics
app.install(new MetricsModule("/actuator")
.threadDump()
.ping()
.healthCheck("deadlock", new ThreadDeadlockHealthCheck())
.metric("memory", new MemoryUsageGaugeSet())
.metric("threads", new ThreadStatesGaugeSet())
.metric("gc", new GarbageCollectorMetricSet())
.metric("fs", new FileDescriptorRatioGauge())
);
// openapi
app.install(new CustomOpenAPIModule(RouterConfig.class));
// dependency injection
app.install(new GuiceModule(
// inject here
));
app.mvc(CustomerController.class);
});
}