File tree Expand file tree Collapse file tree 4 files changed +20
-1
lines changed
packages/docusaurus-plugin-openapi-docs/src Expand file tree Collapse file tree 4 files changed +20
-1
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change @@ -156,8 +156,8 @@ export interface OperationObject {
156156 deprecated ?: boolean ;
157157 security ?: SecurityRequirementObject [ ] ;
158158 servers ?: ServerObject [ ] ;
159-
160159 // extensions
160+ "x-position" ?: number ;
161161 "x-deprecated-description" ?: string ;
162162}
163163
Original file line number Diff line number Diff line change @@ -89,6 +89,7 @@ export interface OpenAPIOperation {
8989 servers ?: OpenAPIServer [ ] ;
9090 "x-codeSamples" ?: OpenAPIXCodeSample [ ] ;
9191 "x-code-samples" ?: OpenAPIXCodeSample [ ] ; // deprecated
92+ "x-position" ?: number ;
9293}
9394
9495export interface OpenAPIParameter {
Original file line number Diff line number Diff line change @@ -118,6 +118,7 @@ export interface ApiMetadataBase {
118118 frontMatter : Record < string , unknown > ;
119119 method ?: string ;
120120 path ?: string ;
121+ position ?: number ;
121122}
122123
123124export interface ApiPageMetadata extends ApiMetadataBase {
You can’t perform that action at this time.
0 commit comments