openapi-jsonrpc-jsdoc 1.5.3 → 1.5.5
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 +12 -12
- package/index.mjs +18 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -37,19 +37,19 @@ module.exports = (parameters) => {
|
|
|
37
37
|
```js
|
|
38
38
|
const openapiJSONRpcJSDoc = require('openapi-jsonrpc-jsdoc');
|
|
39
39
|
openapiJSONRpcJSDoc({
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
40
|
+
api: '/',
|
|
41
|
+
servers: [
|
|
42
|
+
{
|
|
43
|
+
url: '0.0.0.0:8080',
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
info: {
|
|
47
|
+
title: 'Test API',
|
|
48
|
+
},
|
|
49
|
+
packageUrl: './package.json',
|
|
50
|
+
files: './api/*.js',
|
|
51
51
|
}).then(data => {
|
|
52
|
-
JSON.stringify(data, null, 2)
|
|
52
|
+
JSON.stringify(data, null, 2); // openapi.json
|
|
53
53
|
});
|
|
54
54
|
```
|
|
55
55
|
|
package/index.mjs
CHANGED
|
@@ -29,6 +29,16 @@ function isBigInt64(n) {
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
function normalizeString(s) {
|
|
33
|
+
if (
|
|
34
|
+
(s.startsWith("'") && s.endsWith("'"))
|
|
35
|
+
|| (s.startsWith('"') && s.endsWith('"'))
|
|
36
|
+
) {
|
|
37
|
+
return s.slice(1, -1);
|
|
38
|
+
}
|
|
39
|
+
return s;
|
|
40
|
+
}
|
|
41
|
+
|
|
32
42
|
function resolveSchemaFromTypeNames(names) {
|
|
33
43
|
let type;
|
|
34
44
|
let format;
|
|
@@ -92,8 +102,10 @@ function resolveSchemaFromTypeNames(names) {
|
|
|
92
102
|
return Number(n);
|
|
93
103
|
} else if (isBigInt64(n)) {
|
|
94
104
|
return n;
|
|
105
|
+
} else if (typeof n === 'string') {
|
|
106
|
+
return normalizeString(n);
|
|
95
107
|
}
|
|
96
|
-
return
|
|
108
|
+
return n;
|
|
97
109
|
});
|
|
98
110
|
|
|
99
111
|
if (enumData.every(n => Number.isSafeInteger(n))) {
|
|
@@ -128,7 +140,7 @@ function resolveSchemaFromTypeNames(names) {
|
|
|
128
140
|
} else if (enumData.every(n => typeof n === 'string')) {
|
|
129
141
|
type = 'string';
|
|
130
142
|
} else if (enumData.length === 1) {
|
|
131
|
-
type = enumData
|
|
143
|
+
[type] = enumData;
|
|
132
144
|
constant = true;
|
|
133
145
|
} else {
|
|
134
146
|
type = undefined;
|
|
@@ -349,16 +361,16 @@ export default async function openapiJsonrpcJsdoc({
|
|
|
349
361
|
},
|
|
350
362
|
};
|
|
351
363
|
if (module.params) {
|
|
352
|
-
|
|
364
|
+
let propertiesParameters = {};
|
|
365
|
+
let required = [];
|
|
366
|
+
|
|
353
367
|
if (module.examples?.length) {
|
|
354
368
|
const exampleJSON = JSON.parse(module.examples[0]);
|
|
355
369
|
if (exampleJSON) {
|
|
356
|
-
|
|
370
|
+
propertiesParameters['default'] = exampleJSON;
|
|
357
371
|
}
|
|
358
372
|
}
|
|
359
373
|
|
|
360
|
-
let propertiesParameters = {};
|
|
361
|
-
let required = [];
|
|
362
374
|
for (const parameter of module.params) {
|
|
363
375
|
if (parameter.name.startsWith('_')) {
|
|
364
376
|
continue;
|