diff --git a/packages/medusa/oas/admin.oas.base.yaml b/packages/medusa/oas/admin.oas.base.yaml index 76f18ad541..44051021af 100644 --- a/packages/medusa/oas/admin.oas.base.yaml +++ b/packages/medusa/oas/admin.oas.base.yaml @@ -222,6 +222,24 @@ info: For example, if the `count` is 100 and the `limit` is 50, you can divide the `count` by the `limit` to get the number of pages: `100/50 = 2 pages`. + ### Sort Order + + The `order` field available on endpoints supporting pagination allows you to sort the retrieved items by an attribute of that item. For example, you can sort products by their `created_at` attribute by setting `order` to `created_at`: + + ```bash + curl "http://localhost:9000/admin/products?order=created_at" \ + -H 'Authorization: Bearer {api_token}' + ``` + + By default, the sort direction will be ascending. To change it to descending, pass a dash (`-`) before the attribute name. For example: + + ```bash + curl "http://localhost:9000/admin/products?order=-created_at" \ + -H 'Authorization: Bearer {api_token}' + ``` + + This sorts the products by their `created_at` attribute in the descending order. + license: name: MIT url: https://github.com/medusajs/medusa/blob/master/LICENSE diff --git a/packages/medusa/oas/store.oas.base.yaml b/packages/medusa/oas/store.oas.base.yaml index 3c176689eb..021c383782 100644 --- a/packages/medusa/oas/store.oas.base.yaml +++ b/packages/medusa/oas/store.oas.base.yaml @@ -205,6 +205,21 @@ info: For example, if the `count` is 100 and the `limit` is 50, you can divide the `count` by the `limit` to get the number of pages: `100/50 = 2 pages`. + ### Sort Order + + The `order` field available on endpoints supporting pagination allows you to sort the retrieved items by an attribute of that item. For example, you can sort products by their `created_at` attribute by setting `order` to `created_at`: + + ```bash + curl "http://localhost:9000/list/products?order=created_at" + ``` + + By default, the sort direction will be ascending. To change it to descending, pass a dash (`-`) before the attribute name. For example: + + ```bash + curl "http://localhost:9000/list/products?order=-created_at" + ``` + + This sorts the products by their `created_at` attribute in the descending order. license: name: MIT url: https://github.com/medusajs/medusa/blob/master/LICENSE diff --git a/www/docs/src/css/_redocly.css b/www/docs/src/css/_redocly.css index 17d10505df..2b77b91060 100644 --- a/www/docs/src/css/_redocly.css +++ b/www/docs/src/css/_redocly.css @@ -66,7 +66,7 @@ color: var(--ifm-color-headers) !important; } -.redocusaurus [data-section-id] > div:nth-child(2) h2, .redocusaurus [data-section-id] > div:nth-child(2) h3, .redocusaurus [data-section-id] > div:nth-child(2) h4 { +.redocusaurus [data-section-id] [data-section-id] > div:nth-child(2) h2, .redocusaurus [data-section-id] [data-section-id] > div:nth-child(2) h3, .redocusaurus [data-section-id] [data-section-id] > div:nth-child(2) h4 { --ifm-color-headers: var(--medusa-text-on-color); }