I'm using swagger-typescript-api to generate interfaces from swagger schema

npx swagger-typescript-api generate -p PATH_TO_YOUR_SCHEMA -o ./
Answer from Sergey Volkov on Stack Overflow
🌐
GitHub
github.com › acacode › swagger-typescript-api
GitHub - acacode/swagger-typescript-api: Generate the API Client for Fetch or Axios from an OpenAPI Specification · GitHub
Generate the API Client for Fetch or Axios from an OpenAPI Specification - acacode/swagger-typescript-api
Starred by 4.1K users
Forked by 428 users
Languages   TypeScript 87.2% | EJS 9.7% | JavaScript 3.1%
🌐
npm
npmjs.com › package › swagger-typescript-api
swagger-typescript-api - npm
1 week ago - Generate the API client for Fetch or Axios from an OpenAPI Specification. Latest version: 13.6.10, last published: 42 minutes ago. Start using swagger-typescript-api in your project by running `npm i swagger-typescript-api`. There are 144 other projects in the npm registry using swagger-typescript-api.
      » npm install swagger-typescript-api
    
Published   Apr 16, 2026
Version   13.6.10
Discussions

How to generate basic TypeScript interfaces from Swagger schema? - Stack Overflow
I'm looking for a way to generate simplistic TypeScript interfaces from a Swagger schema. Most solutions I find are needlessly complicated. I would like to generate interfaces like this: export More on stackoverflow.com
🌐 stackoverflow.com
Any examples of how to use the output from swagger-typescript-api?
One question. Does your swagger json file contains possible exception codes for a given api? If not, then generated sdk will not handle it. More on reddit.com
🌐 r/typescript
3
5
October 2, 2024
How do you generate and manage your API types?
Our backend uses Swagger/Open API, and we generate our types based on the swagger.json. Frankly, this sucks to manage across deployments and branches. Our backend is in a separate repository, so we frequently block preview deployments because our hosted staging or dev instance is either ahead or behind our frontend. Your backend either needs to be backwards compatible, or your your frontend and your backend belong together and get released together. More on reddit.com
🌐 r/typescript
24
15
February 13, 2024
API Testing Schema Validation?
Use openapi-zod-client . It generates Zod schemas and a type-safe API client from your OpenAPI specs that validates endpoint responses automatically at runtime using the generated schemas. So, inside your tests, all you need to do is to send requests. The library will validate the responses for you. In other words, if the request is successful, the response is valid. Since the library also generates Zod schemas, you can use them to validate the responses manually if really you want to. More on reddit.com
🌐 r/typescript
7
5
September 16, 2024
🌐
DEV Community
dev.to › po5i › how-to-generate-a-typescript-client-from-a-swagger-documented-api-14d8
How to generate a TypeScript client from a Swagger documented API - DEV Community
March 20, 2022 - In my previous tutorial, I built a simple REST API with Swagger documentation. Check it out: ... In this tutorial, I will generate a TypeScript client code based on the Swagger documentation and use it on a simple React application (it can be any front-end application).
🌐
GitHub
github.com › acacode › swagger-typescript-api › releases
Releases · acacode/swagger-typescript-api
Generate the API Client for Fetch or Axios from an OpenAPI Specification - Releases · acacode/swagger-typescript-api
Author   acacode
🌐
Fig
fig.io › manual › swagger-typescript-api
swagger-typescript-api | Fig
swagger-typescript-api · swagger-typescript-api generate-templates · Generate api via swagger scheme · On this page · Subcommands ·
🌐
GitHub
github.com › acacode › swagger-typescript-api › issues
Issues · acacode/swagger-typescript-api
Generate the API Client for Fetch or Axios from an OpenAPI Specification - Issues · acacode/swagger-typescript-api
Author   acacode
Find elsewhere
🌐
Medium
medium.com › @sina.alizadeh120 › unlocking-rapid-development-typescript-model-generation-with-swagger-5c184a3c89f4
Unlocking Rapid Development: TypeScript Model Generation with Swagger | by Sina Alizadeh | Medium
January 15, 2024 - One of the primary tools utilized in this process is Swagger-Typescript-Api, a versatile library that simplifies the generation of models and API requests from Swagger specifications.
🌐
Medium
medium.com › @youry.stancatte › generating-typescript-interfaces-from-swagger-1910cc7a726a
Generating Typescript interfaces from Swagger | by Youry Stancato | Medium
January 23, 2023 - One of the benefits of using the ... API. When working with a TypeScript project, the openapi-typescript library can be used to generate TypeScript interfaces from a Swagger file....
🌐
CodeSandbox
codesandbox.io › examples › package › swagger-typescript-api
swagger-typescript-api examples - CodeSandbox
Use this online swagger-typescript-api playground to view and fork swagger-typescript-api example apps and templates on CodeSandbox.
🌐
Medium
christo8989.medium.com › 5-lessons-learned-about-swagger-typescript-api-511240b34c1
5 Lessons Learned About swagger-typescript-api | by Christopher Jeffery | Medium
September 9, 2022 - 5 Lessons Learned About swagger-typescript-api What they don’t tell you in their documentation. There’s no sense in writing code that can be generated. The issue I’ve encountered is that code …
🌐
GitHub
github.com › john-zulhelmi › swagger-typescript-api
GitHub - john-zulhelmi/swagger-typescript-api · GitHub
It is type mapper or translator swagger schema objects. primitiveTypeConstructs translates type/format schema fields to typescript structs.
Author   john-zulhelmi
🌐
iO tech_hub
techhub.iodigital.com › articles › generate-types-with-swagger
Quick Tip: Generate Types Based on OpenAPI (Swagger)
May 12, 2025 - You can find the Swagger UI here and the Swagger file here. The package we will use is called swagger-typescript-api. It is a command-line tool that generates TypeScript types and API clients from OpenAPI (Swagger) specifications.
🌐
Stackademic
stackademic.com › blog › how-to-create-api-documentation-fast-swagger-with-typescript-a5926acbed30
How To Create API Documentation (FAST): Swagger With TypeScript | Stackademic
August 20, 2023 - import express from 'express'; import { employeeRouter } from './employee-route'; export const routes = express.Router(); routes.use('/api/employee', employeeRouter); If import *** from *** gives an error, there could be an error in your tsconfig.json file. It is important to give “esModuleInterop” field true and if you already defined this, you can restart your IDE. Next, we define swagger.ts file. ... import swaggerAutogen from 'swagger-autogen'; const doc = { info: { version: 'v1.0.0', title: 'Swagger Demo Project', description: 'Implementation of Swagger with TypeScript' }, servers: [
🌐
GitHub
github.com › rmkasendwa › swagger-to-ts
GitHub - rmkasendwa/swagger-to-ts: swagger-to-ts is a powerful library that allows you to generate TypeScript code from Swagger documentation or OpenAPI specifications. It simplifies the process of integrating API definitions into your TypeScript projects, saving you time and effort.
Generate TypeScript interfaces and types from Swagger or OpenAPI specifications. Supports both Swagger 2.0 and OpenAPI 3.0 specifications. Provides strong type safety by inferring data types, request bodies, response schemas, and more.
Author   rmkasendwa
🌐
Codepruner
codepruner.com › how-to-use-apiclient-generated-by-swagger-typescript-api
How to use apiClient generated by swagger-typescript-api
What should be intput and output for passing function type ApiClientOptions<ResponseType> = ( apiClientParameters: ApiClientParameters ) => Promise<AxiosResponse<ResponseType>>; // if you want to add more paramaters to the ApiClient, I think they should be defined here type ApiClientParameters = { api: GeneratedApiClient<unknown>; }; //it is the internal method method const createApiClient = (): GeneratedApiClient<unknown> => { const baseUrl = getBaseUrl(); // we need to configure it a bit on start.
🌐
Medium
medium.com › bb-tutorials-and-thoughts › how-to-add-swagger-to-nodejs-rest-api-typescript-version-5a63953c993b
How To Add Swagger To NodeJS REST API — Typescript Version | by Bhargav Bachina | Bachina Labs | Medium
September 9, 2020 - We need to install types as well since we are implementing a typescript version. npm install swagger-ui-express swagger-jsdoc --save npm install @types/swagger-ui-express @types/swagger-jsdoc --save · You need to define the routes and task files separately as below. Routes contain all the route information and it loads appropriate files based on the path. ... There are two things you need to understand before implementing swagger docs to your REST API.
🌐
Reddit
reddit.com › r/typescript › any examples of how to use the output from swagger-typescript-api?
r/typescript on Reddit: Any examples of how to use the output from swagger-typescript-api?
October 2, 2024 -

Lots of examples of how to run the tool to generate a client based on an OpenAPI spec.... but damn'd if I can't find an example of how to use it.

Here's where I'm at (this is in a ReactJS app):

import { Api } from "../../../swaggergen/Api";
import { loginRequest } from "../authConfig";
import { msalInstance } from "../index";

export async function getApiClient() {

    var client = new Api({
        baseUrl: "",
        securityWorker: () => {
            const account = msalInstance.getActiveAccount();
            if (!account) {
                throw Error("No active account! Verify a user has been signed in and setActiveAccount has been called.");
            }
        
            const response = await msalInstance.acquireTokenSilent({
                ...loginRequest,
                account: account
            });
                    
            return {
                headers: {
                    Authorization: `Bearer ${response.accessToken}`
                },
            };
        },
    });
        
    // Halp... how to use client?
    //?     var d = await client.v1.MyFunkyList();
    //?     var r = await d.json();
}

How do I get typed results out of the API? MyFunkyList() on success should returns and instance of MyFunkyData. But danged if I see how?

Also, how do I handle error conditions? For example some POST calls will return 400 bad request with standard JSON message that contains the error details. How do I detect 400; how do I get the JSON data?

The tool's site: https://www.npmjs.com/package/swagger-typescript-api

Thanks a ton!