swagger-api / swagger-api/swagger-core

Swagger duplicates operation in spec

Open
#4,380 0 comments 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

Q A
Bug or feature request? Bug
Which Swagger-Core version? 2.2.8
Which Java version? 1.8.0_362
Which JAX-RS framework & version? jax-rs 2.1.1 & jersey 2.39

We have an interface defined in this way:

public interface OperationSpec {

  @Operation(
      operationId = "spec.random")
  @GET
  @Path("/operation")
  @Produces(ApiMediaType.JSON)
  Response getOperation();
}

And an implementation of OperationSpec:

@Path("/operations")
public class Operation implements OperationSpec {
  @Override
  @JsonView(Views.API.V1.class)
  public Response getOperation() {
      ...
  }
}

For no reason, swagger is generating a spec file with two duplicate operations:

'/operations/operation':
    get:
      operationId: spec.random
...

'/operation':
    get:
      operationId: spec.random_1

Is there any reason for this?

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

No repository file or test is named. Start by reproducing the duplicate paths with Swagger-Core 2.2.8, JAX-RS 2.1.1, and Jersey 2.39 using the interface and implementation shown; trace how both resource declarations are discovered. Done means identifying the cause and preventing the duplicate operation or documenting the required configuration.

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
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.