Git Product home page Git Product logo

json-schema-language-jsl-codegen's Introduction

jsl-codegen

jsl-codegen generates data structures from JSON Schema Language. Define your schema in a portable way with JSL, and then generate idiomatic code -- structs, classes, interfaces, et cetera -- for any language.

Supported Languages

jsl-codegen can output code for the following languages:

  • TypeScript
  • Golang
  • Java

More targets can be added relatively easily. Just open a GitHub issue on this project to make a feature request!

Usage

As a quick example, here's how you create some TypeScript from a JSL schema:

jsl-codegen --ts-out=gen/typescript -- user.json

That will output some TypeScript into gen/typescript/user.ts.

Example

If you're using TypeScript, jsl-codegen can convert a JSL schema like this:

{
  "properties": {
    "name": { "type": "string" },
    "isAdmin": { "type": "boolean" }
  },
  "optionalProperties": {
    "favoriteNumbers": { "elements": { "type": "number" }}
  }
}

Into this:

interface User {
  name: string;
  isAdmin: boolean;
  favoriteNumbers?: number[];
}

But using the same exact schema, you can also generate some Java:

public class User {
  public String name;
  public boolean isAdmin;
  public List<Double> favoriteNumbers;
}

Or some Golang:

type User struct {
  Name           string    `json:"name"`
  IsAdmin        bool      `json:"isAdmin"`
  FavoriteNumber []float64 `json:"favoriteNumbers"`
}

Full Usage

JSL supports multiple output languages, and can output multiple languages at once. As a consequence, all of the following parameters can be provided simultaneously.

jsl-codegen 1.0
Generates code from a JSON Schema Language schema

USAGE:
    jsl-codegen [OPTIONS] [--] <INPUT>

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

OPTIONS:
        --go-out <go-out>        Go output directory
        --java-out <java-out>    Java output directory
        --java-pkg <java-pkg>    Java output package
        --ts-out <ts-out>        TypeScript output directory

ARGS:
    <INPUT>    Input JSON Schema Language schema file

json-schema-language-jsl-codegen's People

Contributors

ucarion avatar

Watchers

 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.