Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ec803cf

Browse files
author
Phil Sturgeon
committed
Remove $id and id from the root as well as $schema
1 parent 8abb985 commit ec803cf

File tree

3 files changed

+171
-1
lines changed

3 files changed

+171
-1
lines changed

‎index.js‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,18 @@ function convert(schema, options) {
1515
schema = JSON.parse(JSON.stringify(schema));
1616
}
1717

18-
deleteschema['$schema'];
18+
schema=removeRootKeywords(schema);
1919
schema = convertSchema(schema);
2020

2121
return schema;
2222
}
2323

24+
function removeRootKeywords(schema) {
25+
delete schema['$schema'];
26+
delete schema['id'];
27+
return schema;
28+
}
29+
2430
function convertSchema(schema) {
2531
let i = 0;
2632
let j = 0;
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
{
2+
"id": "http://some.site.somewhere/entry-schema#",
3+
"$schema": "http://json-schema.org/draft-06/schema#",
4+
"description": "schema for an fstab entry",
5+
"type": "object",
6+
"required": [ "storage" ],
7+
"properties": {
8+
"storage": {
9+
"type": "object",
10+
"oneOf": [
11+
{ "$ref": "#/definitions/diskDevice" },
12+
{ "$ref": "#/definitions/diskUUID" },
13+
{ "$ref": "#/definitions/nfs" },
14+
{ "$ref": "#/definitions/tmpfs" }
15+
]
16+
},
17+
"fstype": {
18+
"enum": [ "ext3", "ext4", "btrfs" ]
19+
},
20+
"options": {
21+
"type": "array",
22+
"minItems": 1,
23+
"items": { "type": "string" },
24+
"uniqueItems": true
25+
},
26+
"readonly": { "type": "boolean" }
27+
},
28+
"definitions": {
29+
"diskDevice": {
30+
"properties": {
31+
"type": { "enum": [ "disk" ] },
32+
"device": {
33+
"type": "string",
34+
"pattern": "^/dev/[^/]+(/[^/]+)*$"
35+
}
36+
},
37+
"required": [ "type", "device" ],
38+
"additionalProperties": false
39+
},
40+
"diskUUID": {
41+
"properties": {
42+
"type": { "enum": [ "disk" ] },
43+
"label": {
44+
"type": "string",
45+
"pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$"
46+
}
47+
},
48+
"required": [ "type", "label" ],
49+
"additionalProperties": false
50+
},
51+
"nfs": {
52+
"properties": {
53+
"type": { "enum": [ "nfs" ] },
54+
"remotePath": {
55+
"type": "string",
56+
"pattern": "^(/[^/]+)+$"
57+
},
58+
"server": {
59+
"type": "string",
60+
"oneOf": [
61+
{ "format": "hostname" },
62+
{ "format": "ipv4" },
63+
{ "format": "ipv6" }
64+
]
65+
}
66+
},
67+
"required": [ "type", "server", "remotePath" ],
68+
"additionalProperties": false
69+
},
70+
"tmpfs": {
71+
"properties": {
72+
"type": { "enum": [ "tmpfs" ] },
73+
"sizeInMB": {
74+
"type": "integer",
75+
"minimum": 16,
76+
"maximum": 512
77+
}
78+
},
79+
"required": [ "type", "sizeInMB" ],
80+
"additionalProperties": false
81+
}
82+
}
83+
}

‎test/schemas/example2/openapi.json‎

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
{
2+
"description": "schema for an fstab entry",
3+
"type": "object",
4+
"required": [ "storage" ],
5+
"properties": {
6+
"storage": {
7+
"type": "object",
8+
"oneOf": [
9+
{ "$ref": "#/definitions/diskDevice" },
10+
{ "$ref": "#/definitions/diskUUID" },
11+
{ "$ref": "#/definitions/nfs" },
12+
{ "$ref": "#/definitions/tmpfs" }
13+
]
14+
},
15+
"fstype": {
16+
"enum": [ "ext3", "ext4", "btrfs" ]
17+
},
18+
"options": {
19+
"type": "array",
20+
"minItems": 1,
21+
"items": { "type": "string" },
22+
"uniqueItems": true
23+
},
24+
"readonly": { "type": "boolean" }
25+
},
26+
"definitions": {
27+
"diskDevice": {
28+
"properties": {
29+
"type": { "enum": [ "disk" ] },
30+
"device": {
31+
"type": "string",
32+
"pattern": "^/dev/[^/]+(/[^/]+)*$"
33+
}
34+
},
35+
"required": [ "type", "device" ],
36+
"additionalProperties": false
37+
},
38+
"diskUUID": {
39+
"properties": {
40+
"type": { "enum": [ "disk" ] },
41+
"label": {
42+
"type": "string",
43+
"pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$"
44+
}
45+
},
46+
"required": [ "type", "label" ],
47+
"additionalProperties": false
48+
},
49+
"nfs": {
50+
"properties": {
51+
"type": { "enum": [ "nfs" ] },
52+
"remotePath": {
53+
"type": "string",
54+
"pattern": "^(/[^/]+)+$"
55+
},
56+
"server": {
57+
"type": "string",
58+
"oneOf": [
59+
{ "format": "hostname" },
60+
{ "format": "ipv4" },
61+
{ "format": "ipv6" }
62+
]
63+
}
64+
},
65+
"required": [ "type", "server", "remotePath" ],
66+
"additionalProperties": false
67+
},
68+
"tmpfs": {
69+
"properties": {
70+
"type": { "enum": [ "tmpfs" ] },
71+
"sizeInMB": {
72+
"type": "integer",
73+
"minimum": 16,
74+
"maximum": 512
75+
}
76+
},
77+
"required": [ "type", "sizeInMB" ],
78+
"additionalProperties": false
79+
}
80+
}
81+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /