Giter Club home page Giter Club logo

schema2ts's Introduction

schema2ts

JSON Schema to TypeScript. See also https://www.jsonschemavalidator.net/

See also http://json-schema.org/draft-07/schema

Normalized Schema Object

Excluding $id, $schema, $ref, $comment, title, description, default, readOnly, examples, contains, definitions, const, enum, if, then, else, allOf, anyOf, oneOf, not.

interface SimpleType {
  readonly array?: ArrayType
  readonly boolean?: BooleanType
  readonly integer?: IntegerType
  readonly null?: NullType
  readonly number?: NumberType
  readonly object?: ObjectType
  readonly string?: StringType
}

interface ArrayType {
    readonly additionalItems?: SchemaObject
    readonly items?: SchemaObject|ReadonlyArray<SchemaObject>
    readonly maxItems?: number
    readonly minItems: number
    readonly uniqueItems: boolean // default is false
}

interface BooleanType {
}

interface IntegerType extends NumberType {
}

interface NullType {
}

interface NumberType {
    readonly multipleOf?: number
    readonly maximum?: number
    readonly exclusiveMaximum?: number
    readonly minimum?: number
    readonly exclusiveMinimum?: number
}

interface ObjectType {
    readonly maxProperties?: number
    readonly minProperties: number // default is 0
    readonly required: ReadonlyArray<string> // default is []
    readonly additionalProperties?: SchemaObject
    readonly properties: StringMap<SchemaObject> // default is {}
    readonly patternProperties?: {} // ...
    readonly dependencies?: {} // ...
    readonly propertyNames?: {} // ...
}

interface StringType {
    readonly maxLength?: number
    readonly minLength: number // default is 0
    readonly patter?: string
    readonly format?: string
    readonly contentMediaType?: string
    readonly contentEncodinf?: string
}

schema2ts's People

Contributors

sergey-shandar avatar

Watchers

James Cloos avatar  avatar

schema2ts's Issues

better union merge

Resolve type references to real types. For example,

type A = string
type B = string|A

should be converted to

type A = string
type B = string

additional properties are not applied for `oneOf`

    "nonBodyParameter": {
      "type": "object",
      "required": [
        "name",
        "in",
        "type"
      ],
      "oneOf": [
        {
          "$ref": "#/definitions/headerParameterSubSchema"
        },
        {
          "$ref": "#/definitions/formDataParameterSubSchema"
        },
        {
          "$ref": "#/definitions/queryParameterSubSchema"
        },
        {
          "$ref": "#/definitions/pathParameterSubSchema"
        }
      ]
    }

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.