Skip to content

Commit e773911

Browse files
committed
Improve status schemas
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
1 parent 5ef5fc9 commit e773911

11 files changed

Lines changed: 897 additions & 1 deletion
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"title": "RFC 9110 HTTP Client Error Status Code",
4+
"description": "An HTTP 4xx client error status code indicating the request contains bad syntax or cannot be fulfilled",
5+
"$comment": "https://www.rfc-editor.org/rfc/rfc9110#section-15.4",
6+
"examples": [ 400, 404, 403 ],
7+
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
8+
"type": "integer",
9+
"maximum": 499,
10+
"minimum": 400
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"title": "RFC 9110 HTTP Informational Status Code",
4+
"description": "An HTTP 1xx informational status code indicating an interim response",
5+
"$comment": "https://www.rfc-editor.org/rfc/rfc9110#section-15.1",
6+
"examples": [ 100, 101, 102 ],
7+
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
8+
"type": "integer",
9+
"maximum": 199,
10+
"minimum": 100
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"title": "RFC 9110 HTTP Redirection Status Code",
4+
"description": "An HTTP 3xx redirection status code indicating further action needs to be taken to complete the request",
5+
"$comment": "https://www.rfc-editor.org/rfc/rfc9110#section-15.3",
6+
"examples": [ 301, 302, 304 ],
7+
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
8+
"type": "integer",
9+
"maximum": 399,
10+
"minimum": 300
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"title": "RFC 9110 HTTP Server Error Status Code",
4+
"description": "An HTTP 5xx server error status code indicating the server failed to fulfill a valid request",
5+
"$comment": "https://www.rfc-editor.org/rfc/rfc9110#section-15.5",
6+
"examples": [ 500, 502, 503 ],
7+
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
8+
"type": "integer",
9+
"maximum": 599,
10+
"minimum": 500
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"title": "RFC 9110 HTTP Successful Status Code",
4+
"description": "An HTTP 2xx successful status code indicating the request was successfully received, understood, and accepted",
5+
"$comment": "https://www.rfc-editor.org/rfc/rfc9110#section-15.2",
6+
"examples": [ 200, 201, 204 ],
7+
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
8+
"type": "integer",
9+
"maximum": 299,
10+
"minimum": 200
11+
}
Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
{
2+
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
3+
"target": "../../../schemas/ietf/http/status-client-error.json",
4+
"tests": [
5+
{
6+
"description": "Invalid type - string",
7+
"data": "404",
8+
"valid": false
9+
},
10+
{
11+
"description": "Invalid type - boolean",
12+
"data": false,
13+
"valid": false
14+
},
15+
{
16+
"description": "Invalid type - null",
17+
"data": null,
18+
"valid": false
19+
},
20+
{
21+
"description": "Invalid type - array",
22+
"data": [],
23+
"valid": false
24+
},
25+
{
26+
"description": "Invalid type - object",
27+
"data": {},
28+
"valid": false
29+
},
30+
{
31+
"description": "Invalid type - float",
32+
"data": 404.5,
33+
"valid": false
34+
},
35+
{
36+
"description": "Below minimum (399)",
37+
"data": 399,
38+
"valid": false
39+
},
40+
{
41+
"description": "Above maximum (500)",
42+
"data": 500,
43+
"valid": false
44+
},
45+
{
46+
"description": "400 Bad Request",
47+
"data": 400,
48+
"valid": true
49+
},
50+
{
51+
"description": "401 Unauthorized",
52+
"data": 401,
53+
"valid": true
54+
},
55+
{
56+
"description": "402 Payment Required",
57+
"data": 402,
58+
"valid": true
59+
},
60+
{
61+
"description": "403 Forbidden",
62+
"data": 403,
63+
"valid": true
64+
},
65+
{
66+
"description": "404 Not Found",
67+
"data": 404,
68+
"valid": true
69+
},
70+
{
71+
"description": "405 Method Not Allowed",
72+
"data": 405,
73+
"valid": true
74+
},
75+
{
76+
"description": "406 Not Acceptable",
77+
"data": 406,
78+
"valid": true
79+
},
80+
{
81+
"description": "407 Proxy Authentication Required",
82+
"data": 407,
83+
"valid": true
84+
},
85+
{
86+
"description": "408 Request Timeout",
87+
"data": 408,
88+
"valid": true
89+
},
90+
{
91+
"description": "409 Conflict",
92+
"data": 409,
93+
"valid": true
94+
},
95+
{
96+
"description": "410 Gone",
97+
"data": 410,
98+
"valid": true
99+
},
100+
{
101+
"description": "411 Length Required",
102+
"data": 411,
103+
"valid": true
104+
},
105+
{
106+
"description": "412 Precondition Failed",
107+
"data": 412,
108+
"valid": true
109+
},
110+
{
111+
"description": "413 Content Too Large",
112+
"data": 413,
113+
"valid": true
114+
},
115+
{
116+
"description": "414 URI Too Long",
117+
"data": 414,
118+
"valid": true
119+
},
120+
{
121+
"description": "415 Unsupported Media Type",
122+
"data": 415,
123+
"valid": true
124+
},
125+
{
126+
"description": "416 Range Not Satisfiable",
127+
"data": 416,
128+
"valid": true
129+
},
130+
{
131+
"description": "417 Expectation Failed",
132+
"data": 417,
133+
"valid": true
134+
},
135+
{
136+
"description": "418 (Unused)",
137+
"data": 418,
138+
"valid": true
139+
},
140+
{
141+
"description": "421 Misdirected Request",
142+
"data": 421,
143+
"valid": true
144+
},
145+
{
146+
"description": "422 Unprocessable Content",
147+
"data": 422,
148+
"valid": true
149+
},
150+
{
151+
"description": "426 Upgrade Required",
152+
"data": 426,
153+
"valid": true
154+
},
155+
{
156+
"description": "Unassigned code (419)",
157+
"data": 419,
158+
"valid": true
159+
},
160+
{
161+
"description": "Unassigned code (450)",
162+
"data": 450,
163+
"valid": true
164+
},
165+
{
166+
"description": "Maximum valid (499)",
167+
"data": 499,
168+
"valid": true
169+
}
170+
]
171+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
{
2+
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
3+
"target": "../../../schemas/ietf/http/status-informational.json",
4+
"tests": [
5+
{
6+
"description": "Invalid type - string",
7+
"data": "100",
8+
"valid": false
9+
},
10+
{
11+
"description": "Invalid type - boolean",
12+
"data": true,
13+
"valid": false
14+
},
15+
{
16+
"description": "Invalid type - null",
17+
"data": null,
18+
"valid": false
19+
},
20+
{
21+
"description": "Invalid type - array",
22+
"data": [],
23+
"valid": false
24+
},
25+
{
26+
"description": "Invalid type - object",
27+
"data": {},
28+
"valid": false
29+
},
30+
{
31+
"description": "Invalid type - float",
32+
"data": 100.5,
33+
"valid": false
34+
},
35+
{
36+
"description": "Below minimum (99)",
37+
"data": 99,
38+
"valid": false
39+
},
40+
{
41+
"description": "Above maximum (200)",
42+
"data": 200,
43+
"valid": false
44+
},
45+
{
46+
"description": "100 Continue",
47+
"data": 100,
48+
"valid": true
49+
},
50+
{
51+
"description": "101 Switching Protocols",
52+
"data": 101,
53+
"valid": true
54+
},
55+
{
56+
"description": "Unassigned code (102)",
57+
"data": 102,
58+
"valid": true
59+
},
60+
{
61+
"description": "Unassigned code (150)",
62+
"data": 150,
63+
"valid": true
64+
},
65+
{
66+
"description": "Maximum valid (199)",
67+
"data": 199,
68+
"valid": true
69+
}
70+
]
71+
}

0 commit comments

Comments
 (0)