Skip to content

0x-jerry/openapi-ts

Repository files navigation

OpenAPI Code Generator

This package provide a quick way to transform OpenAPI schema or Swagger schema to client typescript code.

Usage

  1. Generate client typescript code
import { generate } from '@0x-jerry/openapi-ts'

const apiUrl = 'http://doc-url/api-docs'

const swaggerSchema = await (await fetch(apiUrl)).json()

await generate({
  schema: swaggerSchema,
  output: 'api',
  format: true,
  clean: true,
  adapter: 'axios'
})
  1. Change adapter file api/_adapter.ts to suit your needs.

  2. Use generated code

import * as api from './api/generated'

const resp = await api.segment.to.path.$get({...})

About

Openapi schema to client typescript code

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •