feat: add jsonschema-protobuf definition (#45992)

This commit is contained in:
Mo Kweon 2020-07-10 05:42:47 -07:00 committed by GitHub
parent 6942b607b9
commit 356af11d46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 59 additions and 0 deletions

6
types/jsonschema-protobuf/index.d.ts vendored Normal file
View File

@ -0,0 +1,6 @@
// Type definitions for jsonschema-protobuf 1.0
// Project: https://github.com/karissa/jsonschema-protobuf
// Definitions by: Mo Kweon <https://github.com/kkweon>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare function convert(schema: string): string;
export = convert;

View File

@ -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);

View File

@ -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"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }