-
e65dc4a: Fix multipart form field types: non-file fields no longer collapse to
string. Amultipart/form-databody property declared via$ref(e.g. an object schema) previously rendered asstringin the body type and was appended raw toFormData(serializing to[object Object]). Non-binary fields now keep their schema type through the mapper ($ref→ the referenced named type, arrays →T[], numbers/booleans → their primitive), and the generated client appends non-string fields asJSON.stringify(...)while string-valued fields (including$refs to string schemas) keep direct appends. Binary handling (FileInput/FileInput[]) is unchanged.A multipart body whose whole schema is a single
$refto a component now reuses that component type (PostXBody = PostRequest) instead of emitting a flattened copy beside it; the component's own definition is rendered through the form-field mapping. This applies only when the component has no other$refconsumers (another operation, content type, or schema would still need the raw mapping); types whose last reference is dropped by the form-mapped rendering are pruned instead of lingering unused.Hardening: nullable string fields append behind a
nullguard (string | nulldoes not satisfy FormData'sstring | Blob); arrays whoseitemsis a$refto a binary schema upload asFileInput[]; orphan pruning no longer drops types used as client path-parameter types and removes whole orphaned dependency chains.
- e46b2b0: Concrete discriminator bases now join their own
{Base}Variantunions. Previously, refs to a base with nooneOf/anyOf(or listed in its ownmapping) could name an undeclared union type, a self-mapped base collapsed its children toneverthrough conflicting discriminant literals, and mapping-children-only families omitted the base from its own union. Variants of a concrete base now strip the discriminant viaOmit<Base, '$disc'>, implicit direct-allOfchildren count as variants, and families with no members fall back to bare base names instead of emitting an unused union. Generated output shape changes for specs with concrete discriminator bases: existing variant unions gain the base as a member. Fixes #93. - e46b2b0: Warn on binary file data declared under
application/x-www-form-urlencodedrequest bodies, and fix multipart bodies that declare their form fields viaallOf. A urlencoded body containingformat: binaryfields cannot transport them, but previously typed them silently as plain strings; genoc now prints a warning naming the offending fields (found throughallOf,$ref, arrays, and nested objects, cycle-safe). Separately, amultipart/form-databody whose fields live inallOfmembers used to collapse toRecord<string, never>and drop every FormData append — the multipart property walk now mergesallOfmembers (recursively, resolving$refs, unioningrequired), so those fields generate asFileInput/FileInput[]/string fields again.
- 7a29f34: Concrete discriminator bases now join their own
{Base}Variantunions. Previously, refs to a base with nooneOf/anyOf(or listed in its ownmapping) could name an undeclared union type, a self-mapped base collapsed its children toneverthrough conflicting discriminant literals, and mapping-children-only families omitted the base from its own union. Variants of a concrete base now strip the discriminant viaOmit<Base, '$disc'>, implicit direct-allOfchildren count as variants, and families with no members fall back to bare base names instead of emitting an unused union. Generated output shape changes for specs with concrete discriminator bases: existing variant unions gain the base as a member. Fixes #93.
- 2eeec7b: Accept empty-string
info.titleandinfo.version. The OpenAPI specification requires these fields to be present strings but imposes no requirement on the value, sotitle: ""/version: ""are no longer rejected. Fixes #85.
- 66fe206: Generated clients now pass the operation's effective security requirements to the requester:
Requesteroptions gainsecurity?: readonly SecurityRequirement[](OR-of-ANDs of{ schemeName, scopes, scheme }with the fully-resolved scheme object, oauth2 flows included), and the runtime exportsSecurityScheme,SecurityCall,SecurityRequirement,OAuthFlow, andOAuthFlows. Contracts add aSecuritySchemeNameunion of the declared scheme keys. Ops declaredsecurity: []or with no requirements send nosecurityfield.securitySchemes/securityare now validated per the OpenAPI spec (required fields per scheme type —$refschemes included, unknown names/types, version-scoped scope rules,mutualTLSin 3.1 only,securityon a Path Item rejected). Note: if you pin an oldergenoc/runtimevia--runtime-import-path, clients generated from specs with security requirements will fail type-checking against it (excess property). (#17)
- b256dae: Fix
DefaultApiErrorto extendApiError<number, TData>: generated catch blocks now re-throw it unchanged instead of wrapping it inRequesterFailError.isDefinedErrorexplicitly returnsfalsefor it (adefault-response error is not part of the per-status error union) - catch it withinstanceof DefaultApiError. Documented in the error-handling guide. Fixes #79. - 9abd899: Validation errors that report a spec violation now link to the section of the OpenAPI specification that states the violated rule (e.g.
https://spec.openapis.org/oas/v3.1.1.html#info-version), each dialect at its latest patch release. When--spec-versionoverrides detection, the override decides which page is linked; for documents whose dialect is unknown,--spec-versionis used and 3.1.1 is the default. Unsupported features (Swagger 2.0, OpenAPI 3.2, external$refs) remain link-free: those documents are valid and the errors cite a genoc limitation, not a specification rule. Version/dialect rules now live solely in the version module (the spec reader no longer duplicates them). Fixes #83.
- 39f4367: Generated clients now type path parameters from their schemas instead of always
string—type: integer/numberproducesnumber | string,type: booleanproducesboolean | string, enums become unions of their literals widened bystring, and$refs resolve to the named contract type widened bystring. Thestringarm is the escape hatch: pass a pre-formatted string when the default serialization is not what your API expects. Typed values are serialized inline withString()before URL-encoding.createClient(requester)takes no options. (#71)
- 4e8d64f: Fixed generated client signatures placing an optional (
?:) parameter before a required one, which produced invalid TypeScript (error TS1016: A required parameter cannot follow an optional parameter) — for example an operation with an optional request body and a required header generatedbody?: PostApiV1EntityBody, headers: PostApiV1EntityHeaders. Optional parameters that precede a required one are now rendered asname: T | undefinedinstead ofname?: T, uniformly for every parameter slot (query, body, headers), replacing the previous query-only special case. (#63)
- d871e0e: Fixed discriminator cross-variant inheritance collapsing generated variants to
never(the .NET System.Text.Json polymorphism style, where each variant inherits the discriminated base). Discriminator literals are now injected exactly once — at each mapping target's own named definition — and same-family variant references render asOmit<Sibling, 'Prop'>instead of re-inlining the parent literal. Every discriminated family also emits a collision-safe{Base}Variantunion (mapping values ∪ oneOf refs), and a$refto a discriminator base resolves to that union at all usage sites. Also fixes four latent analyzer bugs: repeated sibling$refs dropping all properties, injected literals binding only to the last member of a union, implicit variant literals using the sanitized type name instead of the raw ref segment, and mapping keys containing'/\producing syntactically invalid TypeScript. - d871e0e: The
'nullable' is deprecated in OpenAPI 3.1generation warning is now gated by the effective spec dialect: it only fires when generating from a 3.1 spec, wheretype: ["string", "null"]is the modern replacement. OpenAPI 3.0 specs — wherenullableis the correct and only mechanism — no longer produce the warning. The effective dialect is sourced from version detection (honoring--spec-versionoverrides) and threaded through the pipeline into the analyzer; as part of this,SchemaMappernow takes an options object instead of positional constructor parameters. - c0ee6dc:
undiciis no longer bundled as a regular dependency: it moved to an optional peer dependency (^6.13.0 || ^7 || ^8). Fetching specs through a proxy now requires installing it yourself (npm install undici); genoc keeps working without undici when no proxy is configured. The Node.js engine floor rises from 18 to 20.18.1 — the minimum required by undici v7, which the peer range now admits. A missingundiciduring a proxied fetch now produces an actionable install hint instead of a wrapped fetch failure.
-
5531827: Config file support:
genocnow reads its settings from.genocrc.ymlor.genocrc.json, discovered from the current directory up to the git repository boundary, or loaded explicitly with the new--configflag. A flat config generates a single client; aclientsmap generates multiple clients sequentially in one run — a failing target does not stop the loop, failures are aggregated (× client "<name>": …, exit 1 if any target failed) — and the new--project <name>flag runs a single named client. Relativeinput/outputDirpaths resolve against the config file's directory. Thespecpositional and--output-dirare now optional when a config file supplies them. (#32) -
7e51e0c: Always generate an
index.tsbarrel alongsidecontracts.tsandclient.tsin the output directory —export * from './contracts.js';plusexport * from './client.js';under the standard genoc header — so the client factory can be imported straight from the output directory. Barrel generation is always on: no flag, no config option. Regenerating overwrites all three files, including any hand-authoredindex.ts. A spec schema namedcreateClientwould collide with the barrel's re-exported factory, so such schemas now rename tocreateClientModel. -
fb20f92: Add
-oas a short alias for the--output-dirCLI flag:genoc ./spec.yaml -o ./src/apinow works alongside the long form, including when overriding a config file'soutputDir. -
e3c4083: Remove the programmatic API:
generateClient,loadSpec, and the root package export are gone. genoc is now CLI-only — generate clients with thegenocbinary (optionally configured via.genocrc.yml/.genocrc.json). Generated code is unaffected: it imports fromgenoc/runtime, which remains published.BREAKING CHANGE: the
genocpackage root no longer exports anything.import { generateClient, loadSpec } from 'genoc'(and root type imports) now fail at build time — use the CLI instead, and import runtime values (ApiError,isDefinedError,Requester, …) fromgenoc/runtime.
- 37202b7: Resolve
$refs in multipart request bodies before classifying file inputs: a$ref'dformat: binaryproperty now generates aFileInputfield appended asformData.append(name, file.data, file.filename)(and aFile[]loop for arrays of binaries) instead of a plain append of the unresolved object. Whole-body$refs to multipart schemas no longer silently drop all fields. Generation was also rearchitected around a singleanalyze()translation pass consumed by pure renderers — output for all other specs is byte-identical. - b234625: v3.1 spec validation now reaches parity with v3.0: schemas under
components.schemasare validated recursively (includingproperties,items,additionalProperties,allOf/oneOf/anyOf, andprefixItems), and 3.0-only constructs are rejected with dot-joined schema paths —nullable, boolean-formexclusiveMinimum/exclusiveMaximum, and array-formitems(tuples must useprefixItems). Schema-levelexamplestays accepted: deprecated but still legal per the frozen OpenAPI 3.1.0 spec. Legal 3.1 features (type arrays,"type": "null",$schema,$refsiblings,const,examples) are explicitly not flagged. - 1f5c750: Classify responses and request bodies as binary when the resolved schema has
format: binary— vendor content types likeapplication/vnd.openxmlformats-officedocument.spreadsheetml.sheetnow generateStreamResponsereturns withexpectStream: trueandBlobbodies instead of a brokenstringcontract.
- 7b4dd43: Add HTTP(S) proxy support for fetching OpenAPI specs from URLs: new
--proxyCLI flag andproxyprogrammatic option;HTTP_PROXY/HTTPS_PROXY/NO_PROXYenvironment variables are now respected when no flag is given (previously ignored — escape hatch:NO_PROXY).
- 5ab175a: Remove the dead
src/generator/error-types.tsmodule.generateErrorTypeswas never called by the generation pipeline and had diverged from the live inline scheme (methodName-based prefixes, un-renamed tsTypes, inline ApiError classes already emitted by contracts-generator). - 48289eb: Handle special characters in schema names and routes: any run of non-identifier symbols (brackets, backticks, hyphens, spaces, dots, tildes, ...) is folded into PascalCase, leading digits and exact reserved words get an
_prefix, and schemas whose sanitized names collide are renamed with aModelsuffix. Route-derived type prefixes and method names go through the same sanitization.
-
f558199: Generate JSDoc documentation from OpenAPI field metadata. Field-level
description,deprecated,default,example/examples, andtitlenow flow into the generated output as JSDoc — on schema properties, query/header/body parameter types, response types, named type declarations, and client method JSDoc (lowest-numbered 2xx response description). Descriptions containing*/or newlines are now escaped/flattened instead of corrupting the generated file.Output format change (regeneration required): generated type tokens are provably unchanged — a stripped-comment equivalence harness verifies every type compiles identically to before — but object types now render as multi-line blocks with depth-aware indentation instead of single-line inline literals (
{ id: string; name: string; }→ one property per line). Generated files therefore differ textually: consumers diffing or snapshotting generated output must regenerate it. Note that JSDoc comments are preserved intsc --declarationoutput, so published.d.tstext changes as well. Tag order is fixed: description →@deprecated→@default→@example(s) →@title. Composition rules:allOfparent metadata is emitted, inlineoneOf/anyOfmember anditems/additionalPropertiesmetadata is dropped; parameter-level metadata takes precedence over schema-level metadata on parameter types. -
33b378e: Remove the
streamResponse()anderrorResponse()factory functions fromgenoc/runtime. They were zero-logic wrappers around theStreamResponseandErrorResponseconstructors, so the classes are all that remain on the runtime surface.Breaking change: code importing
streamResponseorerrorResponsefromgenoc,genoc/runtime, or a generatedcontracts.ts(which no longer re-exports them) must call the constructors directly instead:// before import { streamResponse, errorResponse } from 'genoc/runtime'; const stream = streamResponse(data, filename, headers); const error = errorResponse(status, data, headers, message); // after import { StreamResponse, ErrorResponse } from 'genoc/runtime'; const stream = new StreamResponse(data, filename, headers); const error = new ErrorResponse(status, data, headers, message);
Both constructors default
headersto{}, so calls that omitted the argument keep working unchanged. All other runtime exports (StreamResponse,ErrorResponse,ApiError,UnspecifiedApiError,DefaultApiError,RequesterFailError,decorateWithErrors,isDefinedError,Requester) are unaffected. -
315e181: Add
genoc/runtimesubpath export containing the shared runtime contract: theRequestertype,StreamResponse,ErrorResponse, error classes (ApiError,UnspecifiedApiError,DefaultApiError,RequesterFailError), response helpers (streamResponse,errorResponse), andisDefinedError/decorateWithErrors.Generated code now imports these from
genoc/runtimeinstead of declaring inline copies (the generatedcontracts.tsre-exports them, so existing consumer imports keep working). This gives all generated clients a single class identity —instanceofchecks work across clients and a sharedRequestercan be written and compiled against the package before any generation.Notes for consumers:
genocis now a runtime dependency of generated output (previously the generated code was fully self-contained).- New
--runtime-import-pathCLI flag /runtimeImportPathprogrammatic config option overrides the import specifier (defaultgenoc/runtime), e.g.[email protected]/runtimefor version pinning.
- 418e5cd: Handle dotted contracts
- 6dfe0dc: Remove isError utility
- 3ba7344: Handle name collision
- 192cf5e: Update headers type
- 192cf5e: Update parameters order generation: params -> query -> body -> headers
- 089590e: Replace errorsSymbol with a hidden errors string property to fix typescript errors ts(4023) and ts(2527)
- 979a37f: Initial commit