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

Add support for managed JAX-RS subresource locators #2169

Merged
merged 4 commits into from
Jan 22, 2025

Conversation

BrianSetz
Copy link
Contributor

This addresses #2168. The problem originates from the fact that context.getResourceTypeResolver().resolve(method.returnType()); was assumed to contain the type of the sub resource. However, when dealing with managed resources, the methodReturnType will be set to Class<SomeManagedResource> which will not be found by context.getIndex().getClassByName(methodReturnType.name()); (since it expects SomeManagedResource and not Class<SomeManagedResource> and therefore the managed sub resource is not processed.

Questions:

  • I am not familiar with the Jandex API at all, so please advice if there is a better way to implement the extraction of the type parameter from the generic class.
  • Where is the best place to introduce tests for this? I quickly tested this by modifying the GreetingGetResource.

@BrianSetz BrianSetz marked this pull request as draft January 22, 2025 14:53
@MikeEdgar MikeEdgar linked an issue Jan 22, 2025 that may be closed by this pull request
Copy link
Member

@MikeEdgar MikeEdgar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @BrianSetz. This is going in the right direction. For testing, you can maybe modify the test below by changing the return type of one or two sub-resource locators to use a Class type. You won't need to change and expectations and the scenario will cover your change.

extension-jaxrs/src/test/java/io/smallrye/openapi/runtime/scanner/SubresourceScanTests.java

@BrianSetz BrianSetz marked this pull request as ready for review January 22, 2025 19:34
@MikeEdgar MikeEdgar added this to the 4.0.7 milestone Jan 22, 2025
Copy link
Member

@MikeEdgar MikeEdgar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thanks again for the PR @BrianSetz !

@MikeEdgar MikeEdgar merged commit e29e2d5 into smallrye:main Jan 22, 2025
7 checks passed
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 this pull request may close these issues.

Support for managed JAX-RS sub resources
2 participants