options
Type: object | Required
Object containing various options to customize the code generation process.
Usage
typescript
// openapi.config.ts
import { GeneratorConfig } from 'ng-openapi';
const config: GeneratorConfig = {
options: {
dateType: 'Date',
enumStyle: 'enum',
generateServices: true,
generateEnumBasedOnDescription: false,
customHeaders: {
'Accept': 'application/json',
... // other headers
},
responseTypeMapping: {
'application/pdf': 'blob',
... // other mappings
},
... // other configurations
}
};
export default config;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Options at a Glance
| Option | Type | Required | Default | Description |
|---|---|---|---|---|
dateType | 'string' | 'Date' | ✅ | — | How date/date-time fields are typed (and whether the date interceptor is generated) |
enumStyle | 'enum' | 'union' | ✅ | — | Emit TypeScript enums or literal-union types |
generateServices | boolean | — | true | Set false to generate models only |
validation | { response?: boolean } | — | undefined | Adds a parse hook to service methods for runtime response validation |
generateEnumBasedOnDescription | boolean | — | false | Read enum member names from JSON-encoded descriptions |
customHeaders | Record<string, string> | — | undefined | Default headers added to every request |
emitAcceptHeader | boolean | — | true | Send an Accept header derived from each operation's response content types |
responseTypeMapping | Record<string, ResponseType> | — | undefined | Pin the Angular responseType per content type |
customizeMethodName | (operationId) => string | — | undefined | Derive method names from operationIds |
useSingleRequestParameter | boolean | — | false | One request object per method instead of positional parameters |
serviceDecorator | 'injectable' | 'service' | — | 'injectable' | Emit Angular 22+'s @Service() instead of @Injectable({ providedIn: 'root' }) |
naming | NamingOptions | — | undefined | Prefix/suffix decoration of generated service, resource and model identifiers |
modelFileStructure | 'single' | 'per-type' | — | 'single' | Keep all models in one models/index.ts or write one file per schema |