Giter Site home page Giter Site logo

compile-schemas-to-typescript's Introduction

Compile Schemas to TypeScript

This module is a wrapper around the json-schema-to-typescript library that enables transformation of directories of schemas instead of individual schemas. If directory support is added to the json-schema-to-typescript library this module will be archived.

CLI

This module works as an CLI. Install as a dependency and call compile-schemas-to-typescript from a npm script, or use npx

npx compile-schemas-to-typescript <schema-dir> <types-output-dir>

API

compileSchema(input: string, output: string): Promise<void>

The method iterates over the contents of the input directory and compiles any .json files into TypeScript interfaces and stores the generated output into the specified output directory.

const compileSchemas = require('compile-schemas-to-typescript')

(async () => {
  try {
    await compileSchemas('./schemas', './types')
  } catch (err) {
    console.error(err)
    process.exit(1)
  }
})()

Contributing

This project is actively maintained by the Fastify team.

Contributions are welcome! Please open an issue and a pull request.

License

Licensed under MIT.

compile-schemas-to-typescript's People

Contributors

eomm avatar ethan-arrowood avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

eomm lundibundi

compile-schemas-to-typescript's Issues

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on Greenkeeper branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because it uses your CI build statuses to figure out when to notify you about breaking changes.

Since we didn’t receive a CI status on the greenkeeper/initial branch, it’s possible that you don’t have CI set up yet.
We recommend using:

If you have already set up a CI for this repository, you might need to check how it’s configured. Make sure it is set to run on all new branches. If you don’t want it to run on absolutely every branch, you can whitelist branches starting with greenkeeper/.

Once you have installed and configured CI on this repository correctly, you’ll need to re-trigger Greenkeeper’s initial pull request. To do this, please click the 'fix repo' button on account.greenkeeper.io.

Add unit test for cli.ts

Unit tests were omitted for the CLI feature of this app as the function simply wraps the underlying logic; however, it is still important it is tested somehow.

I tried using exec from the Node.js child-process lib but it was returning/resolving before the file operations were complete. If anyone has ideas how to better test this please share!

Here is the code I came up with for a unit test using exec: cfa8517#diff-583d616f4b01bf1fa153e71c0cef7de7

Prep and Publish v0.0.1

Couple things necessary before we publish the initial version of this module.

  • Set up CI (either using Azure Pipelines or GitHub actions)
  • Add error cases + tests
    • i.e. invalid functions arguments
    • i.e. directory already exists
  • figure out build->deploy process
    • module is written in TypeScript so when we publish we need to publish the build directory output rather than the src directory.

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.