swagger-api / swagger-api/swagger-core

Invalid detection of overridden methods (reopened #3426)

Open
#4,499 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

backlog
Dominant language
Java
Stars
7.5k
Forks
2.3k
Avg merge
18h 1m
Merged PRs (30d)
10

Description

Sorry for the long delay.

Unfortunately, swagger-core 2.2.16 does not yet solve the problem of #3426 . I missed some important stuff in the example parent class: The overridden method is protected which does not find the method when iterating via Class.getMethods(). Also the type variable is bounded, but this should not be a problem.

So this adapted example does not detect overriding properly:

public class Parent<T extends CharSequence> {
  protected T get(String input) {
    return null;
  }
}
@Path("/inheritExample")
public class Resource extends Parent<String> {
  @Override
  @GET
  @Path("/{input}")
  public String get(@PathParam("input") String input) {
    return super.get(input);
  }
}

Again, this only applies to specific Java compilers that produce two methods of similar signature in the same class. I found JDK 11 from Oracle to behave accordingly.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the Parent and Resource example on Oracle JDK 11, then trace the method-discovery path that handles overridden methods. Done means the protected generic parent method is detected correctly for the annotated public override without breaking other compiler outputs.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.