openapi-typescript-helpers is a utility package providing TypeScript helper types designed to complement types generated by `openapi-typescript`. Its primary purpose is to offer generic type transformations, which are internally leveraged by other packages in the `openapi-ts` ecosystem, such as `openapi-fetch`. The current stable version is `0.1.0`. Given its recent initial release and close ties to `openapi-typescript`, its release cadence is likely tied to major `openapi-typescript` releases and feature additions, though it may not have independent major version bumps as frequently. Key differentiators include its focus on type-level transformations for refining generated OpenAPI types, particularly for handling `readOnly` and `writeOnly` properties, ensuring type safety and correct data handling across different API operations. Unlike `openapi-typescript` which generates the types, this package provides tools to manipulate and refine those generated types for specific application logic.
npm install openapi-typescript-helpersVerified import paths — ran on the pinned version, not inferred.
Demonstrates the usage of `Readable` and `Writable` helper types to refine generated OpenAPI types for specific read and write operations, highlighting how they filter `readOnly` and `writeOnly` properties.
Ensure `openapi-typescript` is installed and run to generate your API types before attempting to use these helpers.
Be prepared for potential minor breaking changes or undocumented behavior. Refer to the source code and `openapi-fetch`'s implementation for advanced usage.
When generating types with `openapi-typescript`, ensure you use the `--read-write-markers` flag (e.g., `npx openapi-typescript --read-write-markers your-api.yaml -o src/api-types.ts`).
Remove the `readOnly` property from the object being assigned to the `Writable` type, as it's not meant to be written to. Ensure `openapi-typescript` was run with `--read-write-markers`.
Ensure the target type or function parameter is also expecting a `Readable` type or a type that is compatible with the `writeOnly` properties being excluded. Or, verify that the original schema does not have `writeOnly` properties that are essential for the assignment.