openapi-jsonrpc-jsdoc 1.2.5 → 1.3.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.
- package/README.md +2 -2
- package/{index.js → index.mjs} +19 -9
- package/package.json +9 -8
package/README.md
CHANGED
package/{index.js → index.mjs}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import jsdocx from 'jsdoc-x';
|
|
2
2
|
|
|
3
|
-
async function openapiJsonrpcJsdoc({ files, securitySchemes = {}, packageUrl, servers, api = '/' }) {
|
|
3
|
+
export default async function openapiJsonrpcJsdoc({ files, securitySchemes = {}, packageUrl, servers, api = '/' }) {
|
|
4
4
|
const [package_, ...documents] = await jsdocx.parse({
|
|
5
5
|
files,
|
|
6
6
|
package: packageUrl,
|
|
@@ -77,7 +77,7 @@ async function openapiJsonrpcJsdoc({ files, securitySchemes = {}, packageUrl, se
|
|
|
77
77
|
if (!isJsonRpc) {
|
|
78
78
|
continue prepare;
|
|
79
79
|
}
|
|
80
|
-
const apiName = module.meta.filename.replace(
|
|
80
|
+
const apiName = module.meta.filename.replace(/\.js$/, '');
|
|
81
81
|
|
|
82
82
|
const schema = {
|
|
83
83
|
post: {
|
|
@@ -103,7 +103,7 @@ async function openapiJsonrpcJsdoc({ files, securitySchemes = {}, packageUrl, se
|
|
|
103
103
|
content: {
|
|
104
104
|
'application/json': {
|
|
105
105
|
schema: {
|
|
106
|
-
$ref: '#/components/schemas/Error'
|
|
106
|
+
$ref: '#/components/schemas/Error',
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
}
|
|
@@ -167,21 +167,30 @@ async function openapiJsonrpcJsdoc({ files, securitySchemes = {}, packageUrl, se
|
|
|
167
167
|
}
|
|
168
168
|
let items;
|
|
169
169
|
let enumData;
|
|
170
|
+
let oneOf;
|
|
170
171
|
|
|
171
172
|
switch (type) {
|
|
172
173
|
case 'Array.<string>': {
|
|
173
174
|
type = 'array';
|
|
174
|
-
items = { type: '
|
|
175
|
+
items = { type: 'string' };
|
|
175
176
|
break;
|
|
176
177
|
}
|
|
177
178
|
case 'Array.<number>': {
|
|
178
179
|
type = 'array';
|
|
179
|
-
items = { type: '
|
|
180
|
+
items = { type: 'number' };
|
|
180
181
|
break;
|
|
181
182
|
}
|
|
182
183
|
case 'enum': {
|
|
183
184
|
enumData = parameter.type.names;
|
|
184
|
-
|
|
185
|
+
oneOf = parameter.type.names.map((n) => {
|
|
186
|
+
if (!Number.isNaN(Number(n))) {
|
|
187
|
+
return Number(n);
|
|
188
|
+
}
|
|
189
|
+
return n;
|
|
190
|
+
});
|
|
191
|
+
if (parameter.type.names.every(n => Number.isInteger(Number(n)))) {
|
|
192
|
+
type = 'integer';
|
|
193
|
+
} else if (parameter.type.names.every(n => !Number.isNaN(Number(n)))) {
|
|
185
194
|
type = 'number';
|
|
186
195
|
} else {
|
|
187
196
|
type = 'string';
|
|
@@ -215,6 +224,9 @@ async function openapiJsonrpcJsdoc({ files, securitySchemes = {}, packageUrl, se
|
|
|
215
224
|
if (enumData) {
|
|
216
225
|
accumulator.properties[name].enum = enumData;
|
|
217
226
|
}
|
|
227
|
+
if (oneOf) {
|
|
228
|
+
accumulator.properties[name].oneOf = oneOf;
|
|
229
|
+
}
|
|
218
230
|
|
|
219
231
|
return accumulator;
|
|
220
232
|
},
|
|
@@ -233,5 +245,3 @@ async function openapiJsonrpcJsdoc({ files, securitySchemes = {}, packageUrl, se
|
|
|
233
245
|
}
|
|
234
246
|
return temporaryDocument;
|
|
235
247
|
}
|
|
236
|
-
|
|
237
|
-
module.exports = openapiJsonrpcJsdoc;
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openapi-jsonrpc-jsdoc",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "Transform JSDoc-annotated JSON-RPC 2.0 methods into OpenAPI
|
|
3
|
+
"version": "1.3.0",
|
|
4
|
+
"description": "Transform JSDoc-annotated JSON-RPC 2.0 methods into OpenAPI specifications.",
|
|
5
5
|
"main": "index.js",
|
|
6
|
+
"type": "module",
|
|
6
7
|
"scripts": {
|
|
7
8
|
"test": "NODE_NO_WARNINGS=1 ava test/*.test.js"
|
|
8
9
|
},
|
|
@@ -14,8 +15,8 @@
|
|
|
14
15
|
"openapi jsdoc",
|
|
15
16
|
"open api js doc",
|
|
16
17
|
"postman jsdoc",
|
|
17
|
-
"swagger
|
|
18
|
-
"openapi
|
|
18
|
+
"swagger jsdoc",
|
|
19
|
+
"openapi jsdoc",
|
|
19
20
|
"json-rpc openapi",
|
|
20
21
|
"json-rpc swagger",
|
|
21
22
|
"jsonrpc openapi",
|
|
@@ -31,11 +32,11 @@
|
|
|
31
32
|
"jsdoc-x": "~4.1.0"
|
|
32
33
|
},
|
|
33
34
|
"devDependencies": {
|
|
34
|
-
"ava": "~
|
|
35
|
-
"express": "~5.1
|
|
36
|
-
"express-openapi-validator": "~5.6.
|
|
35
|
+
"ava": "~6.4.1",
|
|
36
|
+
"express": "~5.2.1",
|
|
37
|
+
"express-openapi-validator": "~5.6.1"
|
|
37
38
|
},
|
|
38
39
|
"engines": {
|
|
39
|
-
"node": ">=
|
|
40
|
+
"node": ">= 22"
|
|
40
41
|
}
|
|
41
42
|
}
|