Skip to content

Sorting operations by operationId leads to issues on generated server #14660

@gemyago

Description

@gemyago

Suppose we have the following routes (in form operationName=route path):

getTopScoredPosts=/posts/top-scored
getPostById=/posts/{postId}

Operations are sorted by operationId like below:

ops.sort((one, another) -> ObjectUtils.compare(one.operationId, another.operationId));

ops.sort((one, another) -> ObjectUtils.compare(one.operationId, another.operationId));

When generating server, routes are going to be registered with a router (like express) in the following order:

getPostById=/posts/{postId}
getTopScoredPosts=/posts/top-scored
```

This leads to an issue where requests like `GET /posts/top-scored` will be actually matched by `GET /posts/{postId}` route handler.

The simplest solution is to avoid sorting operations and have them in order as they are defined in the opeanpi doc.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions