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
Copy file name to clipboardExpand all lines: blog/2025-06-openapi-generator/README.md
+28-58Lines changed: 28 additions & 58 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,14 @@
2
2
title: "Generating Angular API clients with OpenAPI Generator"
3
3
author: Johannes Hoppe
4
4
mail: johannes.hoppe@haushoppe-its.de
5
+
bio: '<a href="https://angular-buch.com"><img src="https://angular-buch.com/assets/img/book-cover-v1m.png" alt="Angular-Buch Cover" style="float: right; margin-top: -60px; margin-right: 30px; max-width: 250px;"></a>This article complements the HTTP chapter of our new <b>Angular book</b> (in German language) by Ferdinand Malcher, Danny Koppenhagen and Johannes Hoppe, where we cover everything you need to know about HTTP communication with Angular. After four successful editions, we have rewritten the book from scratch – with modern syntax, compact and covering many new topics. The new book will be released in May 2026. More info at <a href="https://angular-buch.com" style="text-decoration: underline;"><b>angular-buch.com</b></a>'
6
+
bioHeading: About the Angular book
7
+
author2: Angular.Schule Team
8
+
mail2: team@angular.schule
9
+
bio2: '<a href="https://angular.schule"><img src="/img/logo-angular-schule-gradient-550.png" alt="Angular.Schule Logo" style="float: right; margin-left: 30px; margin-top: -10px; margin-right: 30px; max-width: 250px;"></a>Want to integrate OpenAPI into your Angular workflow? Join Ferdinand Malcher and Johannes Hoppe in our workshops, where you learn Angular the practical way – including API integration with OpenAPI Generator. More at <a href="https://angular.schule" style="text-decoration: underline;"><b>angular.schule</b></a>'
10
+
bio2Heading: About our Angular workshops
5
11
published: 2025-06-18
12
+
lastModified: 2026-02-15
6
13
keywords:
7
14
- OpenAPI
8
15
- OpenAPI Generator
@@ -75,16 +82,16 @@ That's exactly what we want for a clean and reliable workflow.
75
82
### Switching Code Generator Versions
76
83
77
84
To ensure consistent output across your team and avoid accidental diffs, it's a good idea to lock your project to a specific version of the OpenAPI Generator.
78
-
Suppose you want to lock your project to version `7.13.0`.
85
+
Suppose you want to lock your project to version `7.19.0`.
79
86
You can do this by running:
80
87
81
88
```bash
82
-
npx openapi-generator-cli version-manager set 7.13.0
89
+
npx openapi-generator-cli version-manager set 7.19.0
83
90
```
84
91
85
92
This will:
86
93
87
-
1. Download the `openapi-generator-cli-7.13.0.jar` file into your `node_modules` folder – so it shouldn't be under version control, since typically the local NPM files are never checked in.
94
+
1. Download the `openapi-generator-cli-7.19.0.jar` file into your `node_modules` folder – so it shouldn't be under version control, since typically the local NPM files are never checked in.
88
95
2. Record the version into the `openapitools.json` file.
89
96
90
97
To verify which version is currently active, run:
@@ -99,22 +106,19 @@ You can also use this mechanism to test new versions or roll back safely.
99
106
100
107
## Generating Your First Angular API Client
101
108
102
-
Before we take a look at the code, take a moment to explore [api6.angular-buch.com](https://api6.angular-buch.com/).
109
+
Before we take a look at the code, take a moment to explore [api1.angular-buch.com](https://api1.angular-buch.com/).
103
110
104
-
This public REST API is part of the **BookMonkey 6** demo application, the updated companion project for the upcoming **5th edition** of our German Angular book.
105
-
106
-
107
-
> 📘 Save the date!
108
-
> The new edition is scheduled for **early 2026**.
109
-
> Follow us on [angular.schule](https://www.angular.schule/) and our social media channels for updates!
111
+
This public REST API is part of the **BookManager 1** demo application, the companion project for our new **Angular book** (in German language).
112
+
After four successful editions, we have rewritten the book from scratch – with modern syntax, compact and covering many new topics.
113
+
The new book will be released in **May 2026**. More info at [angular-buch.com](https://angular-buch.com).
This graphical interface is fully generated from the OpenAPI specification, located at:
116
120
117
-
→ `https://api6.angular-buch.com/openapi.json`
121
+
→ `https://api1.angular-buch.com/openapi.json`
118
122
119
123
If this metadata is rich enough to render a complete admin UI, then it's clearly powerful enough to generate a fully functional Angular API client.
120
124
@@ -128,9 +132,9 @@ We start with the most minimal setup:
128
132
129
133
```bash
130
134
npx openapi-generator-cli generate \
131
-
-i https://api6.angular-buch.com/openapi.json \
135
+
-i https://api1.angular-buch.com/openapi.json \
132
136
-g typescript-angular \
133
-
-o ./src/app/shared/book-monkey-api
137
+
-o ./src/app/shared/book-manager-api
134
138
```
135
139
136
140
**Hint:** 💡 On Windows (Command Prompt), remove the backslashes and write the command in a single line.
@@ -150,11 +154,10 @@ These are the bare minimum arguments required.
150
154
With this, you'll get:
151
155
152
156
- Typed Angular services for each REST resource
153
-
- A full NgModule (`ApiModule`)
154
157
- Models for all schemas (for example `book`, `author`, etc...)
155
158
-`HttpClient`-based methods for every endpoint
156
159
157
-
> 🛠️ Pro Tip: Place the output directory somewhere inside your app's structure, but outside of actual components or routing. We suggest a path like `src/app/shared/book-monkey-api/`.
160
+
> 🛠️ Pro Tip: Place the output directory somewhere inside your app's structure, but outside of actual components or routing. We suggest a path like `src/app/shared/book-manager-api/`.
158
161
159
162
160
163
The CLI supports many more options.
@@ -176,34 +179,24 @@ This setup is fully compatible with Angular's standalone application structure:
@@ -328,7 +299,7 @@ This modern pattern keeps your components fully reactive and simplifies state ha
328
299
329
300
## Modern Data Loading with `rxResource()`
330
301
331
-
Angular 19 introduced a new reactive primitive: `rxResource()` (still marked as *experimental* as of Angular 20).
302
+
Angular 19 introduced a new reactive primitive: `rxResource()` (still marked as *experimental* as of Angular 21).
332
303
It's designed to simplify the way we work with asynchronous data streams, especially when fetching data from an API.
333
304
334
305
Instead of manual subscription handling or conversion to signals (via `toSignal()` for example), `rxResource()` wraps our observable-based data source into a signal-friendly API.
@@ -343,11 +314,10 @@ import { JsonPipe } from '@angular/common';
0 commit comments