Skip to content

Commit 368b9b7

Browse files
authored
[TypeScript - Angular] Add syntax highlighting to code blocks and correct heading levels in README.mustache (#19837)
* Improve typescript-angular README.mustache - Add syntax highlighting to code blocks - Correct heading levels * Add space between heading and convert bare url to angle brackets link * Update samples
1 parent a84946b commit 368b9b7

File tree

17 files changed

+544
-442
lines changed
  • modules/openapi-generator/src/main/resources/typescript-angular
  • samples/client
    • others/typescript-angular/builds
    • petstore
      • typescript-angular-v12-oneOf/builds/default
      • typescript-angular-v12-provided-in-any/builds/default
      • typescript-angular-v12-provided-in-root/builds
      • typescript-angular-v13-oneOf/builds/default
      • typescript-angular-v13-provided-in-any/builds/default
      • typescript-angular-v13-provided-in-root/builds
      • typescript-angular-v14-provided-in-root/builds/default
      • typescript-angular-v14-query-param-object-format
      • typescript-angular-v15-provided-in-root/builds/default
      • typescript-angular-v16-provided-in-root/builds/default
      • typescript-angular-v17-provided-in-root/builds/default
      • typescript-angular-v18-provided-in-root/builds/default

17 files changed

+544
-442
lines changed

modules/openapi-generator/src/main/resources/typescript-angular/README.mustache

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,35 @@
1-
## {{npmName}}@{{npmVersion}}
1+
# {{npmName}}@{{npmVersion}}
22

33
{{{appDescription}}}
44

55
{{#version}}The version of the OpenAPI document: {{{.}}}{{/version}}
66

7-
### Building
7+
## Building
88

99
To install the required dependencies and to build the typescript sources run:
10-
```
10+
11+
```console
1112
npm install
1213
npm run build
1314
```
1415

15-
### publishing
16+
## Publishing
1617

17-
First build the package then run ```npm publish dist``` (don't forget to specify the `dist` folder!)
18+
First build the package then run `npm publish dist` (don't forget to specify the `dist` folder!)
1819

19-
### consuming
20+
## Consuming
2021

2122
Navigate to the folder of your consuming project and run one of next commands.
2223

2324
_published:_
2425

25-
```
26+
```console
2627
npm install {{npmName}}@{{npmVersion}} --save
2728
```
2829

2930
_without publishing (not recommended):_
3031

31-
```
32+
```console
3233
npm install PATH_TO_GENERATED_PACKAGE/dist.tgz --save
3334
```
3435

@@ -37,26 +38,26 @@ _It's important to take the tgz file, otherwise you'll get trouble with links on
3738
_using `npm link`:_
3839

3940
In PATH_TO_GENERATED_PACKAGE/dist:
40-
```
41+
42+
```console
4143
npm link
4244
```
4345

4446
In your project:
45-
```
47+
48+
```console
4649
npm link {{npmName}}
4750
```
4851

4952
__Note for Windows users:__ The Angular CLI has troubles to use linked npm packages.
50-
Please refer to this issue https://github.com/angular/angular-cli/issues/8284 for a solution / workaround.
53+
Please refer to this issue <https://github.com/angular/angular-cli/issues/8284> for a solution / workaround.
5154
Published packages are not effected by this issue.
5255

53-
54-
#### General usage
56+
### General usage
5557

5658
In your Angular project:
5759

58-
59-
```
60+
```typescript
6061
// without configuring providers
6162
import { {{apiModuleClassName}} } from '{{npmName}}';
6263
import { HttpClientModule } from '@angular/common/http';
@@ -75,7 +76,7 @@ import { HttpClientModule } from '@angular/common/http';
7576
export class AppModule {}
7677
```
7778

78-
```
79+
```typescript
7980
// configuring providers
8081
import { {{apiModuleClassName}}, {{configurationClassName}}, {{configurationParametersInterfaceName}} } from '{{npmName}}';
8182

@@ -95,7 +96,7 @@ export function apiConfigFactory (): {{configurationClassName}} {
9596
export class AppModule {}
9697
```
9798

98-
```
99+
```typescript
99100
// configuring providers with an authentication service that manages your access tokens
100101
import { {{apiModuleClassName}}, {{configurationClassName}} } from '{{npmName}}';
101102

@@ -120,7 +121,7 @@ import { {{apiModuleClassName}}, {{configurationClassName}} } from '{{npmName}}'
120121
export class AppModule {}
121122
```
122123

123-
```
124+
```typescript
124125
import { DefaultApi } from '{{npmName}}';
125126

126127
export class AppComponent {
@@ -131,11 +132,13 @@ export class AppComponent {
131132
Note: The {{apiModuleClassName}} is restricted to being instantiated once app wide.
132133
This is to ensure that all services are treated as singletons.
133134

134-
#### Using multiple OpenAPI files / APIs / {{apiModuleClassName}}s
135+
### Using multiple OpenAPI files / APIs / {{apiModuleClassName}}s
136+
135137
In order to use multiple `{{apiModuleClassName}}s` generated from different OpenAPI files,
136138
you can create an alias name when importing the modules
137139
in order to avoid naming conflicts:
138-
```
140+
141+
```typescript
139142
import { {{apiModuleClassName}} } from 'my-api-path';
140143
import { {{apiModuleClassName}} as OtherApiModule } from 'my-other-api-path';
141144
import { HttpClientModule } from '@angular/common/http';
@@ -154,20 +157,21 @@ export class AppModule {
154157
}
155158
```
156159

157-
158160
### Set service base path
161+
159162
If different than the generated base path, during app bootstrap, you can provide the base path to your service.
160163

161-
```
164+
```typescript
162165
import { BASE_PATH } from '{{npmName}}';
163166

164167
bootstrap(AppComponent, [
165168
{ provide: BASE_PATH, useValue: 'https://your-web-service.com' },
166169
]);
167170
```
171+
168172
or
169173

170-
```
174+
```typescript
171175
import { BASE_PATH } from '{{npmName}}';
172176

173177
@NgModule({
@@ -179,19 +183,20 @@ import { BASE_PATH } from '{{npmName}}';
179183
export class AppModule {}
180184
```
181185

186+
### Using @angular/cli
182187

183-
#### Using @angular/cli
184188
First extend your `src/environments/*.ts` files by adding the corresponding base path:
185189

186-
```
190+
```typescript
187191
export const environment = {
188192
production: false,
189193
API_BASE_PATH: 'http://127.0.0.1:8080'
190194
};
191195
```
192196

193197
In the src/app/app.module.ts:
194-
```
198+
199+
```typescript
195200
import { BASE_PATH } from '{{npmName}}';
196201
import { environment } from '../environments/environment';
197202

@@ -219,6 +224,7 @@ pass an arrow-function or method-reference to the `encodeParam` property of the
219224
(see [General Usage](#general-usage) above).
220225

221226
Example value for use in your Configuration-Provider:
227+
222228
```typescript
223229
new Configuration({
224230
encodeParam: (param: Param) => myFancyParamEncoder(param),

samples/client/others/typescript-angular/builds/composed-schemas-tagged-unions/README.md

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,35 @@
1-
## @
1+
# @
22

33
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
44

55
The version of the OpenAPI document: 1.0.0
66

7-
### Building
7+
## Building
88

99
To install the required dependencies and to build the typescript sources run:
10-
```
10+
11+
```console
1112
npm install
1213
npm run build
1314
```
1415

15-
### publishing
16+
## Publishing
1617

17-
First build the package then run ```npm publish dist``` (don't forget to specify the `dist` folder!)
18+
First build the package then run `npm publish dist` (don't forget to specify the `dist` folder!)
1819

19-
### consuming
20+
## Consuming
2021

2122
Navigate to the folder of your consuming project and run one of next commands.
2223

2324
_published:_
2425

25-
```
26+
```console
2627
npm install @ --save
2728
```
2829

2930
_without publishing (not recommended):_
3031

31-
```
32+
```console
3233
npm install PATH_TO_GENERATED_PACKAGE/dist.tgz --save
3334
```
3435

@@ -37,26 +38,26 @@ _It's important to take the tgz file, otherwise you'll get trouble with links on
3738
_using `npm link`:_
3839

3940
In PATH_TO_GENERATED_PACKAGE/dist:
40-
```
41+
42+
```console
4143
npm link
4244
```
4345

4446
In your project:
45-
```
47+
48+
```console
4649
npm link
4750
```
4851

4952
__Note for Windows users:__ The Angular CLI has troubles to use linked npm packages.
50-
Please refer to this issue https://github.com/angular/angular-cli/issues/8284 for a solution / workaround.
53+
Please refer to this issue <https://github.com/angular/angular-cli/issues/8284> for a solution / workaround.
5154
Published packages are not effected by this issue.
5255

53-
54-
#### General usage
56+
### General usage
5557

5658
In your Angular project:
5759

58-
59-
```
60+
```typescript
6061
// without configuring providers
6162
import { ApiModule } from '';
6263
import { HttpClientModule } from '@angular/common/http';
@@ -75,7 +76,7 @@ import { HttpClientModule } from '@angular/common/http';
7576
export class AppModule {}
7677
```
7778

78-
```
79+
```typescript
7980
// configuring providers
8081
import { ApiModule, Configuration, ConfigurationParameters } from '';
8182

@@ -95,7 +96,7 @@ export function apiConfigFactory (): Configuration {
9596
export class AppModule {}
9697
```
9798

98-
```
99+
```typescript
99100
// configuring providers with an authentication service that manages your access tokens
100101
import { ApiModule, Configuration } from '';
101102

@@ -120,7 +121,7 @@ import { ApiModule, Configuration } from '';
120121
export class AppModule {}
121122
```
122123

123-
```
124+
```typescript
124125
import { DefaultApi } from '';
125126

126127
export class AppComponent {
@@ -131,11 +132,13 @@ export class AppComponent {
131132
Note: The ApiModule is restricted to being instantiated once app wide.
132133
This is to ensure that all services are treated as singletons.
133134

134-
#### Using multiple OpenAPI files / APIs / ApiModules
135+
### Using multiple OpenAPI files / APIs / ApiModules
136+
135137
In order to use multiple `ApiModules` generated from different OpenAPI files,
136138
you can create an alias name when importing the modules
137139
in order to avoid naming conflicts:
138-
```
140+
141+
```typescript
139142
import { ApiModule } from 'my-api-path';
140143
import { ApiModule as OtherApiModule } from 'my-other-api-path';
141144
import { HttpClientModule } from '@angular/common/http';
@@ -154,20 +157,21 @@ export class AppModule {
154157
}
155158
```
156159

157-
158160
### Set service base path
161+
159162
If different than the generated base path, during app bootstrap, you can provide the base path to your service.
160163

161-
```
164+
```typescript
162165
import { BASE_PATH } from '';
163166

164167
bootstrap(AppComponent, [
165168
{ provide: BASE_PATH, useValue: 'https://your-web-service.com' },
166169
]);
167170
```
171+
168172
or
169173

170-
```
174+
```typescript
171175
import { BASE_PATH } from '';
172176

173177
@NgModule({
@@ -179,19 +183,20 @@ import { BASE_PATH } from '';
179183
export class AppModule {}
180184
```
181185

186+
### Using @angular/cli
182187

183-
#### Using @angular/cli
184188
First extend your `src/environments/*.ts` files by adding the corresponding base path:
185189

186-
```
190+
```typescript
187191
export const environment = {
188192
production: false,
189193
API_BASE_PATH: 'http://127.0.0.1:8080'
190194
};
191195
```
192196

193197
In the src/app/app.module.ts:
194-
```
198+
199+
```typescript
195200
import { BASE_PATH } from '';
196201
import { environment } from '../environments/environment';
197202

@@ -219,6 +224,7 @@ pass an arrow-function or method-reference to the `encodeParam` property of the
219224
(see [General Usage](#general-usage) above).
220225

221226
Example value for use in your Configuration-Provider:
227+
222228
```typescript
223229
new Configuration({
224230
encodeParam: (param: Param) => myFancyParamEncoder(param),

0 commit comments

Comments
 (0)