elements icon indicating copy to clipboard operation
elements copied to clipboard

Request parameters are always sorted by requiredness and alphabetically

Open Lexy2 opened this issue 1 year ago • 1 comments

No matter how I order request parameters for my endpoints, whether I use x-position to reorder parameters or not, the request parameters are always sorted by required, then alphabetically.

Context

We use standard parameter names in our request queries - StartDate, EndDate, LastUpdatedDate. The first two are required, the last one is optional. The parameters are always sorted alphabetically, regardless of their appearance in the schema. I've fixed the order of endpoints and groups by sorting them correctly, but parameter order is not preserved in any way in stoplight.

Current Behavior

image

Expected Behavior

image

Possible Workaround/Solution

Rename parameters in the schema so that they are sorted the right way, i.e. add a space before a parameter. It will be shown in the right order, but the Try It functionality will be cooked.

Steps to Reproduce

  1. Run Stoplight Elements on top of any schema that has parameters.
  2. Play with parameter ordering in the schema.
  3. Try adding x-position to the parameters. The extract from the schema:
"parameters": [
                    {
                        "type": "string",
                        "name": "StartDate",
                        "in": "query",
                        "required": true,
                        "format": "date-time",
                        "x-nullable": false,
                    },
                    {
                        "type": "string",
                        "name": "EndDate",
                        "in": "query",
                        "required": true,
                        "format": "date-time",
                        "x-nullable": false,
                    },
                    {
                        "type": "string",
                        "name": "LastUpdatedDateTime",
                        "in": "query",
                        "format": "date-time",
                        "x-nullable": true
                    },
                ],
  • Version used: Tried 7.7.18 and 7.10.0
  • Environment name and version: Edge Version 116.0.1938.76 (Official build) (64-bit) Node 18 React 18.2
  • Operating System and version (desktop or mobile): Windows 10 22H2

Lexy2 avatar Sep 10 '23 06:09 Lexy2

Just ran into this as well, would be nice if we could customise the ordering

Zarathustra2 avatar Sep 11 '23 10:09 Zarathustra2