Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How about a typescript definition for a schema file? #22

Closed
ca0v opened this issue Nov 14, 2014 · 1 comment
Closed

How about a typescript definition for a schema file? #22

ca0v opened this issue Nov 14, 2014 · 1 comment

Comments

@ca0v
Copy link

ca0v commented Nov 14, 2014

It would be nice to have a definitive typescript interface for json schema.

typson.definitions("example/invoice/line.ts").done(function(tree: JsonSchema) {
    document.getElementById("types").innerHTML = JSON.stringify(tree, undefined, 2);
});

This would facilitate the generation of server classes out of the JSON schema as you mention here

So, one can use the JSON schema to document and validate the JSON data. We can even generate the server classes out of the JSON schema.

This is the GIST of it:

interface IDependencyDescriptor {
    [s: string]: string;
}

interface IPropertyDescriptor {
    [s: string]: {
        '$ref'?: string;
        type?: string;
        format?: string;
        description?: string;
    };
}

export interface IJsonSchema {
    type: string;
    properties: IPropertyDescriptor;
    required?: Array<string>;
    dependencies?: IDependencyDescriptor;
    id?: string;
    '$schema'?: string;
    description?: string;
    title?: string;
    definitions?: any;
}

export interface IJsonSchemaModel {
    [s: string]: IJsonSchema;
}
@lbovet
Copy link
Owner

lbovet commented Dec 9, 2014

This would be a nice TS project. However, this is out of Typson's scope, which aims only at generating a schema.

@lbovet lbovet closed this as completed Dec 9, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants