Giter Site home page Giter Site logo

json-schema-to's Introduction

Build Status NPM version Coverage Status Dependency Status devDependency Status

JSON-Schema To
≤GraphQL|Protobuf|Code≥.™

Generate third-party definitions directly from your JSON-Schema.

Contribute!

This module is under development, we're missing:

  • Documentation
  • Advanced examples
  • Complete unit-testing
  • Complete code-coverage

How it works?

JSON-Schema, GraphQL and Protobuf are generated from YAML definitions, e.g.

id: User
service:
  calls:
  - set: updatePassword
    resp: User
    input: UpdatePasswordParams
    params: UpdatePasswordRequest
definitions:
  UpdatePasswordParams:
  UpdatePasswordRequest:

This definition is also a JSON-Schema definition.

Actually, it can be a .json file to but YAML format it's easier to maintain.

Due resp, input and params are schema identifiers they'll be looked-up from all available schemas or from #/definitions on the current file.

Options for calls are:

  • get — RPC call (or Query)
  • set — RPC call (or Mutation)
  • resp — Response type
  • input — Request type
  • params — Request type (Protobuf only)

Use the params option only if you want different input types.

Having some definitions like this we can produce different outputs, e.g.

$ tree .
.
└── schema
    └── test.yml

1 directory, 1 file

$ npx json-schema-to -s schema --json --graphql --protobuf
write ./generated/user.json
write ./generated/user.gql
write ./generated/user.proto
write ./generated/common.json
write ./generated/common.gql
write ./generated/common.proto

Now you can use those sources in your application.

Use --help to display more usage info from the CLI

json-schema-to's People

Contributors

pateketrueke avatar dependabot[bot] avatar

Watchers

James Cloos avatar

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.