mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
feat: add jsonschema-protobuf definition (#45992)
This commit is contained in:
parent
6942b607b9
commit
356af11d46
6
types/jsonschema-protobuf/index.d.ts
vendored
Normal file
6
types/jsonschema-protobuf/index.d.ts
vendored
Normal 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;
|
||||
28
types/jsonschema-protobuf/jsonschema-protobuf-tests.ts
Normal file
28
types/jsonschema-protobuf/jsonschema-protobuf-tests.ts
Normal 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);
|
||||
24
types/jsonschema-protobuf/tsconfig.json
Normal file
24
types/jsonschema-protobuf/tsconfig.json
Normal 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"
|
||||
]
|
||||
}
|
||||
1
types/jsonschema-protobuf/tslint.json
Normal file
1
types/jsonschema-protobuf/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user