|
1 | | -# Swagger to Angular - Templates |
| 1 | +# TypeScript OpenApi/Swagger Generator - Templates |
2 | 2 |
|
3 | | -Templates specify template for each file type generated, so you can edit them and custom as you like. |
| 3 | +## Details |
4 | 4 |
|
5 | | -For now you can only have one template per type. |
| 5 | +This folder contain a list of presets for different languages. |
| 6 | + |
| 7 | +Also you can create your own, it's easy! |
| 8 | + |
| 9 | +## How to create a custom template |
| 10 | + |
| 11 | +### 1 - Duplicate any template folder |
| 12 | + |
| 13 | +To create a new template, first duplicate some folder (recommended `angular2`) to use as base. |
| 14 | + |
| 15 | +Just name it as you whish. |
| 16 | + |
| 17 | +> If you trying to create a preset to push it to the main repo, you should create it in this folder with a **coherent full-name** in **kevab case**. |
| 18 | +> For example for "TypeScript": `type-script`, instead `ts`. |
| 19 | +
|
| 20 | +> If you are creating a **custom template** for you own, just create anywhere in your machine/repository, it's not a requirement to be in this folder. |
| 21 | +
|
| 22 | +### 2 - Customize your template |
| 23 | + |
| 24 | +This step is the hardest one, you have to change all files to adapt to your Language/Framework/Library. |
| 25 | + |
| 26 | +Just change the current templates/files to that. |
| 27 | + |
| 28 | +### 3 - Generate the api files with your own template |
| 29 | + |
| 30 | +Just launch the command to generate your files BUT changing (or adding) `template` flag (`-t`). |
| 31 | + |
| 32 | +```bash |
| 33 | +# Using a "preset" |
| 34 | +transform-swagger -f URI/TO/SWAGGER/JSON/OR/YAML -o src/generatedApi/ -t type-script |
| 35 | + |
| 36 | +# Using a "custom path" |
| 37 | +transform-swagger -f URI/TO/SWAGGER/JSON/OR/YAML -o src/generatedApi/ -t ./path/to/your/template |
| 38 | +``` |
| 39 | + |
| 40 | +### 4 - Just enjoy your saved time! |
| 41 | + |
| 42 | +Easy, right? |
0 commit comments