openapi-jsonrpc-jsdoc 1.3.1 → 1.4.0

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.
Files changed (2) hide show
  1. package/index.mjs +29 -29
  2. package/package.json +3 -3
package/index.mjs CHANGED
@@ -1,19 +1,17 @@
1
- import jsdocx from 'jsdoc-x';
1
+ import jsdoc from 'jsdoc-api';
2
2
 
3
3
  export default async function openapiJsonrpcJsdoc({ files, securitySchemes = {}, packageUrl, servers, api = '/' }) {
4
- const [package_, ...documents] = await jsdocx.parse({
5
- files,
4
+ const allData = await jsdoc.explain({
5
+ files: Array.isArray(files) ? files : [files],
6
6
  package: packageUrl,
7
7
  access: 'public',
8
8
  encoding: 'utf8',
9
- module: true,
10
9
  undocumented: false,
11
- sort: 'scope',
12
10
  allowUnknownTags: true,
13
11
  dictionaries: ['jsdoc'],
14
- hierarchy: true,
15
12
  });
16
- const tags = new Set();
13
+ const package_ = allData.find(item => item.kind === 'package');
14
+ const documents = allData.filter(item => item.kind !== 'package');
17
15
  const temporaryDocument = {
18
16
  'x-send-defaults': true,
19
17
  'openapi': '3.0.0',
@@ -35,22 +33,22 @@ export default async function openapiJsonrpcJsdoc({ files, securitySchemes = {},
35
33
  schemas: {
36
34
  Error: {
37
35
  required: [
38
- "error",
39
- "id",
40
- "jsonrpc"
36
+ 'error',
37
+ 'id',
38
+ 'jsonrpc',
41
39
  ],
42
40
  properties: {
43
- "id": {
44
- "type": "integer",
45
- "format": "int32"
41
+ id: {
42
+ type: 'integer',
43
+ format: 'int32',
46
44
  },
47
- "error": {
48
- "type": "object"
45
+ error: {
46
+ type: 'object',
49
47
  },
50
- "jsonrpc": {
51
- "type": "string"
52
- }
53
- }
48
+ jsonrpc: {
49
+ type: 'string',
50
+ },
51
+ },
54
52
  },
55
53
  }
56
54
  },
@@ -64,12 +62,13 @@ export default async function openapiJsonrpcJsdoc({ files, securitySchemes = {},
64
62
  const requiredSchema = ['method', 'jsonrpc'];
65
63
  prepare: for (const module of documents) {
66
64
  let isJsonRpc = false;
65
+ const tags = new Set();
67
66
 
68
67
  if (module.tags && Array.isArray(module.tags)) {
69
68
  for (const {title, value} of module.tags) {
70
69
  if (title === 'json-rpc') {
71
70
  isJsonRpc = true;
72
- } else if (title === 'tags' && value) {
71
+ } else if (value && ['tags', 'tag'].includes(title)) {
73
72
  value.split(',').map(t => t.trim()).forEach(t => tags.add(t));
74
73
  }
75
74
  }
@@ -77,11 +76,12 @@ export default async function openapiJsonrpcJsdoc({ files, securitySchemes = {},
77
76
  if (!isJsonRpc) {
78
77
  continue prepare;
79
78
  }
80
- const apiName = module.meta.filename.replace(/\.js$/, '');
79
+ const {filename} = module.meta;
80
+ const apiName = filename.replace(/\.js$/, '');
81
81
 
82
82
  const schema = {
83
83
  post: {
84
- operationId: `${module.meta.filename}`,
84
+ operationId: filename,
85
85
  deprecated: module.deprecated || false,
86
86
  summary: `/${apiName}`,
87
87
  description: module.description,
@@ -90,13 +90,13 @@ export default async function openapiJsonrpcJsdoc({ files, securitySchemes = {},
90
90
  responses: {
91
91
  '200': {
92
92
  description: 'OK',
93
- "content": {
94
- "application/json": {
95
- "schema": {
96
- "type": "object"
97
- }
98
- }
99
- }
93
+ content: {
94
+ 'application/json': {
95
+ schema: {
96
+ type: 'object',
97
+ },
98
+ },
99
+ },
100
100
  },
101
101
  default: {
102
102
  description: 'unexpected error',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openapi-jsonrpc-jsdoc",
3
- "version": "1.3.1",
3
+ "version": "1.4.0",
4
4
  "description": "Transform JSDoc-annotated JSON-RPC 2.0 methods into OpenAPI specifications.",
5
5
  "main": "index.mjs",
6
6
  "type": "module",
@@ -29,12 +29,12 @@
29
29
  },
30
30
  "homepage": "https://github.com/qertis/openapi-jsonrpc-jsdoc#readme",
31
31
  "dependencies": {
32
- "jsdoc-x": "~4.1.0"
32
+ "jsdoc-api": "~9.3.5"
33
33
  },
34
34
  "devDependencies": {
35
35
  "ava": "~6.4.1",
36
36
  "express": "~5.2.1",
37
- "express-openapi-validator": "~5.6.1"
37
+ "express-openapi-validator": "~5.6.2"
38
38
  },
39
39
  "engines": {
40
40
  "node": ">= 22"