openapi-jsonrpc-jsdoc 1.2.1 → 1.2.3
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 +34 -5
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -61,7 +61,7 @@ async function openapiJsonrpcJsdoc({ files, securitySchemes = {}, packageUrl, se
|
|
|
61
61
|
],
|
|
62
62
|
'tags': [],
|
|
63
63
|
};
|
|
64
|
-
const requiredSchema = ['method', '
|
|
64
|
+
const requiredSchema = ['method', 'jsonrpc'];
|
|
65
65
|
prepare: for (const module of documents) {
|
|
66
66
|
let isJsonRpc = false;
|
|
67
67
|
|
|
@@ -121,7 +121,6 @@ async function openapiJsonrpcJsdoc({ files, securitySchemes = {}, packageUrl, se
|
|
|
121
121
|
default: apiName,
|
|
122
122
|
description: `API method ${apiName}`,
|
|
123
123
|
},
|
|
124
|
-
// todo делать разграничение для notification request (без id)
|
|
125
124
|
id: {
|
|
126
125
|
type: 'integer',
|
|
127
126
|
default: 1,
|
|
@@ -155,7 +154,36 @@ async function openapiJsonrpcJsdoc({ files, securitySchemes = {}, packageUrl, se
|
|
|
155
154
|
if (parameter.type.names[0] === 'object') {
|
|
156
155
|
return accumulator;
|
|
157
156
|
}
|
|
158
|
-
|
|
157
|
+
let type;
|
|
158
|
+
if (parameter.type.names.length === 0) {
|
|
159
|
+
type = 'null';
|
|
160
|
+
} else if (parameter.type.names.length === 1) {
|
|
161
|
+
type = parameter.type.names[0];
|
|
162
|
+
} else {
|
|
163
|
+
type = 'enum';
|
|
164
|
+
}
|
|
165
|
+
let items;
|
|
166
|
+
let enumData;
|
|
167
|
+
switch (type) {
|
|
168
|
+
case 'Array.<string>': {
|
|
169
|
+
type = 'array';
|
|
170
|
+
items = { type: 'number' };
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
case 'Array.<number>': {
|
|
174
|
+
type = 'array';
|
|
175
|
+
items = { type: 'string' };
|
|
176
|
+
break;
|
|
177
|
+
}
|
|
178
|
+
case 'enum': {
|
|
179
|
+
type = 'string';
|
|
180
|
+
enumData = parameter.type.names;
|
|
181
|
+
break;
|
|
182
|
+
}
|
|
183
|
+
default: {
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
159
187
|
const description = parameter.description;
|
|
160
188
|
let name;
|
|
161
189
|
try {
|
|
@@ -171,6 +199,8 @@ async function openapiJsonrpcJsdoc({ files, securitySchemes = {}, packageUrl, se
|
|
|
171
199
|
[name]: {
|
|
172
200
|
type,
|
|
173
201
|
description,
|
|
202
|
+
items,
|
|
203
|
+
enum: enumData,
|
|
174
204
|
},
|
|
175
205
|
};
|
|
176
206
|
return accumulator;
|
|
@@ -179,12 +209,11 @@ async function openapiJsonrpcJsdoc({ files, securitySchemes = {}, packageUrl, se
|
|
|
179
209
|
title: 'Parameters',
|
|
180
210
|
type: 'object',
|
|
181
211
|
'default': exampleJSON,
|
|
182
|
-
required:
|
|
212
|
+
required: [],
|
|
183
213
|
properties: {},
|
|
184
214
|
},
|
|
185
215
|
);
|
|
186
216
|
const schemaPostJsdoc = schema.post.requestBody.content['application/json'].schema;
|
|
187
|
-
schemaPostJsdoc.required.push('params');
|
|
188
217
|
schemaPostJsdoc.properties.params = propertiesParameters;
|
|
189
218
|
}
|
|
190
219
|
temporaryDocument.paths[`${api}${apiName}`] = schema;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openapi-jsonrpc-jsdoc",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.3",
|
|
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": {
|