@ibabkin/openapi-to-server v1.17.8
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>>;
}
14 days ago
14 days ago
14 days ago
14 days ago
14 days ago
14 days ago
14 days ago
14 days ago
14 days ago
14 days ago
14 days ago
17 days ago
17 days ago
20 days ago
20 days ago
21 days ago
22 days ago
22 days ago
1 month ago
2 months ago
3 months ago
3 months ago
3 months ago
3 months ago
10 months ago
10 months ago
10 months ago
9 months ago
8 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago