1.0.51 • Published 2 years ago

swagular v1.0.51

Weekly downloads
125
License
-
Repository
github
Last release
2 years 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

2 years ago

1.0.43

2 years ago

1.0.48

2 years ago

1.0.49

2 years ago

1.0.51

2 years ago

1.0.37

3 years ago

1.0.39

3 years ago

1.0.38

3 years ago

1.0.40

3 years ago

1.0.42

3 years ago

1.0.41

3 years ago

1.0.36

4 years ago

1.0.35

4 years ago

1.0.34

4 years ago

1.0.22

4 years ago

1.0.26

4 years ago

1.0.25

4 years ago

1.0.24

4 years ago

1.0.23

4 years ago

1.0.29

4 years ago

1.0.28

4 years ago

1.0.27

4 years ago

1.0.33

4 years ago

1.0.32

4 years ago

1.0.31

4 years ago

1.0.30

4 years ago

1.0.21

4 years ago

1.0.20

4 years ago

1.0.19

4 years ago

1.0.18

4 years ago

1.0.17

4 years ago

1.0.16

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.15

4 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.4

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

0.1.90

4 years ago

1.0.3

4 years ago

0.1.89

4 years ago

0.1.85

4 years ago

0.1.86

4 years ago

0.1.87

4 years ago

0.1.88

4 years ago

0.1.80

4 years ago

0.1.81

4 years ago

0.1.82

4 years ago

0.1.83

4 years ago

0.1.84

4 years ago

0.1.75

4 years ago

0.1.76

4 years ago

0.1.77

4 years ago

0.1.78

4 years ago

0.1.79

4 years ago

0.1.36

4 years ago

0.1.35

4 years ago

0.1.34

4 years ago

0.1.32

4 years ago

0.1.33

4 years ago

0.1.31

4 years ago

0.1.30

4 years ago

0.1.22

4 years ago

0.1.23

4 years ago

0.1.24

4 years ago

0.1.17

4 years ago

0.1.12

4 years ago

0.1.13

4 years ago

0.1.14

4 years ago

0.1.15

4 years ago

0.1.16

4 years ago

0.1.11

4 years ago

0.1.10

4 years ago

0.1.8

4 years ago

0.1.9

4 years ago

0.1.7

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.2

4 years ago

0.1.3

4 years ago

0.1.1

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago