openapi-jsonrpc-jsdoc 1.2.4 → 1.2.6
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/index.js +33 -12
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -147,6 +147,9 @@ async function openapiJsonrpcJsdoc({ files, securitySchemes = {}, packageUrl, se
|
|
|
147
147
|
|
|
148
148
|
const propertiesParameters = module.params.reduce(
|
|
149
149
|
(accumulator, parameter) => {
|
|
150
|
+
if (parameter.name.startsWith('_')) {
|
|
151
|
+
return accumulator;
|
|
152
|
+
}
|
|
150
153
|
if (!parameter.type) {
|
|
151
154
|
throw new Error('JSDoc parameter error: ' + apiName);
|
|
152
155
|
}
|
|
@@ -164,20 +167,30 @@ async function openapiJsonrpcJsdoc({ files, securitySchemes = {}, packageUrl, se
|
|
|
164
167
|
}
|
|
165
168
|
let items;
|
|
166
169
|
let enumData;
|
|
170
|
+
let oneOf;
|
|
171
|
+
|
|
167
172
|
switch (type) {
|
|
168
173
|
case 'Array.<string>': {
|
|
169
174
|
type = 'array';
|
|
170
|
-
items = { type: '
|
|
175
|
+
items = { type: 'string' };
|
|
171
176
|
break;
|
|
172
177
|
}
|
|
173
178
|
case 'Array.<number>': {
|
|
174
179
|
type = 'array';
|
|
175
|
-
items = { type: '
|
|
180
|
+
items = { type: 'number' };
|
|
176
181
|
break;
|
|
177
182
|
}
|
|
178
183
|
case 'enum': {
|
|
179
184
|
enumData = parameter.type.names;
|
|
180
|
-
|
|
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)))) {
|
|
181
194
|
type = 'number';
|
|
182
195
|
} else {
|
|
183
196
|
type = 'string';
|
|
@@ -198,15 +211,23 @@ async function openapiJsonrpcJsdoc({ files, securitySchemes = {}, packageUrl, se
|
|
|
198
211
|
if (!parameter.optional) {
|
|
199
212
|
accumulator.required.push(name);
|
|
200
213
|
}
|
|
201
|
-
accumulator.properties = {
|
|
202
|
-
|
|
203
|
-
[name]
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
214
|
+
accumulator.properties[name] = accumulator.properties[name] ?? {};
|
|
215
|
+
if (type) {
|
|
216
|
+
accumulator.properties[name].type = type;
|
|
217
|
+
}
|
|
218
|
+
if (description) {
|
|
219
|
+
accumulator.properties[name].description = description;
|
|
220
|
+
}
|
|
221
|
+
if (items) {
|
|
222
|
+
accumulator.properties[name].items = items;
|
|
223
|
+
}
|
|
224
|
+
if (enumData) {
|
|
225
|
+
accumulator.properties[name].enum = enumData;
|
|
226
|
+
}
|
|
227
|
+
if (oneOf) {
|
|
228
|
+
accumulator.properties[name].oneOf = oneOf;
|
|
229
|
+
}
|
|
230
|
+
|
|
210
231
|
return accumulator;
|
|
211
232
|
},
|
|
212
233
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openapi-jsonrpc-jsdoc",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.6",
|
|
4
4
|
"description": "Transform JSDoc-annotated JSON-RPC 2.0 methods into OpenAPI 3.0 specifications. Auto-generates REST API documentation with complete schemas, parameters, and endpoint definitions.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|