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(
263
263
jsonRequestBodyExample,
264
264
info : openapiData . info ,
265
265
} ,
266
+ position : operationObject [ "x-position" ] as number | undefined ,
266
267
} ;
267
268
268
269
items . push ( apiPage ) ;
@@ -509,6 +510,22 @@ function createItems(
509
510
} ) ;
510
511
}
511
512
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
+
512
529
return items as ApiMetadata [ ] ;
513
530
}
514
531
Original file line number Diff line number Diff line change @@ -156,8 +156,8 @@ export interface OperationObject {
156
156
deprecated ?: boolean ;
157
157
security ?: SecurityRequirementObject [ ] ;
158
158
servers ?: ServerObject [ ] ;
159
-
160
159
// extensions
160
+ "x-position" ?: number ;
161
161
"x-deprecated-description" ?: string ;
162
162
}
163
163
Original file line number Diff line number Diff line change @@ -89,6 +89,7 @@ export interface OpenAPIOperation {
89
89
servers ?: OpenAPIServer [ ] ;
90
90
"x-codeSamples" ?: OpenAPIXCodeSample [ ] ;
91
91
"x-code-samples" ?: OpenAPIXCodeSample [ ] ; // deprecated
92
+ "x-position" ?: number ;
92
93
}
93
94
94
95
export interface OpenAPIParameter {
Original file line number Diff line number Diff line change @@ -118,6 +118,7 @@ export interface ApiMetadataBase {
118
118
frontMatter : Record < string , unknown > ;
119
119
method ?: string ;
120
120
path ?: string ;
121
+ position ?: number ;
121
122
}
122
123
123
124
export interface ApiPageMetadata extends ApiMetadataBase {
You can’t perform that action at this time.
0 commit comments