Skip to content

Commit 89692a8

Browse files
committed
Add support for x-position vendor extension and sorting logic
1 parent 8997017 commit 89692a8

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

  • packages/docusaurus-plugin-openapi-docs/src/openapi

packages/docusaurus-plugin-openapi-docs/src/openapi/openapi.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ function createItems(
263263
jsonRequestBodyExample,
264264
info: openapiData.info,
265265
},
266+
position: operationObject["x-position"] as number | undefined,
266267
};
267268

268269
items.push(apiPage);
@@ -509,6 +510,22 @@ function createItems(
509510
});
510511
}
511512

513+
items.sort((a, b) => {
514+
// Items with position come first, sorted by position
515+
if (a.position !== undefined && b.position !== undefined) {
516+
return a.position - b.position;
517+
}
518+
// Items with position come before items without position
519+
if (a.position !== undefined) {
520+
return -1;
521+
}
522+
if (b.position !== undefined) {
523+
return 1;
524+
}
525+
// If neither has position, maintain original order
526+
return 0;
527+
});
528+
512529
return items as ApiMetadata[];
513530
}
514531

0 commit comments

Comments
 (0)