1.0.51 • Published 1 year ago

swagular v1.0.51

Weekly downloads
125
License
-
Repository
github
Last release
1 year ago

Swagular

Make your swagger specification source of true by generate client api includes form group controllers.

Motivation

To prevent rewrite schema again (in angular forms), or even more - prevent write the ui.

For example, we can just do :

model = this.swagularService.loginFormModel({ fields: [{ key: 'email' }, { key: 'password', type: 'password' }] });

And then using it in our component:

<swagular-form class="container" [model]="model" (submit)="login()"></swagular-form>

The full example is here

Get started

This package is using OpenAPI 3 code generator to generate the client api, so first run npm i ng-openapi-gen -D

Install the package by running npm i swagular

Add script that will generate the client api code to your package.json:

"gen": "ng-openapi-gen --input [path to your api doc] --templates node_modules/swagular/templates",

Now you can just run npm run gen, it will generate the code under src/app/api folder.

import the modules to your angular modules -

ApiModule.forRoot({ rootUrl: [path to your api] }),
SwagularModule

Add the service to your component dependencies.

constructor(private service: SomeService) {}

Using generated form group

if your route have body params, you can see the relevant form group in the generated service.

for example - login route -

formGroup = this.service.loginFormGroup();

using swagular form component

you can use swagular form component instead of building the form on your own -

  • install angular material ng add @angular/material
  • import SwagularComponentModule to ng module.
  • declare the form model
  model: FormModel<LoginFormGroupType> = {
  formGroup: this.service.loginFormGroup(),
  formTitle: 'Login Form',
  formSaveButtonTitle: 'Login',
  fields: [{ key: 'email' }, { key: 'password', type: 'password' }]
};
  • bind the model to swagular-form component
    <swagular-form class="container" [model]="model" (submit)="login()"></swagular-form>
1.0.44

1 year ago

1.0.43

1 year ago

1.0.48

1 year ago

1.0.49

1 year ago

1.0.51

1 year ago

1.0.37

2 years ago

1.0.39

2 years ago

1.0.38

2 years ago

1.0.40

2 years ago

1.0.42

2 years ago

1.0.41

2 years ago

1.0.36

3 years ago

1.0.35

3 years ago

1.0.34

3 years ago

1.0.22

3 years ago

1.0.26

3 years ago

1.0.25

3 years ago

1.0.24

3 years ago

1.0.23

3 years ago

1.0.29

3 years ago

1.0.28

3 years ago

1.0.27

3 years ago

1.0.33

3 years ago

1.0.32

3 years ago

1.0.31

3 years ago

1.0.30

3 years ago

1.0.21

3 years ago

1.0.20

3 years ago

1.0.19

3 years ago

1.0.18

3 years ago

1.0.17

3 years ago

1.0.16

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.4

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

0.1.90

3 years ago

1.0.3

3 years ago

0.1.89

3 years ago

0.1.85

3 years ago

0.1.86

3 years ago

0.1.87

3 years ago

0.1.88

3 years ago

0.1.80

3 years ago

0.1.81

3 years ago

0.1.82

3 years ago

0.1.83

3 years ago

0.1.84

3 years ago

0.1.75

3 years ago

0.1.76

3 years ago

0.1.77

3 years ago

0.1.78

3 years ago

0.1.79

3 years ago

0.1.36

3 years ago

0.1.35

3 years ago

0.1.34

3 years ago

0.1.32

3 years ago

0.1.33

3 years ago

0.1.31

3 years ago

0.1.30

3 years ago

0.1.22

3 years ago

0.1.23

3 years ago

0.1.24

3 years ago

0.1.17

3 years ago

0.1.12

3 years ago

0.1.13

3 years ago

0.1.14

3 years ago

0.1.15

3 years ago

0.1.16

3 years ago

0.1.11

3 years ago

0.1.10

3 years ago

0.1.8

3 years ago

0.1.9

3 years ago

0.1.7

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago

0.1.2

3 years ago

0.1.3

3 years ago

0.1.1

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago