Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested parent class not imported in generated server code #453

Closed
literallyEllie opened this issue Jun 20, 2024 · 2 comments · Fixed by #455
Closed

Nested parent class not imported in generated server code #453

literallyEllie opened this issue Jun 20, 2024 · 2 comments · Fixed by #455
Assignees
Milestone

Comments

@literallyEllie
Copy link

literallyEllie commented Jun 20, 2024

Repost from Discord :)

Using avaje-http and avaje-http-javalin-generator 2.4

The following code,

package my.project.a;

import my.project.b.Foo;

@Controller
public class TestController {
    @Post
    public void foo(Foo.NestedEnum value) {
        System.out.println(value);
    }
package my.project.b;

public class Foo {
    public enum NestedEnum {
        A, B, C
    }
}

produces:

import my.project.b.Foo.PublicSubclass;
import my.project.a.TestController;

@Generated("avaje-javalin-generator")
@Component
public class TestController$Route extends AvajeJavalinPlugin {
...

  private void routes(JavalinDefaultRouting app) {
    app.post("", ctx -> {
      ctx.status(201);
      var value = (Foo.NestedEnum) toEnum(Foo.NestedEnum.class, ctx.queryParam("value")); // <-- error here, "cannot resolve symbol Foo.NestedEnum"
      controller.foo(value);
    });
}

at compile.

But compile fails as the error Unknown class: Foo.NestedEnum is produced since it imports my.project.b.Foo.NestedEnum and not the parent class my.project.b.Foo.

Thank you for your work, love the library :)

rbygrave added a commit that referenced this issue Jun 20, 2024
…server code

e.g.
```
public class Foo {
    public enum NestedEnum {
        A, B, C
    }
}
```

```
@controller
class TestController {
    @post
    void foo(Foo.NestedEnum value) {
        System.out.println(value);
    }
```
rbygrave added a commit that referenced this issue Jun 20, 2024
…server code (#455)

e.g.
```
public class Foo {
    public enum NestedEnum {
        A, B, C
    }
}
```

```
@controller
class TestController {
    @post
    void foo(Foo.NestedEnum value) {
        System.out.println(value);
    }
```
@rbygrave rbygrave self-assigned this Jun 20, 2024
@rbygrave rbygrave added this to the 2.6 milestone Jun 20, 2024
@rbygrave
Copy link
Contributor

Thanks !!! You can try 2.6-RC2 to confirm the fix.

@literallyEllie
Copy link
Author

Can confirm fixed. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants