Assumptions & limitations
openapi-ng targets a focused subset of OpenAPI 3.x. Specs outside
this subset are rejected with clear diagnostics — no silent
misgeneration. Most rejections carry a subcode that pins the precise
shape your spec violated; see the
Diagnostics reference for routing.
Spec requirements
Section titled “Spec requirements”operationIdis required on every operation. The generator uses it to name service methods and request interfaces.- Every operation needs at least one
tag. The first tag determines which service class the operation belongs to (tagpet→PetRest). Additional tags are ignored for grouping. - Only
#/components/schemas/references are supported. External files, URL refs, and refs to other sections (e.g.#/components/responses/) are rejected.
Response handling
Section titled “Response handling”- Only the lowest 2xx response is used. If your operation defines
both
200and201, the200response is picked. Error responses (4xx, 5xx) are completely ignored — no error type mappings are generated. - Default content type is
application/json; other types route to the matchingrequestFactory.{blob,text,arrayBuffer}variant (see the Angular generator).
Request bodies
Section titled “Request bodies”application/json,multipart/form-data, andapplication/x-www-form-urlencodedare supported. Other content types — XML, custom media types, and bodies declaring multiple media types on a single request — are rejected.
Parameters
Section titled “Parameters”- Path and query parameters are fully supported and rendered at the top of the request interface.
- Header parameters are accepted and emitted as a sibling
headersobject on the request interface (alongside path/query and the body surface), so callers pass them in the same call. - Cookie parameters are accepted but omitted from the generated
service contract with an
E_UNSUPPORTED_SEMANTIC/unsupported-parameter-locationwarning — cookies are managed by the browser, so surfacing them on the client API would be misleading.
Request body shape
Section titled “Request body shape”The generated *Params interface treats the body using a
smart-flatten rule keyed on how the spec author wrote the schema:
- A body declared as
$ref: '#/components/schemas/Name'(or any non-object JSON shape — scalar, array, union) surfaces as a single nestedbody: Namefield, preserving the named type. - A body declared inline as
type: objecthas its properties hoisted to top-level fields next to path/query. - Multipart and url-encoded bodies always hoist their fields to
top-level (binary fields surface as
Blob | File).
The escape hatch is in the spec: name the schema to nest under body,
or inline a schema’s contents to hoist its properties. Hoisted body
properties that duplicate a path or query parameter name are rejected
at codegen with E_POLICY_VIOLATION / field-collision.
Schemas
Section titled “Schemas”- String enums only. Integer or mixed enums are rejected.
notkeyword is not supported.additionalPropertiesworks only on pure object schemas — emitted asRecord<string, T>. Cannot be combined with namedproperties,$ref, or composition keywords (allOf/oneOf/anyOf). BooleanadditionalProperties: trueis also rejected; it must be a schema.- One composition keyword per schema. You can use
allOf,oneOf, oranyOf, but not two of them on the same schema. oneOfwithdiscriminator: { propertyName }emitsA | Bon the TypeScript surface, with each variant’s discriminator property narrowed to its wire value. Whendiscriminator.mappingis set, the mapping key becomes the literal value (e.g.mapping: { feline: '#/.../Cat' }produceskind: 'feline'on theCatvariant). When no mapping entry matches, the lowercased schema name is used as a fallback.- Recursive schemas are supported.
- Nullable types via OpenAPI 3.0’s
nullable: trueare supported, emitted asT | null.
Out of scope
Section titled “Out of scope”- Remote URLs or external file references (the
--input <url>fetcher is the one exception). - OpenAPI 2.x (Swagger) and 3.1-specific features.
- Error response type generation.
- Custom service grouping strategies (tag-first only).