Setup

Configuration

Learn how to configure NuxtOpenFetch

nuxt.config.ts
export default 
defineNuxtConfig
({
modules
: ['nuxt-open-fetch'],
openFetch
: {
clients
: {}
} })
KeyTypeDefaultDescription
openAPITSOpenAPITSOptionsOpenAPI TS options
addPluginbooleantrueIf enable default plugin to create fetch clients
Clients
clients.[client]OpenFetchClientOptionsClient options
clients.[client].baseURLstringBase URL for the request.
clients.[client].headersHeadersInitRequest headers.
clients.[client].querySearchParametersAdds query search params to URL
clients.[client].schemaOpenAPI3SchemaLocal or remote schema file (YAML or JSON)

Client can also be configured using runtimeConfig or environment variables:

nuxt.config.ts
export default 
defineNuxtConfig
({
openFetch
: {
clients
: {
pets
: {}
} },
runtimeConfig
: {
openFetch
: {
pets
: {
schema
: 'https://petstore3.swagger.io/api/v3/openapi.json',
baseURL
: 'https://petstore3.swagger.io/api/v3/'
}, }, }, })

or:

NUXT_OPEN_FETCH_PETS_SCHEMA=https://petstore3.swagger.io/api/v3/openapi.json
NUXT_OPEN_FETCH_PETS_BASE_URL=https://petstore3.swagger.io/api/v3/

Copyright © 2023