question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

OperantionId may be duplicated

See original GitHub issue

Now a days operationId is generated based on the endpoint method name. So when you have two methods with the same name (even in different classes) it causes a conflict in the swagger.json file.

For example:

@ApiOperation(value = "Just testing")
@Path("test-one")
public class Test {
    @GET
    @Path("test")
    public Response test() {
        return Response.ok().build();
    }
}
@ApiOperation(value = "Testing...")
@Path("test-two")
public class Test2 {
    @GET
    @Path("another-test")
    public Response test() {
        return Response.ok().build();
    }
}

The operationId property in the final file will be test for both endpoints.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
ChristianLutzcommented, Sep 18, 2019

@larsf

I solved this problem with a filterClass

public class OperationIdPrefixFilter extends AbstractSpecFilter {

	@Override
	public Optional<Operation> filterOperation(Operation operation, ApiDescription api, Map<String,
			List<String>> params, Map<String, String> cookies, Map<String, List<String>> headers) {
		String operationId = operation.getOperationId();
		operation.setOperationId(operationId.split("_[0-9]+$")[0]);

		return super.filterOperation(operation, api, params, cookies, headers);
	}
}
1reaction
larsfcommented, Mar 31, 2019

This change cause swagger-codegen to generate methods that now have “arbitrary” numbers in the name. So in stead of being able to call “endpoint”.delete(), depending on how many endpoints you have, it may be endpoint.delete_1(), or endpoint.delete_100(). When you allowed for the operationId to simply be equal to the method name, the api calls were consistent like this: firstEndpoint.delete() and secondEndpoint.delete(), instead of now being firstEndpoint.delete_1(), and secondEndpoint.delete_2()

Is there a way to override this auto numbering, and revert to the old behavior?

Read more comments on GitHub >

github_iconTop Results From Across the Web

2.3 Duplicate Cases Found Alert - E-Verify
A Duplicate Cases Found alert appears for a case that contains information found in one or more cases created within the last 365...
Read more >
Duplication of Output Spool Entries - IBM
a duplicate itself may be duplicated; each duplicate can be separately manipulated or displayed; allows to fan out one output entry to different...
Read more >
Find and remove duplicates - Microsoft Support
Select the cells you want to check for duplicates. Note: Excel can't highlight duplicates in the Values area of a PivotTable report. Click...
Read more >
Rule 1003. Admissibility of Duplicates - Law.Cornell.Edu
A duplicate is admissible to the same extent as the original unless a genuine ... may be present when only a part of...
Read more >
Duplicate Content: Why does it happen and how to fix issues
This occurs when each user that visits a website is assigned a different session ID that is stored in the URL. Session ids...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found