Skip to content

Commit 4915bc1

Browse files
robertmassaiolidomoritz
authored andcommitted
Issue YousefED#113: @TJS-format now fully supported.
1 parent cf275f3 commit 4915bc1

File tree

3 files changed

+101
-1
lines changed

3 files changed

+101
-1
lines changed

test/programs/annotation-tjs/main.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// All of these formats are defined in this specification: http://json-schema.org/latest/json-schema-validation.html#rfc.section.8.3
2+
interface MyObject {
3+
/**
4+
* @TJS-format date-time
5+
*/
6+
dateTime: string;
7+
8+
/**
9+
* @TJS-format email
10+
*/
11+
email: string;
12+
13+
/**
14+
* @TJS-format hostname
15+
*/
16+
hostname: string;
17+
18+
/**
19+
* @TJS-format ipv4
20+
*/
21+
ipv4: string;
22+
23+
/**
24+
* @TJS-format ipv6
25+
*/
26+
ipv6: string;
27+
28+
/**
29+
* @TJS-format uri
30+
*/
31+
uri: string;
32+
33+
/**
34+
* @TJS-format uri-reference
35+
*/
36+
uriReference: string;
37+
38+
/**
39+
* @TJS-format uri-template
40+
*/
41+
uriTemplate: string;
42+
43+
/**
44+
* @TJS-format json-pointer
45+
*/
46+
jsonPointer: string;
47+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-04/schema#",
3+
"properties": {
4+
"dateTime": {
5+
"format": "date-time",
6+
"type": "string"
7+
},
8+
"email": {
9+
"format": "email",
10+
"type": "string"
11+
},
12+
"hostname": {
13+
"format": "hostname",
14+
"type": "string"
15+
},
16+
"ipv4": {
17+
"format": "ipv4",
18+
"type": "string"
19+
},
20+
"ipv6": {
21+
"format": "ipv6",
22+
"type": "string"
23+
},
24+
"jsonPointer": {
25+
"format": "json-pointer",
26+
"type": "string"
27+
},
28+
"uri": {
29+
"format": "uri",
30+
"type": "string"
31+
},
32+
"uriReference": {
33+
"format": "uri-reference",
34+
"type": "string"
35+
},
36+
"uriTemplate": {
37+
"format": "uri-template",
38+
"type": "string"
39+
}
40+
},
41+
"required": [
42+
"dateTime",
43+
"email",
44+
"hostname",
45+
"ipv4",
46+
"ipv6",
47+
"jsonPointer",
48+
"uri",
49+
"uriReference",
50+
"uriTemplate"
51+
],
52+
"type": "object"
53+
}

typescript-json-schema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import * as stringify from "json-stable-stringify";
77
const vm = require("vm");
88

99
const REGEX_FILE_NAME = /".*"\./;
10-
const REGEX_TJS_JSDOC = /^-([\w]+)\s([\w]+)/g;
10+
const REGEX_TJS_JSDOC = /^-([\w]+)\s([\w-]+)/g;
1111

1212
export function getDefaultArgs(): Args {
1313
return {

0 commit comments

Comments
 (0)