jknack on 2.x
Add FUNDING/sponsor file (compare)
jknack on 2.x
App should return 400 code if f… Merge pull request #2612 from e… (compare)
NettyPush
?
I am trying to use the openapi annotation to create swagger doc, not sure how to work with the parameters when using script api
Here is the code i am using , and it failed during maven build
Please help. Thanks.
code
public class App extends Jooby {
{
install(new GsonModule());
install(new OpenAPIModule());
get("/test/test", this::test);
}
public static void main(final String[] args) {
runApp(args, App::new);
}
@Operation(
description = "test",
parameters = {@Parameter(name = "token", in = ParameterIn.QUERY)},
requestBody = @RequestBody(content = @Content(schema = @Schema(implementation = ApiRequest.class)))
)
public ApiRequest test(
Context ctx) {
ctx.setResponseType(MediaType.json);
return new ApiRequest();
}
}
error
[ERROR] Failed to execute goal io.jooby:jooby-maven-plugin:2.9.5:openapi (default) on project swagger-test: execution of openapi resulted in exception: Parameter not found: token at position: 0 for annotation: {name=token, in=[Ljava.lang.String;@1f018dd} -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal io.jooby:jooby-maven-plugin:2.9.5:openapi (default) on project swagger-test: execution of openapi resulted in exception
......
Caused by: org.apache.maven.plugin.MojoFailureException: execution of openapi resulted in exception
at io.jooby.maven.BaseMojo.execute(BaseMojo.java:83)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
... 24 more
Caused by: java.lang.IllegalArgumentException: Parameter not found: token at position: 0 for annotation: {name=token, in=[Ljava.lang.String;@1f018dd}
at io.jooby.internal.openapi.OpenAPIParser.parameters(OpenAPIParser.java:450)
at io.jooby.internal.openapi.OpenAPIParser.lambda$operation$57(OpenAPIParser.java:380)
at io.jooby.internal.openapi.AsmUtils.annotationList(AsmUtils.java:108)
at io.jooby.internal.openapi.OpenAPIParser.operation(OpenAPIParser.java:380)
......
@jknack would fixing jooby-project/jooby#2252 be as easy as switching that constructor parameter in
NettyPush
?
If so, I could easily raise a PR to that effect.
Hello Guys,
i am new to jooby graphql development
i referenced below jooby graphql-starter example to setup the graphql server with java
https://github.com/jooby-project/jooby/tree/2.x/starters/graphql-starter
i have some doubts related to the setting up the graphql resolvers context with jooby server setup
As per the project requirements i need to set the databases sessions and some information in graphql context which also need a way to get the same context reference in datafetcher used in above example
anyone have suggestions or workarounds regarding same?
I am trying to use the openapi annotation to create swagger doc, not sure how to work with the parameters when using script api
Here is the code i am using , and it failed during maven buildPlease help. Thanks.
code
public class App extends Jooby { { install(new GsonModule()); install(new OpenAPIModule()); get("/test/test", this::test); } public static void main(final String[] args) { runApp(args, App::new); } @Operation( description = "test", parameters = {@Parameter(name = "token", in = ParameterIn.QUERY)}, requestBody = @RequestBody(content = @Content(schema = @Schema(implementation = ApiRequest.class))) ) public ApiRequest test( Context ctx) { ctx.setResponseType(MediaType.json); return new ApiRequest(); } }
error
[ERROR] Failed to execute goal io.jooby:jooby-maven-plugin:2.9.5:openapi (default) on project swagger-test: execution of openapi resulted in exception: Parameter not found: token at position: 0 for annotation: {name=token, in=[Ljava.lang.String;@1f018dd} -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal io.jooby:jooby-maven-plugin:2.9.5:openapi (default) on project swagger-test: execution of openapi resulted in exception ...... Caused by: org.apache.maven.plugin.MojoFailureException: execution of openapi resulted in exception at io.jooby.maven.BaseMojo.execute(BaseMojo.java:83) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210) ... 24 more Caused by: java.lang.IllegalArgumentException: Parameter not found: token at position: 0 for annotation: {name=token, in=[Ljava.lang.String;@1f018dd} at io.jooby.internal.openapi.OpenAPIParser.parameters(OpenAPIParser.java:450) at io.jooby.internal.openapi.OpenAPIParser.lambda$operation$57(OpenAPIParser.java:380) at io.jooby.internal.openapi.AsmUtils.annotationList(AsmUtils.java:108) at io.jooby.internal.openapi.OpenAPIParser.operation(OpenAPIParser.java:380) ......
Did you manage to sort this out? I get the same issue with 2.9.5 where I cannot add any parameters. I have followed the docs to the tee but with no luck.
Or is there any other working examples on how to get the parameters into the swagger openapi.json
Here is even a more basic one that still gives the issue:
@GET
@Operation(
summary = "Find a pet by ID",
description = "Find a pet by ID or throws a 404",
parameters = { @Parameter(name = "id", description = "Pet ID") }
)
public String test(){
return "Bla";
}
Then I also get the following error:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':openAPI'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$3.accept(ExecuteActionsTaskExecuter.java:166)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$3.accept(ExecuteActionsTaskExecuter.java:163)
at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:191)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:156)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:62)
...
Here is even a more basic one that still gives the issue:
@GET @Operation( summary = "Find a pet by ID", description = "Find a pet by ID or throws a 404", parameters = { @Parameter(name = "id", description = "Pet ID") } ) public String test(){ return "Bla"; }
Then I also get the following error:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':openAPI'. at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$3.accept(ExecuteActionsTaskExecuter.java:166) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$3.accept(ExecuteActionsTaskExecuter.java:163) at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:191) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:156) at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:62) ...
try this
@GET
@Operation(
summary = "Find a pet by ID",
description = "Find a pet by ID or throws a 404",
parameters = { @Parameter(name = "id", description = "Pet ID") }
)
public String test(@QueryParam String id){
return "Bla";
}
Here is even a more basic one that still gives the issue:
@GET @Operation( summary = "Find a pet by ID", description = "Find a pet by ID or throws a 404", parameters = { @Parameter(name = "id", description = "Pet ID") } ) public String test(){ return "Bla"; }
Then I also get the following error:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':openAPI'. at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$3.accept(ExecuteActionsTaskExecuter.java:166) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$3.accept(ExecuteActionsTaskExecuter.java:163) at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:191) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:156) at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:62) ...
try this
@GET @Operation( summary = "Find a pet by ID", description = "Find a pet by ID or throws a 404", parameters = { @Parameter(name = "id", description = "Pet ID") } ) public String test(@QueryParam String id){ return "Bla"; }
Still no luck my side:
@GET
@Operation(
summary = "Find a pet by ID",
description = "Find a pet by ID or throws a 404",
parameters = { @Parameter(name = "id", description = "Pet ID") }
)
public String test(@QueryParam String id){
return "Bla";
}
Execution failed for task ':openAPI'.
> Parameter not found: id at position: 0 for annotation: {in=[Ljava.lang.String;@6b20ffcf, name=id, description=Pet ID}
* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':openAPI'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$3.accept(ExecuteActionsTaskExecuter.java:166)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$3.accept(ExecuteActionsTaskExecuter.java:163)
at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:191)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:156)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:62)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:108)
at org.gradle.api.internal.tasks.execution.ResolveBeforeExecutionOutputsTaskExecuter.execute(ResolveBeforeExecutionOutputsTaskExecuter.java:67)
at org.gradle.api.internal.tasks.execution.ResolveAfterPreviousExecutionStateTaskExecuter.execute(ResolveAfterPreviousExecutionStateTaskExecuter.java:46)
at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:94)
at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46)
at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:95)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:56)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)
at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:77)
at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:55)
at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.ja
Hi folks, someone has already create a Unit Test for resource with an App that use the Hikari Module ?
I follow this link jooby-project/jooby#1891 but I don't understand how to mock Hikari ?
For me it's not possible due to this line (https://github.com/jooby-project/jooby/blob/34eb70cf2583e317d3c77f94d165bc8be7520bb5/modules/jooby-hikari/src/main/java/io/jooby/hikari/HikariModule.java#L209).
My App.java
code :
public class App extends Jooby {
{
install(new HikariModule());
[...]
}
}
The unit test execute the new HikariModule()
that try to create a connection to a database...
My unit test method :
@Test
@SneakyThrows
void getSensors() {
final var router = new MockRouter( new App());
}
Hi! I'm having some issues combining dynamic routing (mount with predicates) and DI with Guice and mvc() primitives.
This is throwing "Service not found" exception
public class V1 extends Jooby {
{
install(new GuiceModule());
mvc(PingController.mvc);
}
}
public class App extends Jooby {
{
mount(ctx -> ctx.header("version").value().equals("v1"), new V1());
}
}
curl localhost:8080/ping
io.jooby.exception.RegistryException: Service not found: project.controllers.PingController
How can I solve it?
@Module
public class App extends Jooby {
public App() {
setContextAsService(true);
install(new GracefulShutdown());
install(new OpenAPIModule());
decorator(new AccessLogHandler());
decorator(new CorsHandler());
// decorator(new TracingHandler());
var endpointFactory = HelloEndpoint_Factory.create(() -> require(Context.class));
mvc(HelloEndpoint.class, endpointFactory);
}
@Provides
public Context bindEndpoint() {
return require(Context.class);
}
I have this SSE code but the server does not send events to the browser:
sse("/events/{eventId}", sse -> {
// if we go down, recover from last event ID we sent. Otherwise, start from zero.
int lastId = OptionalInt.of(sse.lastEventId(Integer.class)).orElse(0);
AtomicInteger next = new AtomicInteger(lastId);
ScheduledFuture<?> future = executor.scheduleAtFixedRate(() -> {
Integer id = next.incrementAndGet();
String data = "test " + id;
sse.send(data);
// sse.send(
// new ServerSentMessage(data)
// .setId(id)
// .setRetry(1000L)
// );
}, 0, 1, TimeUnit.SECONDS);
sse.keepAlive(15, TimeUnit.SECONDS);
sse.onClose(() -> {
future.cancel(true);
});
});
And another question how do you get the path parameter within an SSE, like how can I get the eventId
in this case?