Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 01:26
    Blquinn commented #2779
  • Jan 30 02:33
    jknack commented #2779
  • Jan 30 01:33
    Blquinn edited #2779
  • Jan 30 01:31
    Blquinn opened #2779
  • Jan 30 00:08

    dependabot[bot] on maven

    (compare)

  • Jan 30 00:08
    dependabot[bot] closed #2769
  • Jan 30 00:08
    dependabot[bot] commented #2769
  • Jan 30 00:08
    dependabot[bot] labeled #2778
  • Jan 30 00:08
    dependabot[bot] labeled #2778
  • Jan 30 00:08
    dependabot[bot] opened #2778
  • Jan 30 00:08

    dependabot[bot] on maven

    build(deps): bump spotless-mave… (compare)

  • Jan 30 00:04

    dependabot[bot] on maven

    (compare)

  • Jan 30 00:04
    dependabot[bot] closed #2770
  • Jan 30 00:04
    dependabot[bot] commented #2770
  • Jan 30 00:04
    dependabot[bot] labeled #2777
  • Jan 30 00:04
    dependabot[bot] labeled #2777
  • Jan 30 00:04
    dependabot[bot] opened #2777
  • Jan 30 00:04

    dependabot[bot] on maven

    build(deps): bump tiles-maven-p… (compare)

  • Jan 30 00:04

    dependabot[bot] on maven

    (compare)

  • Jan 30 00:04
    dependabot[bot] closed #2775
Edgar Espina
@jknack
thank you
Emmanuel Oga
@EmmanuelOga
I've never used spring before, seems pretty crazy haha. It is weird because there seems to be a lot of "spring refugees" out there, but at the same time it feels like it has a massive user base. Maybe a lot of enterprise usage
Edgar Espina
@jknack
yea enterprise and bc the Java community is lazy
:D
Emmanuel Oga
@EmmanuelOga
jeje
Kelvin Law
@lawkai
hi, completely new to this, how do we serve favicon using jooby? Thanks
Mészáros István
@imeszaros
hi @lawkai , try the static asset handlers: https://jooby.io/#static-files
Kelvin Law
@lawkai
thanks @imeszaros
Cosimo Damiano Prete
@cdprete

Hi.
I'm using the MockRouter (1.6.3) and somehow it doesn't load the modules that I create with use.

Do you have any idea why?

Edgar Espina
@jknack
is there a mockrouter in 1.6.3? don’t remember
but if we have one… yes, module won’t be loaded it
that is not the intention/goal of unit tests
Edgar Espina
@jknack
Will
@williamjtodd
Hi. For some reason I'm not getting my logback.test.xml loaded when I'm running tests. I am setting application.env=test when running (intellij). Is there something I'm missing (the result is I can't filter out log levels - everything gets logged...) Thanks.
12:19:50.294 [Test worker] INFO app.privitar.InvPortTest - [test] └── system properties └── env variables └── conf/application.conf └── defaults
Edgar Espina
@jknack
hmm yea, probably we don’t bootstrap logback from tests
Will
@williamjtodd
Is there a suggested way to get it loaded?
Nguyen Huu Tuan
@snowyukischnee
Hi,
I'm new to jooby. How can I using jooby-openapi to generate api specs with out having to define all the api in the same class?
Edgar Espina
@jknack
@williamjtodd There is a static call: LogConfigurer.configure(new EnvironmentOptions().getActiveNames());
@snowyukischnee Hi, welcome. Try the mvc/controller model
Nguyen Huu Tuan
@snowyukischnee
@jknack Hi, when i try to define the mvc controller in the same class which is mainClass in jooby-openapi plugin then the generated openapi.yaml was generated fine, but if i move the controller to an another place then the generated spec was not contain the api spec of that controller
i was seperated the route definitions, app config to another place by writing class which consume Jooby instance like AppConfig and RouteConfig, both those class are inherit Extension interface
Edgar Espina
@jknack
Controller are generated OK, just make sure to register the controller from the application
Routes from Extension are not considered
but this should works OK:
class MyApp extends Jooby {
   {
       mvc(new MyController());
   }
}
MyController can be in his own file, no need to have in same file as MyApp
Nguyen Huu Tuan
@snowyukischnee

@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: {}
Edgar Espina
@jknack
Yea, that is what I tried to explain before
This is not supported:
public class RouterConfig implements Extension {

    @Override
    public void install(@Nonnull Jooby app) throws Exception {
        app.mvc(CustomerController.class);
    }
}
Routes from extension are considered internal or infrastructure, not part of an API
Remove that class and just do:
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);
        });
    }
}
Nguyen Huu Tuan
@snowyukischnee
so passing Jooby instance to another class to perform the route definition is not supported, right
Edgar Espina
@jknack
correct
openapi scanner traverse known API calls (except for Extensions)
Nguyen Huu Tuan
@snowyukischnee
it will follow the code inside that class, not the jooby instance itself, am i correct
Edgar Espina
@jknack
yes
Nguyen Huu Tuan
@snowyukischnee

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

Edgar Espina
@jknack
Ok, but why?
why do you need to put the controller inside an Extension?
for example, you are forking how it works and might miss something new from module (like bug fixing, new features, etc)
Also, open-api doesn’t use reflection and your version does it… not necessarily bad but not need it
Nguyen Huu Tuan
@snowyukischnee
yes, this is just a workaround
since my project structure that will seperate the route register from the main app
the App class contains no information about it will has route A or route B
I just move the definition to another to do that
Edgar Espina
@jknack
don’t get it
but if you ruly want this, try this instead: https://jooby.io/#router-composing-routes