Setup
Configuration
Learn how to configure NuxtOpenFetch
nuxt.config.ts
export default defineNuxtConfig({
modules: ['nuxt-open-fetch'],
openFetch: {
clients: {}
}
})
Key | Type | Default | Description |
---|---|---|---|
openAPITS | OpenAPITSOptions | OpenAPI TS options | |
addPlugin | boolean | true | If enable default plugin to create fetch clients |
Clients | |||
clients.[client] | OpenFetchClientOptions | Client options | |
clients.[client].baseURL | string | Base URL for the request. | |
clients.[client].headers | HeadersInit | Request headers. | |
clients.[client].query | SearchParameters | Adds query search params to URL | |
clients.[client].schema | OpenAPI3Schema | Local 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: {} // The key should be specified as it is used to generate the client
}
},
runtimeConfig: {
public: {
openFetch: {
pets: {
schema: 'https://petstore3.swagger.io/api/v3/openapi.json',
baseURL: 'https://petstore3.swagger.io/api/v3/'
},
},
}
},
})
or:
NUXT_PUBLIC_OPEN_FETCH_PETS_SCHEMA=https://petstore3.swagger.io/api/v3/openapi.json
NUXT_PUBLIC_OPEN_FETCH_PETS_BASE_URL=https://petstore3.swagger.io/api/v3/