diff --git a/types/jsonschema-protobuf/index.d.ts b/types/jsonschema-protobuf/index.d.ts new file mode 100644 index 0000000000..dc004003c0 --- /dev/null +++ b/types/jsonschema-protobuf/index.d.ts @@ -0,0 +1,6 @@ +// Type definitions for jsonschema-protobuf 1.0 +// Project: https://github.com/karissa/jsonschema-protobuf +// Definitions by: Mo Kweon +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +declare function convert(schema: string): string; +export = convert; diff --git a/types/jsonschema-protobuf/jsonschema-protobuf-tests.ts b/types/jsonschema-protobuf/jsonschema-protobuf-tests.ts new file mode 100644 index 0000000000..a46d15e684 --- /dev/null +++ b/types/jsonschema-protobuf/jsonschema-protobuf-tests.ts @@ -0,0 +1,28 @@ +import toProtobuf from 'jsonschema-protobuf'; + +// $ExpectType string +toProtobuf(` +{ + "type": "object", + "name": "person", + "properties": { + "name": {"type": "string"}, + "age": {"type": "integer", "min": 0, "max": 120}, + "income": {"type": "number", "min": 0}, + "universe": {"type": "string", "enum": ["Marvel", "DC"]}, + "living": {"type": "boolean", "default": true}, + "alterEgos": {"type": "array", "items": {"type": "string"}}, + "location": { + "type": "object", + "properties": { + "city": {"type": "string"}, + "state": {"type": "string", "regex": "/[A-Z]{2}/"} + } + } + }, + "required": ["name", "age", "income"] +}`); + +// When the param is incorrect +// $ExpectError +toProtobuf(1); diff --git a/types/jsonschema-protobuf/tsconfig.json b/types/jsonschema-protobuf/tsconfig.json new file mode 100644 index 0000000000..06bd810a24 --- /dev/null +++ b/types/jsonschema-protobuf/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "allowSyntheticDefaultImports": true, + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "jsonschema-protobuf-tests.ts" + ] +} diff --git a/types/jsonschema-protobuf/tslint.json b/types/jsonschema-protobuf/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/jsonschema-protobuf/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }