GithubHelp home page GithubHelp logo

pablaber / openapi-typescript-types Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 216 KB

A library for generating Typescript types from an OpenAPI document.

License: ISC License

JavaScript 4.55% TypeScript 95.45%

openapi-typescript-types's Introduction

openapi-typescript-types

A library for generating Typescript types from an OpenAPI document.

Usage

The script can either be run through the command line or with a config file.

Config File

The preferred way of running ott is by using a config file. If the config file is named ott.config.yaml and stored in the current working directory, the script can be invoked with that config file by running:

ott --config ./ott.config.yaml

Config File Structure

The structure and options for the config file are defined below:

version: 1.0               # The config version, only supports 1.0
input: ./swagger.yaml      # The path to teh swagger file input
output: ./out/types.ts     # The output file for the typescript types

options:                   # Additional options (optional)
  typeNameFormat: "{name}" # Format the name of output types.
  
  paths:                   # Options for paths, paths excluded if false
    include:               # List specific paths to include.
      - /pet/**            #   - Takes precedence over "exclude"
      - /store/**
    exclude:               # List specific paths to exclude
      - /user/**           #   - Has no effect if "include" is specified
  
  schemas:                 # Options for schemas, all schemas excluded if false
    include:               # List specific paths to include.
      - Pet                #   - Takes precedence over "exclude"
      - Category
    exclude:               # List specific paths to exclude
      - Customer           #   - Has no effect if "include" is specified

Command Line

The script can also be run through the command line, although the options are more limited than the config file.

You can always run ott --help for the most detailed and up to date explanation of the command line options.

Command Line Example

Below is an example of invoking the command to generate a types file without schemas that will be named petstore-types.ts from an input file of petstore.yaml.

ott \
  --input petstore.yaml \
  --output petstore-types.ts \
  --exclude-schemas

openapi-typescript-types's People

Contributors

pablaber avatar github-actions[bot] avatar

Watchers

 avatar

openapi-typescript-types's Issues

Support enum types

Instead of generic strings, enum strings can just be a list of the enum

Add logging

Add some more consistent logging. Using winston or some other logging library.

Add tests

Tests using jest or another testing framework

Also add linting / prettier

Require status checks to pass on testing and linting for merges

Initial Release

  • figure out some CI stuff to make it easier to publish
  • touch up readme before publish
  • add license
  • publish first package to npm under v0.1.0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.