Skip to content

Repository files navigation

openapi-effect

Drop-in replacement for openapi-fetch with an opt-in Effect API.

Install

pnpm add @prover-coder-ai/openapi-effect

Usage (Envelope API)

This package implements openapi-fetch compatible method inputs and response envelopes.

import{Effect}from"effect"importcreateClientfrom"@prover-coder-ai/openapi-effect"importtype{paths}from"./openapi"constclient=createClient<paths>({baseUrl: "https://api.example.com"})constprogram=Effect.gen(function*(){const{ data, error }=yield*client.GET("/pets",{params: {query: {limit: 10}}})returnerror??data})

Usage (Effect API)

createClientEffect keeps the same method inputs but moves non-2xx responses into the Effect error channel.

import{Effect}from"effect"import{createClientEffect}from"@prover-coder-ai/openapi-effect"importtype{paths}from"./openapi"constclient=createClientEffect<paths>({baseUrl: "https://api.example.com"})constprogram=Effect.gen(function*(){constresult=yield*client.GET("/pets",{params: {query: {limit: 10}}})returnresult.body})

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages