An open API service indexing awesome lists of open source software.

https://github.com/Norbiros/nuxt-open-fetch

Generate zero-overhead, typed OpenAPI clients for Nuxt.
https://github.com/Norbiros/nuxt-open-fetch

api composable fetch nuxt openapi query

Last synced: 2 months ago
JSON representation

Generate zero-overhead, typed OpenAPI clients for Nuxt.

Awesome Lists containing this project

README

          

[![Nuxt Open Fetch](./docs/public/cover.png)](https://nuxt-open-fetch.norbiros.dev/)

# Nuxt Open Fetch

[![npm version][npm-version-src]][npm-version-href]
[![License][license-src]][license-href]
[![Nuxt][nuxt-src]][nuxt-href]

Generate zero-overhead, 100% typed OpenAPI clients for Nuxt.

In other words - `$fetch` and `useFetch` on steroids. Uses awesome [openapi-typescript](https://github.com/drwpow/openapi-typescript) generator under the hood.

> [!WARNING]
> APIs are subject to change before `v1.0.0`.
> All ideas/suggestions are welcome!

> [!IMPORTANT]
> Special thanks to @enkot for creating the original module - this project wouldn't be possible without your work 🎉

- [✨  Release Notes](/CHANGELOG.md)
- [📖  Read the documentation](https://nuxt-open-fetch.norbiros.dev/)

## Features

- 🍹  No manual typing of your API
- 🍋  Supports OpenAPI 3.0 and 3.1 (including advanced features like [discriminators](https://spec.openapis.org/oas/v3.1.0#discriminator-object))
- 🌲  Uses runtime-free types that outperform old-school codegen
- 📡  Load schemas from YAML or JSON, locally or remotely
- 🥞  Works with Nuxt [Layers](https://nuxt.com/docs/getting-started/layers)

## Quick Setup

1. Add `nuxt-open-fetch` dependency to your project

```bash
# Using pnpm
pnpm add -D nuxt-open-fetch

# Using yarn
yarn add --dev nuxt-open-fetch

# Using bun
bun add -D nuxt-open-fetch

# Using npm
npm install --save-dev nuxt-open-fetch
```

2. Add `nuxt-open-fetch` to the `modules` section of `nuxt.config.ts`

```js
export default defineNuxtConfig({
modules: [
'nuxt-open-fetch'
]
})
```

That's it! You can now use `nuxt-open-fetch` in your Nuxt app ✨

## Development

```bash
# Install dependencies
pnpm install

# Generate type stubs
pnpm dev:prepare

# Develop with the playground
pnpm dev

# Build the playground
pnpm dev:build

# Run ESLint
pnpm lint

# Run Vitest
pnpm test
pnpm test:watch

# Release new version
pnpm release
```

## License

Made with 💚

Published under the [MIT License](./LICENCE).

[npm-version-src]: https://img.shields.io/npm/v/nuxt-open-fetch/latest.svg?style=flat&colorA=18181B&colorB=28CF8D
[npm-version-href]: https://npmjs.com/package/nuxt-open-fetch

[license-src]: https://img.shields.io/npm/l/nuxt-open-fetch.svg?style=flat&colorA=18181B&colorB=28CF8D
[license-href]: https://npmjs.com/package/nuxt-open-fetch

[nuxt-src]: https://img.shields.io/badge/Nuxt-18181B?logo=nuxt.js
[nuxt-href]: https://nuxt.com