Skip to content

Generated Output โ€‹

What ng-openapi actually writes into your output directory, file by file. This is the canonical reference for the generated structure โ€” other pages link here instead of repeating it.

The Full Tree โ€‹

With the default configuration (generateServices: true, dateType: "Date"):

<output>/
โ”œโ”€โ”€ models/
โ”‚   โ”œโ”€โ”€ index.ts             # TypeScript interfaces, enums / unions
โ”‚   โ”œโ”€โ”€ *.ts                 # One file per schema (only with modelFileStructure: 'per-type')
โ”‚   โ””โ”€โ”€ request-params.ts    # Request-object interfaces (only with useSingleRequestParameter)
โ”œโ”€โ”€ services/
โ”‚   โ”œโ”€โ”€ index.ts             # Service exports
โ”‚   โ””โ”€โ”€ *.service.ts         # One Angular service per controller/tag
โ”œโ”€โ”€ tokens/
โ”‚   โ””โ”€โ”€ index.ts             # Injection tokens for this client
โ”œโ”€โ”€ utils/
โ”‚   โ”œโ”€โ”€ base-interceptor.ts  # Routes client-scoped interceptors
โ”‚   โ”œโ”€โ”€ date-transformer.ts  # Date interceptor (only with dateType: "Date")
โ”‚   โ”œโ”€โ”€ file-download.ts     # Download helpers
โ”‚   โ””โ”€โ”€ http-params-builder.ts # Query-param serialization
โ”œโ”€โ”€ providers.ts             # provide<ClientName>Client() setup function
โ””โ”€โ”€ index.ts                 # Main barrel export

Plugins add their own directories next to these:

With generateServices: false only models/ and the main index.ts are generated.

File by File โ€‹

models/index.ts โ€‹

One interface per schema in the spec, plus enums in the style you chose via enumStyle. Date fields are typed Date or string depending on dateType. Type names can be decorated with a prefix/suffix via naming.models.

With modelFileStructure: 'per-type', each schema instead gets its own models/<kebab-name>.ts file (plus models/request-options.ts for the RequestOptions interface), and models/index.ts becomes a pure barrel re-exporting them โ€” imports from ../models and the main index.ts are unaffected.

models/request-params.ts โ€‹

Only generated with useSingleRequestParameter: one exported <MethodName>Params interface per operation, re-exported through the models barrel.

services/*.service.ts โ€‹

One injectable service per controller (OpenAPI tag), using inject(HttpClient) and this client's base-path token. Class names default to <Tag>Service and can be decorated via naming.services (file names are unaffected). Classes are decorated with @Injectable({ providedIn: "root" }), or Angular 22+'s @Service() when serviceDecorator is set to 'service'. Method names come from operationId, optionally transformed by customizeMethodName. When validation.response is enabled, each method accepts a parse hook in its trailing options parameter.

tokens/index.ts โ€‹

Injection tokens namespaced per client so multiple clients can coexist (see Multiple Clients):

  • BASE_PATH_<CLIENTNAME> โ€” the API base URL (falls back to /api)
  • HTTP_INTERCEPTORS_<CLIENTNAME> โ€” this client's interceptor instances
  • CLIENT_CONTEXT_TOKEN_<CLIENTNAME> โ€” HttpContext token marking which client a request belongs to

For the default client, deprecated BASE_PATH / CLIENT_CONTEXT_TOKEN aliases are kept for backwards compatibility.

utils/base-interceptor.ts โ€‹

A global interceptor that checks each request's HttpContext and applies this client's interceptor chain only to requests made by this client's services โ€” that's what keeps interceptors from leaking across clients.

utils/date-transformer.ts โ€‹

Only generated with dateType: "Date". Contains ISO_DATE_REGEX, transformDates, and the DateInterceptor that converts ISO date strings in responses to Date objects. See the Date Transformer reference.

utils/file-download.ts โ€‹

downloadFile, downloadFileOperator, and extractFilenameFromContentDisposition for handling blob downloads. See the File Download Helper reference.

utils/http-params-builder.ts โ€‹

Serializes query parameters into HttpParams, handling arrays, nested objects, and Date values. Used internally by the generated services.

providers.ts โ€‹

The provide<ClientName>Client() function (e.g. provideDefaultClient) plus its config interface. Wires up the base-path token, the base interceptor, client-scoped interceptors, and (with dateType: "Date") the date interceptor. See the Providers reference.

index.ts โ€‹

Barrel export of everything above, so consumers can import from the output root.

Regeneration Notes โ€‹

  • Every file starts with a "Generated by ng-openapi โ€” do not edit" header; regeneration overwrites them, so put customizations in your own code (interceptors, wrappers), never in the output directory.
  • Generated files carry @ts-nocheck and eslint-disable pragmas so they don't fight your project's lint/strict settings.
  • Add the output directory to your API-generation script rather than committing manual tweaks โ€” see CLI Usage for workflow recipes.

Released under the MIT License.
This site is powered by Netlify
About ยท Impressum