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/, the main index.ts, and any plugin directories are generated โ€” plugins run regardless of this option. Pair that mode only with plugins whose output stands alone (Zod imports nothing but zod); the HTTP Resource plugin imports from tokens/ and utils/, which this mode does not generate.

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. Tags and operationIds are free-form text in a valid spec, so characters that cannot appear in a TypeScript identifier are treated as word separators: the tag Groups (yes) yields GroupsYesService in groupsYes.service.ts, and the operationId groups_{group_id}_delete yields the method groupsGroupIdDelete. 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 โ€” including any plugin directories (e.g. resources/, validators/) โ€” so consumers can import from the output root.

Schema References โ€‹

  • $ref to a whole schema (#/components/schemas/Pet) โ€” an imported model in models/.
  • $ref to a property inside a schema (#/components/schemas/PolicyEntry/properties/namespaces) โ€” inlined at each use, no extra model.

An unresolvable or cyclic property $ref is left as-is and warned about:

โš ๏ธ Could not resolve nested $ref "#/components/schemas/Missing/properties/nope". The generated type will not match the spec (generated files ship @ts-nocheck, so this surfaces as a silently wrong type rather than a compile error).

Your build stays green โ€” that is the point of the warning. Generated files carry @ts-nocheck, so the dangling type name degrades to any instead of failing compilation, and the warning is the only signal that the API surface is wrong.

Fix the spec: promote the target to a named schema and reference that.

Only pointers under #/components/schemas/โ€ฆ and #/definitions/โ€ฆ are inlined. A deep pointer into any other root โ€” #/components/responses/Error/content/application~1json/schema, #/paths/โ€ฆ/schema, Swagger 2.0 #/parameters/X/schema, the shape redocly bundle and swagger-cli bundle emit for a repeated subschema โ€” is passed through and warned about, naming the type the output will contain so you can search for it:

โš ๏ธ Nested $ref "#/components/responses/Error/content/application~1json/schema" points into a part of the document this generator does not inline (only #/components/schemas/โ€ฆ and #/definitions/โ€ฆ are) โ€” it will be emitted as the type "Schema", which nothing defines. Promote the target to a named schema and reference that. โ€ฆ

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