openapi-jsonrpc-jsdoc 1.5.0 → 1.5.1
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.mjs +24 -17
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -164,30 +164,40 @@ export default async function openapiJsonrpcJsdoc({
|
|
|
164
164
|
samples = ['node', 'javascript'],
|
|
165
165
|
...xHeaders
|
|
166
166
|
}) {
|
|
167
|
-
const
|
|
168
|
-
files: Array.isArray(files) ? files : [files],
|
|
169
|
-
packageJson: packageUrl,
|
|
167
|
+
const options = {
|
|
170
168
|
access,
|
|
171
169
|
encoding,
|
|
170
|
+
samples,
|
|
171
|
+
files: Array.isArray(files) ? files : [files],
|
|
172
172
|
undocumented: false,
|
|
173
173
|
allowUnknownTags: true,
|
|
174
174
|
dictionaries: ['jsdoc'],
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
175
|
+
};
|
|
176
|
+
if (info.title) {
|
|
177
|
+
options.cache = true;
|
|
178
|
+
} else {
|
|
179
|
+
options.package = packageUrl;
|
|
180
|
+
}
|
|
181
|
+
let documents;
|
|
182
|
+
if (options.cache) {
|
|
183
|
+
documents = await jsdoc.explain(options);
|
|
184
|
+
} else {
|
|
185
|
+
const allData = await jsdoc.explain(options);
|
|
186
|
+
documents = allData.filter(item => item.kind !== 'package');
|
|
187
|
+
const package_ = allData.find(item => item.kind === 'package');
|
|
188
|
+
info.version = package_.version;
|
|
189
|
+
info.title = package_.name;
|
|
190
|
+
info.description = package_.description;
|
|
191
|
+
}
|
|
192
|
+
if (!info.title) {
|
|
193
|
+
throw new Error('API title is required. Please set packageUrl or info object.');
|
|
194
|
+
}
|
|
180
195
|
const temporaryDocument = {
|
|
181
196
|
'openapi': openapi,
|
|
182
197
|
'x-samples-enabled': samples.length > 0,
|
|
183
198
|
'x-samples-languages': samples,
|
|
184
199
|
...xHeaders,
|
|
185
|
-
'info':
|
|
186
|
-
version: package_.version,
|
|
187
|
-
title: package_.name,
|
|
188
|
-
description: package_.description,
|
|
189
|
-
...info,
|
|
190
|
-
},
|
|
200
|
+
'info': info,
|
|
191
201
|
'servers': servers,
|
|
192
202
|
'paths': {},
|
|
193
203
|
'components': {
|
|
@@ -218,9 +228,6 @@ export default async function openapiJsonrpcJsdoc({
|
|
|
218
228
|
'security': Object.keys(securitySchemes).map(val => ({ [val]: [] })),
|
|
219
229
|
'tags': [],
|
|
220
230
|
};
|
|
221
|
-
if (!temporaryDocument.info.title) {
|
|
222
|
-
throw new Error('Info title is required');
|
|
223
|
-
}
|
|
224
231
|
const requiredSchema = ['method', 'jsonrpc'];
|
|
225
232
|
prepare: for (const module of documents) {
|
|
226
233
|
let isJsonRpc = false;
|