openapi-jsonrpc-jsdoc 1.2.3 → 1.2.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.
Files changed (2) hide show
  1. package/index.js +23 -10
  2. 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,6 +167,7 @@ async function openapiJsonrpcJsdoc({ files, securitySchemes = {}, packageUrl, se
164
167
  }
165
168
  let items;
166
169
  let enumData;
170
+
167
171
  switch (type) {
168
172
  case 'Array.<string>': {
169
173
  type = 'array';
@@ -176,8 +180,12 @@ async function openapiJsonrpcJsdoc({ files, securitySchemes = {}, packageUrl, se
176
180
  break;
177
181
  }
178
182
  case 'enum': {
179
- type = 'string';
180
183
  enumData = parameter.type.names;
184
+ if (parameter.type.names.every(n => !Number.isNaN(Number(n)))) {
185
+ type = 'number';
186
+ } else {
187
+ type = 'string';
188
+ }
181
189
  break;
182
190
  }
183
191
  default: {
@@ -194,15 +202,20 @@ async function openapiJsonrpcJsdoc({ files, securitySchemes = {}, packageUrl, se
194
202
  if (!parameter.optional) {
195
203
  accumulator.required.push(name);
196
204
  }
197
- accumulator.properties = {
198
- ...accumulator.properties,
199
- [name]: {
200
- type,
201
- description,
202
- items,
203
- enum: enumData,
204
- },
205
- };
205
+ accumulator.properties[name] = accumulator.properties[name] ?? {};
206
+ if (type) {
207
+ accumulator.properties[name].type = type;
208
+ }
209
+ if (description) {
210
+ accumulator.properties[name].description = description;
211
+ }
212
+ if (items) {
213
+ accumulator.properties[name].items = items;
214
+ }
215
+ if (enumData) {
216
+ accumulator.properties[name].enum = enumData;
217
+ }
218
+
206
219
  return accumulator;
207
220
  },
208
221
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openapi-jsonrpc-jsdoc",
3
- "version": "1.2.3",
3
+ "version": "1.2.5",
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": {