nuxt3-api-gen

This tool generates TypeScript types and API methods based on a Swagger/OpenAPI schema.
1,860
Install
npm install nuxt3-api-gen
Latest Version:1.0.21
License:ISC
Last Updated:Jun 2, 2025
Links: GitHub  ·  npm
Maintainer: akbarshax

🚀 API Client Generator

This tool generates TypeScript types and API methods based on a Swagger/OpenAPI schema.

📋 Steps to Generate

  1. download necessary files In the root folder of your frontend application, run the command to download the composable and api-gen folders.

    ⚠️ Warning:
    Make sure you do not have composable files named useApi.ts or useApiService.ts. The script will overwrite them if they exist.

    If you already have files with these names, it's recommended to run the script in a different directory to safely download the composable and api-gen folders.

    npx nuxt3-api-gen
    
    
  2. Configure swaggerUrl

    • Open your Swagger UI in a browser.
    • Press F12 to open Developer Tools, go to the Network tab, and refresh the page.
    • Look for a .json request (usually the Swagger schema), right-click it, and copy its URL.
    • Paste the URL into the swaggerUrl field inside config.json.
  3. Run the generator
    In your terminal, run one of the following commands:

    npm run api-gen
    # or
    node generate.cjs
    
    
    

📦 Output

After running the command, a directory named api will be created in the same location as the script (if it doesn't already exist).

Inside the api folder, two files will be generated:

  • apiScheme.types.ts — TypeScript types generated from the Swagger schema.
  • apiScheme.ts — Grouped API methods based on tags defined in the Swagger spec.

These files are ready to use with the useApiService composable in your project.

🔧 Usage Example

<script lang="ts" setup>
const { data, error, status } = useApiService().users.getUserList();
// ...
</script>

Related Packages

nuxt-open-fetch

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

379,588 259
@localess/nuxt

Nuxt module for Localess's API.

6,411 1
@newschools/sdk

New Schools SDK - Multi-framework components and modules for integrating New Sch...

2,312
@habityzer/nuxt-openapi-composables

Generate type-safe Nuxt 3 & 4 composables from OpenAPI schemas

1,549 0
@nathanchase/nuxt-dayjs-module

This is a Nuxt 3 compatible module built with the official Nuxt 3 (module-builde...

19,376 31

Version History

Version Released License
1.0.21 ISC
1.0.20 ISC
1.0.19 ISC
1.0.18 ISC
1.0.17 ISC