@orval/effect
v8.22.0
Published
Readme
@orval/effect
Generates Effect Schema validators from OpenAPI specifications.
Install
npm install -D @orval/effect
npm install effecteffect is a peer dependency (>=3.10). @orval/effect does not bundle it.
Usage
Set client: 'effect' in your orval.config:
import { defineConfig } from 'orval';
export default defineConfig({
petstore: {
input: { target: './petstore.yaml' },
output: {
client: 'effect',
target: './src/api/schemas',
mode: 'single',
},
},
});Generated output
import { Schema as S } from 'effect';
export const ListPetsQueryParams = S.Struct({
limit: S.optional(S.String).annotations({
description: 'How many items to return at one time (max 100)',
}),
});See the Effect guide and the swr-with-effect sample for more.
Why Effect alongside Zod?
@orval/effect mirrors @orval/zod's output shape, but Effect Schemas bring capabilities Zod can't:
- Encoded vs decoded type duality —
Schema.Type<S>(runtime) andSchema.Encoded<S>(wire) are distinct;Schema.encoderound-trips back to the wire shape. - Branded types as a generator option —
override.effect.useBrandedTypes: trueturns named schemas into Effect brands for nominal-typed IDs without hand-writing.brand<...>(). - First-class annotations — OpenAPI
description,title,examplesflow intoS.annotations(...)and stay queryable at the AST level. - AST, not method chains — schemas are introspectable artifacts, composable structurally by downstream tooling.
- Effect runtime integration — decoded results pipe straight into Effect's typed-error / retry / concurrency primitives.
Configuration
Options are read from override.effect.*:
strict— fail on extra fields in object schemasgenerate— fine-grained control over which schemas (params/body/response) are emitteduseBrandedTypes— map named schemas to branded typesgenerateEachHttpStatus— emit a schema per response status code
