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

operationId auto generation fails for inheritance #819

Closed
codegourmet opened this issue Jun 7, 2021 · 3 comments · Fixed by #820
Closed

operationId auto generation fails for inheritance #819

codegourmet opened this issue Jun 7, 2021 · 3 comments · Fixed by #820
Assignees
Labels
bug Something isn't working
Milestone

Comments

@codegourmet
Copy link

codegourmet commented Jun 7, 2021

When I use CLASS_METHOD as operationId generation strategy, and my resource implements an interface, the interface name is used for operationId instead of the concrete jaxrs resource class's name.

So, in the case of

GreetingInterface -> GreetingResource

it should generate: operationId: GreetingResource_hello,
but it does: operationId: GreetingInterface_hello

This is a problem since when I have for example

GreetingResourceA implements GreetingInterface
GreetingResourceB implements GreetingInterface

I will get duplicate operationId errors when generating a client (GreetingInterface_hello, GreetingInterface_hello).

My concrete use case is an annotated interface (and implementation) for basic CRUD operations so I don't need to repeat them for each model.

I tried to do some digging and testing, but couldn't get the existing unit test to pick up my example resource (result was always empty).

Here is the implementation and the test in the smallrye-openapi code:

https://github.com/smallrye/smallrye-open-api/blob/main/core/src/main/java/io/smallrye/openapi/runtime/io/operation/OperationReader.java#L145

https://github.com/smallrye/smallrye-open-api/blob/main/extension-jaxrs/src/test/java/io/smallrye/openapi/runtime/scanner/OperationIdTest.java

Here are an example and a link to a quarkus example project.

Example:

public interface GreetingInterface {

    @GET
    public String hello();

}
@Path("/hello")
public class GreetingResource implements GreetingInterface {

    public String hello() {
        return "Hello RESTEasy";
    }

}

Result:

---
openapi: 3.0.3
info:
  title: Generated API
  version: "1.0"
paths:
  /hello:
    get:
      operationId: GreetingInterface_hello
      responses:
        "200":
          description: OK
          content:
            text/plain:
              schema:
                type: string

expected: operationId: GreetingResource_hello
actual: operationId: GreetingInterface_hello

Example Repo URL: https://github.com/codegourmet/openapi-operationid-example

@phillip-kruger
Copy link
Member

Hi @codegourmet

I will look at this a.s.a.p. If you have an idea how to fix this, PR's are welcome :)

@MikeEdgar
Copy link
Member

I can take a look.

@MikeEdgar MikeEdgar self-assigned this Jun 9, 2021
@MikeEdgar MikeEdgar added the bug Something isn't working label Jun 9, 2021
@MikeEdgar MikeEdgar added this to the 2.1.6 milestone Jun 9, 2021
@codegourmet
Copy link
Author

You guys are absolutely fantastic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants