MCPcopy
hub / github.com/ferdikoomen/openapi-typescript-codegen

github.com/ferdikoomen/openapi-typescript-codegen @v0.31.0 sqlite

repository ↗ · DeepWiki ↗ · release v0.31.0 ↗
211 symbols 551 edges 263 files 0 documented · 0%
README

Important announcement

[!IMPORTANT] Please migrate your projects to use @hey-api/openapi-ts

Due to time limitations on my end, this project has been unmaintained for a while now. The @hey-api/openapi-ts project started as a fork with the goal to resolve the most pressing issues. going forward they are planning to maintain the OpenAPI generator and give it the love it deserves. Please support them with their work and make sure to migrate your projects: https://heyapi.dev/openapi-ts/migrating.html#openapi-typescript-codegen

  • All open PR's and issues will be archived on the 1st of May 2024
  • All versions of this package will be deprecated in NPM

👋 Thanks for all the support, downloads and love! Cheers Ferdi.


OpenAPI Typescript Codegen

NPM License Downloads Build

Node.js library that generates Typescript clients based on the OpenAPI specification.

Why?

  • Frontend ❤️ OpenAPI, but we do not want to use JAVA codegen in our builds
  • Quick, lightweight, robust and framework-agnostic 🚀
  • Supports generation of TypeScript clients
  • Supports generations of Fetch, Node-Fetch, Axios, Angular and XHR http clients
  • Supports OpenAPI specification v2.0 and v3.0
  • Supports JSON and YAML files for input
  • Supports generation through CLI, Node.js and NPX
  • Supports tsc and @babel/plugin-transform-typescript
  • Supports aborting of requests (cancelable promise pattern)
  • Supports external references using json-schema-ref-parser

Install

npm install openapi-typescript-codegen --save-dev

Usage

$ openapi --help

  Usage: openapi [options]

  Options:
    -V, --version             output the version number
    -i, --input <value>       OpenAPI specification, can be a path, url or string content (required)
    -o, --output <value>      Output directory (required)
    -c, --client <value>      HTTP client to generate [fetch, xhr, node, axios, angular] (default: "fetch")
    --name <value>            Custom client class name
    --useOptions              Use options instead of arguments
    --useUnionTypes           Use union types instead of enums
    --exportCore <value>      Write core files to disk (default: true)
    --exportServices <value>  Write services to disk (default: true)
    --exportModels <value>    Write models to disk (default: true)
    --exportSchemas <value>   Write schemas to disk (default: false)
    --indent <value>          Indentation options [4, 2, tab] (default: "4")
    --postfixServices         Service name postfix (default: "Service")
    --postfixModels           Model name postfix
    --request <value>         Path to custom request file
    -h, --help                display help for command

  Examples
    $ openapi --input ./spec.json --output ./generated
    $ openapi --input ./spec.json --output ./generated --client xhr

Documentation

The main documentation can be found in the openapi-typescript-codegen/wiki

Sponsors

If you or your company use the OpenAPI Typescript Codegen, please consider supporting me. By sponsoring I can free up time to give this project some love! Details can be found here: https://github.com/sponsors/ferdikoomen

Extension points exported contracts — how you extend this code

Model (Interface)
(no doc)
src/client/interfaces/Model.d.ts
Templates (Interface)
(no doc)
src/utils/registerHandlebarTemplates.ts
OpenApiSecurityRequirement (Interface)
(no doc)
src/openApi/v2/interfaces/OpenApiSecurityRequirement.d.ts
Schema (Interface)
(no doc)
src/client/interfaces/Schema.d.ts
Dictionary (Interface)
(no doc)
src/utils/types.d.ts
OpenApiParameter (Interface)
(no doc)
src/openApi/v2/interfaces/OpenApiParameter.d.ts
Client (Interface)
(no doc)
src/client/interfaces/Client.d.ts
OpenApiPath (Interface)
(no doc)
src/openApi/v2/interfaces/OpenApiPath.d.ts

Core symbols most depended-on inside this repo

getType
called by 22
src/openApi/v3/parser/getType.ts
copyAsset
called by 21
test/e2e/scripts/copyAsset.ts
getType
called by 21
src/openApi/v2/parser/getType.ts
getOperationName
called by 21
src/openApi/v2/parser/getOperationName.ts
getOperationName
called by 21
src/openApi/v3/parser/getOperationName.ts
getPattern
called by 19
src/utils/getPattern.ts
generateClient
called by 18
test/e2e/scripts/generateClient.ts
cleanup
called by 18
test/e2e/scripts/cleanup.ts

Shape

Function 129
Interface 67
Class 8
Enum 5
Method 2

Languages

TypeScript100%

Modules by API surface

test/e2e/assets/main-angular.ts5 symbols
test/e2e/assets/main-angular-module.ts5 symbols
test/e2e/scripts/browser.ts4 symbols
test/index.js3 symbols
src/utils/discriminator.ts3 symbols
types/index.d.ts2 symbols
test/e2e/scripts/server.ts2 symbols
src/utils/registerHandlebarTemplates.ts2 symbols
src/utils/getOpenApiVersion.ts2 symbols
src/openApi/v3/parser/getType.ts2 symbols
src/openApi/v3/parser/getOperationResults.ts2 symbols
src/openApi/v3/parser/getContent.ts2 symbols

Used by 2 indexed graphs manifest dependencies, hub-wide

Dependencies from manifests, versioned

@angular-devkit/build-angular22.0.3 · 1×
@angular/animations22.0.2 · 1×
@angular/cli22.0.3 · 1×
@angular/common22.0.2 · 1×
@angular/compiler22.0.2 · 1×
@angular/compiler-cli22.0.2 · 1×
@angular/core22.0.2 · 1×
@angular/forms22.0.2 · 1×
@angular/platform-browser22.0.2 · 1×
@angular/platform-browser-dynamic22.0.2 · 1×
@angular/router22.0.2 · 1×
@apidevtools/json-schema-ref-parser14.2.1 · 1×

For agents

$ claude mcp add openapi-typescript-codegen \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact