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.

Custom sorting/position is not honored for V2

See original GitHub issue

Using an annotation such as:

@ApiOperation(
         value = "Operation",
         notes = "Notes",
         position = 2
 )

and a custom ordering such as:

docket.apiDescriptionOrdering(new Ordering<ApiDescription>() {

        @Override
        public int compare(ApiDescription left, ApiDescription right) {
            int leftPos = left.getOperations().size() == 1 ? left.getOperations().get(0).getPosition() : 0;
            int rightPos = right.getOperations().size() == 1 ? right.getOperations().get(0).getPosition() : 0;

            int position = Integer.compare(leftPos, rightPos);

            if(position == 0) {
                position = left.getPath().compareTo(right.getPath());
            }

            return position;
        }
    });

The scanner framework seems to read the documentation and sort it properly. When the data is extracted to the Swagger object at Swagger2Controller.java:74, the ordering seems to be lost.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:26 (6 by maintainers)

github_iconTop GitHub Comments

18reactions
grtessmancommented, Jan 25, 2019

So let me get this right… If your consumer has to follow a hateoas pattern: ie: Call1 must get a list of objects and returns Id to make call 2 Call2 must use id from Call1 to fetch an object that has a list of objects to fetch for Call3 by Id Call3 must use id from Call2 to retrieve last object

But somewhere, someone decided that Alphabetical was a good solution??? Umm… WHY? Now, I have to explain to all users of my swagger doc that they must start at 2, then goto 3 then goto 1 depending on how my endpoint is alphabetically arranged.

Pure and utter NONSENSE! FIX THIS!

8reactions
chenmu5241commented, Sep 22, 2018

I try new version 2.9.2,operationOrdering and apiListingReferenceOrdering not working!It’s a bug!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Custom Sorting option not working in Magetno 2.4 search
When i select the Newest filter it shows the message No Result Found. Any one tell me what is the issue or any...
Read more >
Custom sorting function in javascript not working
I'm trying to write a custom sort function for my array of objects in javascript. For testing purposes, my arr array looks like...
Read more >
Sort data using a custom list - Microsoft Support
From the Order drop-down, select Custom List. In the Custom Lists box, select the list that you want, and then click OK to...
Read more >
legend custom sort not working - Microsoft Power BI Community
Solved: I have a line chart with legend field [FY Label], whose values are like '2018-2019', '2019-2020', 'Current FY'. This field is a...
Read more >
Power BI Custom Sort Order with hidden columns - YouTube
This Power BI custom sort order tutorial shows a new method of creating custom sorting using hidden columns and NO JOINS!
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