ng-openapi 0.2.19 → 0.2.20-pr-85-testing-1481b20.0
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 +51 -56
- package/package.json +88 -88
package/README.md
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
<p align="center">💪 Made with ❤️ by Angular Devs for Angular Devs</p>
|
|
5
5
|
</div>
|
|
6
6
|
|
|
7
|
-
|
|
8
7
|
<p align="center">
|
|
9
8
|
<a href="https://stackblitz.com/@Mr-Jami/collections/ng-openapi-examples">⚡Examples</a>
|
|
10
9
|
<span> • </span>
|
|
@@ -38,30 +37,30 @@ yarn add ng-openapi --dev
|
|
|
38
37
|
Create a configuration file (e.g., `openapi.config.ts`):
|
|
39
38
|
|
|
40
39
|
```typescript
|
|
41
|
-
import { GeneratorConfig } from
|
|
40
|
+
import { GeneratorConfig } from "ng-openapi";
|
|
42
41
|
|
|
43
42
|
const config: GeneratorConfig = {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
43
|
+
input: "./swagger.json",
|
|
44
|
+
output: "./src/api",
|
|
45
|
+
options: {
|
|
46
|
+
dateType: "Date",
|
|
47
|
+
enumStyle: "enum",
|
|
48
|
+
generateEnumBasedOnDescription: true,
|
|
49
|
+
generateServices: true,
|
|
50
|
+
customHeaders: {
|
|
51
|
+
"X-Requested-With": "XMLHttpRequest",
|
|
52
|
+
Accept: "application/json",
|
|
53
|
+
},
|
|
54
|
+
responseTypeMapping: {
|
|
55
|
+
"application/pdf": "blob",
|
|
56
|
+
"application/zip": "blob",
|
|
57
|
+
"text/csv": "text",
|
|
58
|
+
},
|
|
59
|
+
customizeMethodName: (operationId) => {
|
|
60
|
+
const parts = operationId.split("_");
|
|
61
|
+
return parts[parts.length - 1] || operationId;
|
|
62
|
+
},
|
|
59
63
|
},
|
|
60
|
-
customizeMethodName: (operationId) => {
|
|
61
|
-
const parts = operationId.split('_');
|
|
62
|
-
return parts[parts.length - 1] || operationId;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
64
|
};
|
|
66
65
|
|
|
67
66
|
export default config;
|
|
@@ -142,17 +141,17 @@ The simplest way to integrate ng-openapi is using the provider function:
|
|
|
142
141
|
|
|
143
142
|
```typescript
|
|
144
143
|
// In your app.config.ts
|
|
145
|
-
import { ApplicationConfig } from
|
|
146
|
-
import { provideNgOpenapi } from
|
|
144
|
+
import { ApplicationConfig } from "@angular/core";
|
|
145
|
+
import { provideNgOpenapi } from "./api/providers";
|
|
147
146
|
|
|
148
147
|
export const appConfig: ApplicationConfig = {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
148
|
+
providers: [
|
|
149
|
+
// One-line setup with automatic interceptor configuration
|
|
150
|
+
provideNgOpenapi({
|
|
151
|
+
basePath: "https://api.example.com",
|
|
152
|
+
}),
|
|
153
|
+
// other providers...
|
|
154
|
+
],
|
|
156
155
|
};
|
|
157
156
|
```
|
|
158
157
|
|
|
@@ -166,50 +165,46 @@ That's it! This automatically configures:
|
|
|
166
165
|
```typescript
|
|
167
166
|
// Disable date transformation
|
|
168
167
|
provideNgOpenapi({
|
|
169
|
-
|
|
170
|
-
|
|
168
|
+
basePath: "https://api.example.com",
|
|
169
|
+
enableDateTransform: false,
|
|
171
170
|
});
|
|
172
171
|
|
|
173
172
|
// Async configuration
|
|
174
173
|
provideNgOpenapiAsync({
|
|
175
|
-
|
|
174
|
+
basePath: () => import("./config").then((c) => c.apiConfig.baseUrl),
|
|
176
175
|
});
|
|
177
176
|
```
|
|
178
177
|
|
|
179
178
|
## Using Generated Services
|
|
180
179
|
|
|
181
180
|
```typescript
|
|
182
|
-
import { Component, inject } from
|
|
183
|
-
import { toSignal } from
|
|
184
|
-
import { UserService } from
|
|
185
|
-
import { User } from
|
|
181
|
+
import { Component, inject } from "@angular/core";
|
|
182
|
+
import { toSignal } from "@angular/core/rxjs-interop";
|
|
183
|
+
import { UserService } from "./api/services";
|
|
184
|
+
import { User } from "./api/models";
|
|
186
185
|
|
|
187
186
|
@Component({
|
|
188
|
-
|
|
189
|
-
|
|
187
|
+
selector: "app-users",
|
|
188
|
+
template: `...`,
|
|
190
189
|
})
|
|
191
190
|
export class UsersComponent {
|
|
192
|
-
|
|
193
|
-
|
|
191
|
+
private readonly userService = inject(UserService);
|
|
192
|
+
readonly users = toSignal(this.userService.getUsers());
|
|
194
193
|
}
|
|
195
194
|
```
|
|
196
195
|
|
|
197
196
|
## File Download Example
|
|
198
197
|
|
|
199
198
|
```typescript
|
|
200
|
-
import { Component, inject } from
|
|
201
|
-
import { downloadFileOperator } from
|
|
199
|
+
import { Component, inject } from "@angular/core";
|
|
200
|
+
import { downloadFileOperator } from "./api/utils/file-download";
|
|
202
201
|
|
|
203
202
|
export class ReportComponent {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
downloadFileOperator('report.pdf')
|
|
210
|
-
)
|
|
211
|
-
.subscribe();
|
|
212
|
-
}
|
|
203
|
+
private readonly reportService = inject(ReportService);
|
|
204
|
+
|
|
205
|
+
downloadReport() {
|
|
206
|
+
this.reportService.getReport("pdf", { reportId: 123 }).pipe(downloadFileOperator("report.pdf")).subscribe();
|
|
207
|
+
}
|
|
213
208
|
}
|
|
214
209
|
```
|
|
215
210
|
|
|
@@ -219,8 +214,8 @@ Add these scripts to your `package.json`:
|
|
|
219
214
|
|
|
220
215
|
```json
|
|
221
216
|
{
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
217
|
+
"scripts": {
|
|
218
|
+
"generate:api": "ng-openapi -c openapi.config.ts"
|
|
219
|
+
}
|
|
225
220
|
}
|
|
226
221
|
```
|
package/package.json
CHANGED
|
@@ -1,92 +1,92 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
},
|
|
28
|
-
"license": "MIT",
|
|
29
|
-
"homepage": "https://ng-openapi.dev/",
|
|
30
|
-
"bugs": {
|
|
31
|
-
"url": "https://github.com/ng-openapi/ng-openapi/issues"
|
|
32
|
-
},
|
|
33
|
-
"repository": {
|
|
34
|
-
"type": "git",
|
|
35
|
-
"url": "git+https://github.com/ng-openapi/ng-openapi.git",
|
|
36
|
-
"directory": "packages/ng-openapi"
|
|
37
|
-
},
|
|
38
|
-
"funding": {
|
|
39
|
-
"type": "github",
|
|
40
|
-
"url": "https://github.com/sponsors/ng-openapi"
|
|
41
|
-
},
|
|
42
|
-
"main": "./index.cjs",
|
|
43
|
-
"module": "./index.js",
|
|
44
|
-
"types": "./index.d.ts",
|
|
45
|
-
"bin": {
|
|
46
|
-
"ng-openapi": "./cli.cjs"
|
|
47
|
-
},
|
|
48
|
-
"files": [
|
|
49
|
-
"index.js",
|
|
50
|
-
"index.cjs",
|
|
51
|
-
"index.d.ts",
|
|
52
|
-
"cli.cjs",
|
|
53
|
-
"lib/**/*.js",
|
|
54
|
-
"lib/**/*.cjs",
|
|
55
|
-
"lib/**/*.d.ts",
|
|
56
|
-
"README.md",
|
|
57
|
-
"LICENSE",
|
|
58
|
-
"CHANGELOG.md"
|
|
59
|
-
],
|
|
60
|
-
"scripts": {
|
|
61
|
-
"prepublishOnly": "echo 'Build the package using: npm run build:ng-openapi from workspace root'",
|
|
62
|
-
"build": "tsup"
|
|
63
|
-
},
|
|
64
|
-
"dependencies": {
|
|
65
|
-
"commander": "^14.0.0",
|
|
66
|
-
"ts-morph": "^26.0.0",
|
|
67
|
-
"ts-node": "^10.9.2",
|
|
68
|
-
"typescript": "^5.8.3",
|
|
69
|
-
"@types/swagger-schema-official": "^2.0.25",
|
|
70
|
-
"js-yaml": "^4.1.0"
|
|
71
|
-
},
|
|
72
|
-
"peerDependencies": {
|
|
73
|
-
"@angular/core": ">=15",
|
|
74
|
-
"@angular/common": ">=15"
|
|
75
|
-
},
|
|
76
|
-
"peerDependenciesMeta": {
|
|
77
|
-
"@angular/core": {
|
|
78
|
-
"optional": false
|
|
2
|
+
"name": "ng-openapi",
|
|
3
|
+
"version": "0.2.20-pr-85-testing-1481b20.0",
|
|
4
|
+
"description": "Generate Angular services and TypeScript types from OpenAPI/Swagger specifications",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"ng-openapi",
|
|
7
|
+
"angular",
|
|
8
|
+
"openapi",
|
|
9
|
+
"swagger",
|
|
10
|
+
"codegen",
|
|
11
|
+
"typescript",
|
|
12
|
+
"generator",
|
|
13
|
+
"code-generator",
|
|
14
|
+
"api",
|
|
15
|
+
"rest",
|
|
16
|
+
"http",
|
|
17
|
+
"cli",
|
|
18
|
+
"ng",
|
|
19
|
+
"ng openapi",
|
|
20
|
+
"httpResource",
|
|
21
|
+
"reactive"
|
|
22
|
+
],
|
|
23
|
+
"author": {
|
|
24
|
+
"name": "Tareq Jami",
|
|
25
|
+
"email": "info@jami-it.de",
|
|
26
|
+
"url": "http://tareqjami.de"
|
|
79
27
|
},
|
|
80
|
-
"
|
|
81
|
-
|
|
28
|
+
"license": "MIT",
|
|
29
|
+
"homepage": "https://ng-openapi.dev/",
|
|
30
|
+
"bugs": {
|
|
31
|
+
"url": "https://github.com/ng-openapi/ng-openapi/issues"
|
|
32
|
+
},
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "git+https://github.com/ng-openapi/ng-openapi.git",
|
|
36
|
+
"directory": "packages/ng-openapi"
|
|
37
|
+
},
|
|
38
|
+
"funding": {
|
|
39
|
+
"type": "github",
|
|
40
|
+
"url": "https://github.com/sponsors/ng-openapi"
|
|
41
|
+
},
|
|
42
|
+
"main": "./index.cjs",
|
|
43
|
+
"module": "./index.js",
|
|
44
|
+
"types": "./index.d.ts",
|
|
45
|
+
"bin": {
|
|
46
|
+
"ng-openapi": "./cli.cjs"
|
|
47
|
+
},
|
|
48
|
+
"files": [
|
|
49
|
+
"index.js",
|
|
50
|
+
"index.cjs",
|
|
51
|
+
"index.d.ts",
|
|
52
|
+
"cli.cjs",
|
|
53
|
+
"lib/**/*.js",
|
|
54
|
+
"lib/**/*.cjs",
|
|
55
|
+
"lib/**/*.d.ts",
|
|
56
|
+
"README.md",
|
|
57
|
+
"LICENSE",
|
|
58
|
+
"CHANGELOG.md"
|
|
59
|
+
],
|
|
60
|
+
"scripts": {
|
|
61
|
+
"prepublishOnly": "echo 'Build the package using: npm run build:ng-openapi from workspace root'",
|
|
62
|
+
"build": "tsup"
|
|
63
|
+
},
|
|
64
|
+
"dependencies": {
|
|
65
|
+
"commander": "^14.0.0",
|
|
66
|
+
"ts-morph": "^28.0.0",
|
|
67
|
+
"ts-node": "^10.9.2",
|
|
68
|
+
"typescript": "^5.9.3",
|
|
69
|
+
"@types/swagger-schema-official": "^2.0.25",
|
|
70
|
+
"js-yaml": "^4.1.0"
|
|
71
|
+
},
|
|
72
|
+
"peerDependencies": {
|
|
73
|
+
"@angular/core": ">=15",
|
|
74
|
+
"@angular/common": ">=15"
|
|
75
|
+
},
|
|
76
|
+
"peerDependenciesMeta": {
|
|
77
|
+
"@angular/core": {
|
|
78
|
+
"optional": false
|
|
79
|
+
},
|
|
80
|
+
"@angular/common": {
|
|
81
|
+
"optional": false
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
"engines": {
|
|
85
|
+
"node": ">=20.0.0",
|
|
86
|
+
"npm": ">=8.0.0"
|
|
87
|
+
},
|
|
88
|
+
"publishConfig": {
|
|
89
|
+
"access": "public",
|
|
90
|
+
"registry": "https://registry.npmjs.org/"
|
|
82
91
|
}
|
|
83
|
-
},
|
|
84
|
-
"engines": {
|
|
85
|
-
"node": ">=20.0.0",
|
|
86
|
-
"npm": ">=8.0.0"
|
|
87
|
-
},
|
|
88
|
-
"publishConfig": {
|
|
89
|
-
"access": "public",
|
|
90
|
-
"registry": "https://registry.npmjs.org/"
|
|
91
|
-
}
|
|
92
92
|
}
|