@necessarylion/adonis-autoswagger 0.0.8 → 0.0.9

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/README.md CHANGED
@@ -18,7 +18,7 @@ pnpm i @necessarylion/adonis-autoswagger #using pnpm
18
18
 
19
19
  ---
20
20
 
21
- *This is a fork of [adonis-autoswagger](https://github.com/ad-on-is/adonis-autoswagger) with some additional features.*
21
+ _This is a fork of [adonis-autoswagger](https://github.com/ad-on-is/adonis-autoswagger) with some additional features._
22
22
 
23
23
  ## ⭐️ Features
24
24
 
@@ -467,10 +467,10 @@ Automatically generates swagger schema-descriptions based on your validators.
467
467
  ```ts
468
468
  export const adminLogin = vine.compile(
469
469
  vine.object({
470
- email: vine.string().trim().example('admin@laconcept.de'),
471
- password: vine.string().trim().example('password'),
470
+ email: vine.string().trim().example("admin@laconcept.de"),
471
+ password: vine.string().trim().example("password"),
472
472
  })
473
- )
473
+ );
474
474
  ```
475
475
 
476
476
  ##### Create custom validators with vine
@@ -478,38 +478,41 @@ export const adminLogin = vine.compile(
478
478
  ```ts
479
479
  // start/validators/example.ts
480
480
 
481
- import vine, { VineNumber, VineString, VineNativeEnum } from '@vinejs/vine'
482
- import { EnumLike } from '@vinejs/vine/types'
481
+ import vine, { VineNumber, VineString, VineNativeEnum } from "@vinejs/vine";
482
+ import { EnumLike } from "@vinejs/vine/types";
483
483
 
484
484
  type Options = {
485
- example: any
486
- }
485
+ example: any;
486
+ };
487
487
 
488
- declare module '@vinejs/vine' {
488
+ declare module "@vinejs/vine" {
489
489
  interface VineString {
490
- example(example: string): this
490
+ example(example: string): this;
491
491
  }
492
492
  interface VineNumber {
493
- example(example: number): this
493
+ example(example: number): this;
494
494
  }
495
495
  interface VineNativeEnum<Values extends EnumLike> {
496
- example(example: string): this
496
+ example(example: string): this;
497
497
  }
498
498
  }
499
499
 
500
500
  export const exampleRule = vine.createRule((_: unknown, opt: Options) => {
501
- return opt.example
502
- })
503
-
504
- VineString.macro('example', function (this: VineString, example: string) {
505
- return this.use(exampleRule({ example }))
506
- })
507
- VineNumber.macro('example', function (this: VineNumber, example: number) {
508
- return this.use(exampleRule({ example }))
509
- })
510
- VineNativeEnum.macro('example', function (this: VineNativeEnum<any>, example: string) {
511
- return this.use(exampleRule({ example }))
512
- })
501
+ return opt.example;
502
+ });
503
+
504
+ VineString.macro("example", function (this: VineString, example: string) {
505
+ return this.use(exampleRule({ example }));
506
+ });
507
+ VineNumber.macro("example", function (this: VineNumber, example: number) {
508
+ return this.use(exampleRule({ example }));
509
+ });
510
+ VineNativeEnum.macro(
511
+ "example",
512
+ function (this: VineNativeEnum<any>, example: string) {
513
+ return this.use(exampleRule({ example }));
514
+ }
515
+ );
513
516
  ```
514
517
 
515
518
  ##### Import in `adonisrc.ts` preloads
@@ -579,6 +582,9 @@ Specify a format for that field, i.e. uuid, email, binary, etc...
579
582
  **@example(foo bar)**
580
583
  Use this field to provide own example values for specific fields
581
584
 
585
+ **@serializeAs(foo)**
586
+ Use this field to serialize for specific fields
587
+
582
588
  **@props({"minLength": 10, "foo": "bar"})**
583
589
  Use this field to provide additional properties to a field, like minLength, maxLength, etc. Needs to bee valid JSON.
584
590
 
@@ -65,6 +65,10 @@ class ModelParser {
65
65
  }
66
66
  let splittedLine2 = splittedLine[1].replace(/;/g, "").split(":");
67
67
  let field = splittedLine2[0].replace('?', '');
68
+ if (index > 0 && lines[index - 1].includes("@serializeAs")) {
69
+ const line = lines[index - 1];
70
+ field = (0, helpers_1.getBetweenBrackets)(line, "serializeAs");
71
+ }
68
72
  let type = splittedLine2[1] || "";
69
73
  type = type.trim();
70
74
  let enums = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@necessarylion/adonis-autoswagger",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "description": "Auto-Generate swagger docs for AdonisJS",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",