Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

json2ts

Automatically generate typescript definition file from url

Install

npm install json2ts-core --save-dev

Usage(CLI)

you can generate multiple ts definition files for api site,like NEI(default). or generate single file for your single url address.

json2ts -u=your-web-url
--version       Show version number                                   [boolean]
  -u, --url       your web url                                        [required]
  -m, --method    your web url method                           [default: "get"]
  -t, --target    typescript interface target folder path       [default: "./interfaces"]
  -p, --property  export response property interface
  -h, --help      Show help                                           [boolean]

Usage(API)

you can use api to parser user-defined rule.

const json2ts = require('json2ts-core/src/json2ts')

json2ts({url: 'http://localhost:8002'}, ($) => {
  // your rule to parser page
  $('selector').each(function(index, element) {
    ...
    arr.push({ url, method })
  })
  return arr
})

License

The code is distributed under the MIT license

About

automatically generate typescript definition file from url

Topics

Resources

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages