@necessarylion/adonis-autoswagger 0.0.16 → 0.0.18

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.
@@ -251,14 +251,31 @@ class CommentParser {
251
251
  ks.push(key);
252
252
  if (value["required"])
253
253
  required.push(key);
254
- props.push({
255
- [key]: {
256
- type: typeof value["type"] === "undefined" ? "string" : value["type"],
257
- format: typeof value["format"] === "undefined"
258
- ? "string"
259
- : value["format"],
260
- },
261
- });
254
+ const type = typeof value["type"] === "undefined" ? "string" : value["type"];
255
+ if (type !== 'array') {
256
+ props.push({
257
+ [key]: {
258
+ type,
259
+ format: typeof value["format"] === "undefined"
260
+ ? "string"
261
+ : value["format"],
262
+ example: parsedRef[key],
263
+ enum: value["enum"]
264
+ },
265
+ });
266
+ }
267
+ else {
268
+ props.push({
269
+ [`${key}[]`]: {
270
+ type,
271
+ example: '',
272
+ items: {
273
+ type: value["items"]["type"],
274
+ format: value["items"]["format"],
275
+ }
276
+ }
277
+ });
278
+ }
262
279
  });
263
280
  const properties = props.reduce((acc, curr) => ({ ...acc, ...curr }), {});
264
281
  const appends = Object.keys(parsedRef).filter((k) => !ks.includes(k));
@@ -108,7 +108,6 @@ class ValidatorParser {
108
108
  const type = property["type"];
109
109
  const field = property["fieldName"];
110
110
  if (type === "object") {
111
- console.log(field, property);
112
111
  obj[field] = { type: "object", ...this.#parseSchema(property, refs) };
113
112
  }
114
113
  else {
@@ -125,14 +124,16 @@ class ValidatorParser {
125
124
  }
126
125
  else {
127
126
  const meta = this.#getMetaFromValidations(property["each"]["validations"], refs);
127
+ const subType = this.#getType(property["each"]["subtype"]);
128
128
  obj[field] = {
129
129
  type: "array",
130
130
  items: {
131
131
  type: this.#getType(property["each"]["type"]),
132
132
  ...meta,
133
+ format: subType === 'multipartFile' ? 'binary' : undefined,
133
134
  example: meta.example ??
134
135
  meta.minimum ??
135
- this.exampleGenerator.exampleByType("number"),
136
+ this.exampleGenerator.exampleByType(subType),
136
137
  },
137
138
  };
138
139
  }
package/dist/schema.js CHANGED
@@ -156,7 +156,6 @@ class SchemaService {
156
156
  for (const modelPath of modelPaths) {
157
157
  files.push(...await this.fileService.getFiles(path_1.default.join(this.options.appPath, modelPath), [], this.options.models?.ignores));
158
158
  }
159
- console.log(files);
160
159
  const readFile = util_1.default.promisify(fs_1.default.readFile);
161
160
  if (this.options.debug) {
162
161
  console.log("Found model files", files);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@necessarylion/adonis-autoswagger",
3
- "version": "0.0.16",
3
+ "version": "0.0.18",
4
4
  "description": "Auto-Generate swagger docs for AdonisJS",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",