You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* fix: handling x-omitempty property for definition properties (#68)
* docs: update CHANGELOG
* docs: update CHANGELOG
* Migrate to eta (#88)
* BREAKING CHANGE: migrate from mustache template engine to eta template engine
* fix: merge conflicts after rebasing next
Co-authored-by: Rafael Fakhreev <[email protected]>
Co-authored-by: svolkov <[email protected]>
* chore: update README (Contribution)
* Refactor render layer (#90)
* fix: handling x-omitempty property for definition properties (#68)
* docs: update CHANGELOG
* docs: update CHANGELOG; bump: up project version to 2.0.0
* BREAKING_CHANGE: renamed mustache templates, split client mustache template
* BREAKING CHANGE: migrate from mustache template engine to eta template engine
* feat: rewrite render layer
- Respect single responsibility principle
- Use Eta includeFile
- Force use "No description" JSDoc comment
* fix: handling x-omitempty property for definition properties (#68)
* docs: update CHANGELOG
* docs: update CHANGELOG
* Migrate to eta (#88)
* BREAKING CHANGE: migrate from mustache template engine to eta template engine
* fix: merge conflicts after rebasing next
Co-authored-by: Rafael Fakhreev <[email protected]>
Co-authored-by: svolkov <[email protected]>
* Sync code base
* chore: delete unnecessary dir
* Update index.js
Fix default templates path
Co-authored-by: svolkov <[email protected]>
Co-authored-by: Rafael Fakhreev <[email protected]>
* chore: revert back fix commit
* BREAKING_CHANGE: return type of generateApi(); feat: modular option; chore: update HttpClient class (exportable)
* fix: outOfModule modular
* feat: complete data contracts imports for modular api modules, add prettier organize imports plugin
* chore: remove console info
* BREAKING_CHANGE: move generating route names into eta template
* fix: problem of missing templates folder
* fix: try to fix problem with not using prettier plugin
* chore: refresh generated tests schemas
* BREAKING_CHANGE: update all dependencies to latest
* feat: improve types in index.d.ts file; refactor: processing templates folder, ETA templates, routes, schemas; feat: optional templates feature
* chore: update CHANGELOG
* feat: --extract-request-params option
* fix: add missing generateApi params to .d.ts file; feat: add support x-enumNames field for enums
* fix: enumNames getting from schema
* feat: improve data-contracts.eta template, now data contracts formatting inside template
* docs: update CHANGELOG
* feat: hooks property for watching/modifying parsed parts of schema
* fix: problem of complex types (`oneOf`, `allOf`) with `properties` field
* chore: fix problem of wrong js docs comments for procedure call
* feat: add pathArgs to routeInfo for routeName template
* BREAKING_CHANGE: properties data and error in HttpResponse type have duck types
* feat: add extraTemplate property for generateApi()
* docs: update docs for --templates option
* bump: up version to 4.0.0
* docs: update README
* refactor: move all type identifiers\naming into constants like TS_KEYWORDS, SCHEMA_TYPES; chore: move prepareConfig to hooks.onPrepareConfig; feat: add onInit hook; feat: enumNamesAsValues
* chore: try to fix travis yml
* chore: remove description from modular api class
* docs: update CHANGELOG
Co-authored-by: Rafael Fakhreev <[email protected]>
Co-authored-by: Rafael Fakhreev <[email protected]>
--modular generate separated files for http client, data contracts, and routes (default: false)
53
57
-h, --help display help for command
54
58
```
55
59
@@ -67,15 +71,23 @@ generateApi({
67
71
name:"MySuperbApi.ts", // name of output typescript file
68
72
url:'http://api.com/swagger.json', // url where located swagger schema
69
73
})
70
-
.then(sourceFile=>fs.writeFile(path, sourceFile))
74
+
.then(({ files, configuration }) => {
75
+
files.forEach(({ content, name }) => {
76
+
fs.writeFile(path, content);
77
+
});
78
+
})
71
79
.catch(e=>console.error(e))
72
80
73
81
// example with local file
74
82
generateApi({
75
83
name:"ApiModule.ts", // name of output typescript file
76
84
input:resolve(process.cwd(), './foo/swagger.json') // path to swagger schema
77
85
})
78
-
.then(sourceFile=>fs.writeFile(path, sourceFile))
86
+
.then(({ files, configuration }) => {
87
+
files.forEach(({ content, name }) => {
88
+
fs.writeFile(path, content);
89
+
});
90
+
})
79
91
.catch(e=>console.error(e))
80
92
81
93
// example with parsed schema
@@ -98,19 +110,36 @@ generateApi({
98
110
// ...
99
111
}
100
112
})
101
-
.then(sourceFile=>fs.writeFile(path, sourceFile))
113
+
.then(({ files, configuration }) => {
114
+
files.forEach(({ content, name }) => {
115
+
fs.writeFile(path, content);
116
+
});
117
+
})
102
118
.catch(e=>console.error(e))
103
119
104
120
```
105
121
106
122
107
123
## 💎 options
108
124
### **`--templates`**
109
-
This option should be used in cases when you don't want to use default `swagger-typescript-api` output structure
125
+
This option needed for cases when you don't want to use default `swagger-typescript-api` output structure
126
+
127
+
Templates:
128
+
-`api.eta` - Api class module
129
+
-`data-contracts.eta` - all types (data contracts) from swagger schema
130
+
-`http-client.eta` - HttpClient class module
131
+
-`procedure-call.eta` - route in Api class
132
+
-`route-docs.eta` - documentation for route in Api class
133
+
-`route-name.eta` - route name for route in Api class
134
+
-`route-type.eta` - *(`--route-types` option)*
135
+
-`route-types.eta` - *(`--route-types` option)*
136
+
110
137
How to use it:
111
-
1. copy [**swagger-typescript-api templates**](https://github.com/acacode/swagger-typescript-api/tree/mustache-latest/src/templates/defaults) into your place in project
138
+
1. copy swagger-typescript-api templates into your place in project
139
+
- from [/templates/default](https://github.com/acacode/swagger-typescript-api/tree/next/templates/default) for single api file
140
+
- from [/templates/modular](https://github.com/acacode/swagger-typescript-api/tree/next/templates/modular) for multiple api files (with `--modular` option)
0 commit comments