@necessarylion/adonis-autoswagger 0.0.20 → 0.0.22
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/dist/auto_swagger.js
CHANGED
|
@@ -290,7 +290,9 @@ class AutoSwagger {
|
|
|
290
290
|
}
|
|
291
291
|
delete responses[responseCodes[method]]["summary"];
|
|
292
292
|
}
|
|
293
|
-
|
|
293
|
+
// An own @description wins. The response text is only the fallback.
|
|
294
|
+
if (description === "" &&
|
|
295
|
+
typeof responses[responseCodes[method]] !== "undefined" &&
|
|
294
296
|
typeof responses[responseCodes[method]]["description"] !==
|
|
295
297
|
"undefined") {
|
|
296
298
|
description = responses[responseCodes[method]]["description"];
|
|
@@ -377,6 +379,7 @@ class AutoSwagger {
|
|
|
377
379
|
in: 'query',
|
|
378
380
|
name: key,
|
|
379
381
|
required: required.includes(key),
|
|
382
|
+
description: data.description,
|
|
380
383
|
schema: data,
|
|
381
384
|
});
|
|
382
385
|
}
|
|
@@ -109,6 +109,8 @@ class ValidatorParser {
|
|
|
109
109
|
const field = property["fieldName"];
|
|
110
110
|
if (type === "object") {
|
|
111
111
|
obj[field] = { type: "object", ...this.#parseSchema(property, refs) };
|
|
112
|
+
if (meta.description)
|
|
113
|
+
obj[field].description = meta.description;
|
|
112
114
|
}
|
|
113
115
|
else {
|
|
114
116
|
// if array
|
|
@@ -123,24 +125,26 @@ class ValidatorParser {
|
|
|
123
125
|
};
|
|
124
126
|
}
|
|
125
127
|
else {
|
|
126
|
-
const
|
|
128
|
+
const itemMeta = this.#getMetaFromValidations(property["each"]["validations"], refs);
|
|
127
129
|
const subType = this.#getType(property["each"]["subtype"]);
|
|
128
130
|
obj[field] = {
|
|
129
131
|
type: "array",
|
|
130
132
|
items: {
|
|
131
|
-
type: this.#getType(property["each"]["type"]),
|
|
132
|
-
...
|
|
133
|
+
type: this.#getType(property["each"]["type"], property["each"]["subtype"]),
|
|
134
|
+
...itemMeta,
|
|
133
135
|
format: subType === 'multipartFile' ? 'binary' : undefined,
|
|
134
|
-
example:
|
|
135
|
-
|
|
136
|
+
example: itemMeta.example ??
|
|
137
|
+
itemMeta.minimum ??
|
|
136
138
|
this.exampleGenerator.exampleByType(subType),
|
|
137
139
|
},
|
|
138
140
|
};
|
|
139
141
|
}
|
|
142
|
+
if (meta.description)
|
|
143
|
+
obj[field].description = meta.description;
|
|
140
144
|
}
|
|
141
145
|
else {
|
|
142
146
|
obj[field] = {
|
|
143
|
-
type: this.#getType(type),
|
|
147
|
+
type: this.#getType(type, property["subtype"]),
|
|
144
148
|
example: meta.example ??
|
|
145
149
|
meta.minimum ??
|
|
146
150
|
this.exampleGenerator.exampleByType("number"),
|
|
@@ -156,15 +160,22 @@ class ValidatorParser {
|
|
|
156
160
|
result["required"] = required;
|
|
157
161
|
return result;
|
|
158
162
|
}
|
|
159
|
-
#getType(type) {
|
|
163
|
+
#getType(type, subtype) {
|
|
160
164
|
if (type == "literal") {
|
|
161
|
-
|
|
165
|
+
// vine says "literal" for every plain value and keeps the real type in subtype
|
|
166
|
+
return subtype === "number" || subtype === "boolean" ? subtype : "string";
|
|
162
167
|
}
|
|
163
168
|
return type;
|
|
164
169
|
}
|
|
165
170
|
#getMetaFromValidations(validations, refs) {
|
|
166
171
|
let meta = {};
|
|
167
172
|
for (const validation of validations) {
|
|
173
|
+
if (refs[validation["ruleFnId"]].options?.description) {
|
|
174
|
+
meta = {
|
|
175
|
+
...meta,
|
|
176
|
+
description: refs[validation["ruleFnId"]].options.description,
|
|
177
|
+
};
|
|
178
|
+
}
|
|
168
179
|
if (refs[validation["ruleFnId"]].options?.example) {
|
|
169
180
|
meta = {
|
|
170
181
|
...meta,
|