1.17.8 • Published 14 days ago

@ibabkin/openapi-to-server v1.17.8

Weekly downloads
-
License
ISC
Repository
github
Last release
14 days ago

NPM version:latest npm downloads Coverage Status License

Description

Generates typescript interfaces for operations from OpenAPI 3.0 specification. Recommended to use with @ibabkin/openapi-to-zod

Usage

  • supported version of OpenAPI: 3.0.0
  • supports yaml-import
  • --json - emit json file alongside with typescript file
openapi-to-server --input ./swagger.yaml --output ./operations.d.ts --json
import api from './swagger.json';
import { OpenAPIV3 } from 'openapi-types';
import { renderDocument } from '../lib';
import fs from 'fs';

fs.writeFileSync('./operations.d.ts', renderDocument(api as OpenAPIV3.Document));

Input example:

openapi: 3.0.0
info:
  title: Simple Inventory API
  description: This is a simple API
  contact:
    email: you@your-company.com
  license:
    name: Apache 2.0
    url: http://www.apache.org/licenses/LICENSE-2.0.html
  version: 1.0.0
servers:
  - url: https://virtserver.swaggerhub.com/DOSAKANTIVENKATESH/smp/1.0.0
    description: SwaggerHub API Auto Mocking
tags:
  - name: admins
    description: Secured Admin-only calls
  - name: developers
    description: Operations available to regular developers
paths:
  !!import/merge
    - paths.yaml

components:
  schemas:
    !!import/merge
      - components.yaml

Output example:

export type SearchInventoryPayload = {
  query: {
    searchString?: string,
    skip: number,
    limit: number,
  }
};

export type SearchInventoryResponse = InventoryItem[]

export type Operations = {
  searchInventory: IRoute<SearchInventoryPayload, Ok<SearchInventoryResponse>>;
}
1.16.0

14 days ago

1.17.2

14 days ago

1.17.1

14 days ago

1.17.0

14 days ago

1.17.6

14 days ago

1.17.5

14 days ago

1.17.4

14 days ago

1.17.3

14 days ago

1.17.8

14 days ago

1.17.7

14 days ago

1.15.0

14 days ago

1.14.1

17 days ago

1.14.2

17 days ago

1.14.0

20 days ago

1.13.0

20 days ago

1.12.0

21 days ago

1.11.0

22 days ago

1.10.0

22 days ago

1.9.5

1 month ago

1.9.4

2 months ago

1.9.3

3 months ago

1.9.2

3 months ago

1.9.1

3 months ago

1.9.0

3 months ago

1.8.9

10 months ago

1.8.10

10 months ago

1.8.8

10 months ago

1.8.11

9 months ago

1.8.12

8 months ago

1.8.7

11 months ago

1.8.6

11 months ago

1.8.5

11 months ago

1.8.4

11 months ago

1.8.3

11 months ago

1.8.2

11 months ago

1.8.1

11 months ago

1.8.0

11 months ago

1.7.10

11 months ago

1.7.9

11 months ago

1.7.8

11 months ago

1.7.7

11 months ago

1.7.6

11 months ago

1.7.5

11 months ago

1.7.4

11 months ago

1.7.3

11 months ago

1.7.2

11 months ago

1.7.1

11 months ago

1.7.0

11 months ago

1.6.0

11 months ago

1.5.1

11 months ago

1.5.0

11 months ago

1.4.1

11 months ago

1.4.0

11 months ago

1.3.10

11 months ago

1.3.9

11 months ago

1.3.8

11 months ago

1.3.7

11 months ago

1.3.6

11 months ago

1.3.5

11 months ago

1.3.4

11 months ago

1.3.3

11 months ago

1.3.2

11 months ago

1.3.1

11 months ago

1.3.0

11 months ago

1.2.0

11 months ago

1.1.8

11 months ago

1.1.7

11 months ago

1.1.6

11 months ago

1.1.5

11 months ago

1.1.4

11 months ago

1.1.3

11 months ago

1.1.2

11 months ago

1.1.1

11 months ago

1.1.0

11 months ago

1.0.1

11 months ago