docusaurus-plugin-openapi-docs 0.0.0-1007 → 0.0.0-1010

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -48,7 +48,7 @@ Key Features:
48
48
 
49
49
  ## Bootstrapping from Template (new Docusaurus site)
50
50
 
51
- Run the following to bootstrap a Docsaurus v3 site (classic theme) with `docusaurus-openapi-docs`:
51
+ Run the following to bootstrap a Docusaurus v3 site (classic theme) with `docusaurus-openapi-docs`:
52
52
 
53
53
  ```bash
54
54
  npx create-docusaurus@3.7.0 my-website --package-manager yarn
@@ -192,12 +192,13 @@ The `docusaurus-plugin-openapi-docs` plugin can be configured with the following
192
192
 
193
193
  `versions` can be configured with the following options:
194
194
 
195
- | Name | Type | Default | Description |
196
- | ---------- | -------- | ------- | ------------------------------------------------------------------------------------------------------------------------ |
197
- | `specPath` | `string` | `null` | Designated URL or path to the source of an OpenAPI specification file or directory of micro OpenAPI specification files. |
198
- | `ouputDir` | `string` | `null` | Desired output path for versioned, generated MDX files. |
199
- | `label` | `string` | `null` | _Optional:_ Version label used when generating version selector dropdown menu. |
200
- | `baseUrl` | `string` | `null` | _Optional:_ Version base URL used when generating version selector dropdown menu. |
195
+ | Name | Type | Default | Description |
196
+ | ------------- | -------- | ------- | -------------------------------------------------------------------------------------------------------------------------- |
197
+ | `specPath` | `string` | `null` | Designated URL or path to the source of an OpenAPI specification file or a directory of micro OpenAPI specification files. |
198
+ | `outputDir` | `string` | `null` | Desired output path for versioned, generated MDX files. |
199
+ | `label` | `string` | `null` | _Optional:_ Version label used when generating the version selector dropdown menu. |
200
+ | `baseUrl` | `string` | `null` | _Optional:_ Version base URL used when generating the version selector dropdown menu. |
201
+ | `downloadUrl` | `string` | `null` | _Optional:_ Designated URL for downloading the versioned OpenAPI specification. |
201
202
 
202
203
  > All versions will automatically inherit `sidebarOptions` from the parent/base config.
203
204
 
@@ -329,11 +330,11 @@ yarn docusaurus gen-api-docs:version petstore:all
329
330
 
330
331
  > This will generate API docs for all of the OpenAPI specification (OAS) files referenced in your `versions` config and will also generate a `versions.json` file.
331
332
 
332
- > Substitue `all` with a specific version ID to generate/clean a specific version. Generating for `all` or a specific version ID will automatically update the `versions.json` file.
333
+ > Substitute `all` with a specific version ID to generate or clean a specific version. Generating for `all` or a single version ID will automatically update the `versions.json` file.
333
334
 
334
335
  ## Developer Quick Start
335
336
 
336
- > Looking to make a contribution? Make sure to checkout out our contributing guide.
337
+ > Looking to make a contribution? Make sure to check out our contributing guide.
337
338
 
338
339
  After [forking](https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/fork) the main repository, run the following:
339
340
 
@@ -211,6 +211,7 @@ function createItems(openapiData, options, sidebarOptions) {
211
211
  jsonRequestBodyExample,
212
212
  info: openapiData.info,
213
213
  },
214
+ position: operationObject["x-position"],
214
215
  };
215
216
  items.push(apiPage);
216
217
  }
@@ -406,6 +407,21 @@ function createItems(openapiData, options, sidebarOptions) {
406
407
  items.push(tagPage);
407
408
  });
408
409
  }
410
+ items.sort((a, b) => {
411
+ // Items with position come first, sorted by position
412
+ if (a.position !== undefined && b.position !== undefined) {
413
+ return a.position - b.position;
414
+ }
415
+ // Items with position come before items without position
416
+ if (a.position !== undefined) {
417
+ return -1;
418
+ }
419
+ if (b.position !== undefined) {
420
+ return 1;
421
+ }
422
+ // If neither has position, maintain original order
423
+ return 0;
424
+ });
409
425
  return items;
410
426
  }
411
427
  /**
@@ -128,6 +128,7 @@ export interface OperationObject {
128
128
  deprecated?: boolean;
129
129
  security?: SecurityRequirementObject[];
130
130
  servers?: ServerObject[];
131
+ "x-position"?: number;
131
132
  "x-deprecated-description"?: string;
132
133
  }
133
134
  export interface OperationObjectWithRef {
@@ -76,6 +76,7 @@ export interface OpenAPIOperation {
76
76
  servers?: OpenAPIServer[];
77
77
  "x-codeSamples"?: OpenAPIXCodeSample[];
78
78
  "x-code-samples"?: OpenAPIXCodeSample[];
79
+ "x-position"?: number;
79
80
  }
80
81
  export interface OpenAPIParameter {
81
82
  name: string;
package/lib/types.d.ts CHANGED
@@ -85,6 +85,7 @@ export interface ApiMetadataBase {
85
85
  frontMatter: Record<string, unknown>;
86
86
  method?: string;
87
87
  path?: string;
88
+ position?: number;
88
89
  }
89
90
  export interface ApiPageMetadata extends ApiMetadataBase {
90
91
  json?: string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "docusaurus-plugin-openapi-docs",
3
3
  "description": "OpenAPI plugin for Docusaurus.",
4
- "version": "0.0.0-1007",
4
+ "version": "0.0.0-1010",
5
5
  "license": "MIT",
6
6
  "keywords": [
7
7
  "openapi",
@@ -65,5 +65,5 @@
65
65
  "engines": {
66
66
  "node": ">=14"
67
67
  },
68
- "gitHead": "864d5355b98d552679472455f533ef15313a0bee"
68
+ "gitHead": "5348bdfc01228df1025d380a949689f833dcfc13"
69
69
  }
@@ -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
 
@@ -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
 
@@ -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 {
package/src/types.ts CHANGED
@@ -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 {