Skip to content

Commit f6b0510

Browse files
authored
Merge pull request #63 from krakend/dev-v2.9-enterprise
Add new schema for EE 2.9
2 parents c5c066f + 39883e8 commit f6b0510

17 files changed

+1217
-55
lines changed

test/v2.9/all.json

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,15 @@
143143
"content_type": "application/json",
144144
"debug": false,
145145
"template": "abcdef"
146+
},
147+
"modifier/response-body": {
148+
"modifiers": [
149+
{
150+
"upper": {
151+
"field": "surname"
152+
}
153+
}
154+
]
146155
}
147156
}
148157
}
@@ -446,7 +455,10 @@
446455
"ping_period": "54s",
447456
"max_retries": 0,
448457
"backoff_strategy": "exponential",
449-
"disable_otel_metrics": true
458+
"disable_otel_metrics": true,
459+
"subprotocols": [
460+
"streamlit"
461+
]
450462
},
451463
"modifier/response-body-generator": {
452464
"content_type": "application/json",
@@ -1663,6 +1675,12 @@
16631675
"name": "shared_instance",
16641676
"address": "redis:6379"
16651677
}
1678+
],
1679+
"clusters": [
1680+
{
1681+
"name": "shared_redis_cluster",
1682+
"addresses": ["192.168.1.45:6379", "192.168.1.52:6379"]
1683+
}
16661684
]
16671685
},
16681686
"qos/ratelimit/service/redis": {

test/v2.9/modifier/response-body.json

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"description": "response-body",
3+
"target": "https://www.krakend.io/schema/v2.9/modifier/response-body.json",
4+
"tests": [
5+
{
6+
"description": "Operations declared but no actions",
7+
"data": {
8+
"modifiers": []
9+
},
10+
"valid": true
11+
},
12+
{
13+
"description": "happy case",
14+
"data": {
15+
"modifiers": [
16+
{
17+
"regexp": {
18+
"field": "data.credit_card",
19+
"find": "(^\\d{4})(.*)",
20+
"replace": "${1}-XXXX"
21+
}
22+
},
23+
{
24+
"literal": {
25+
"field": "surname",
26+
"find": " supu",
27+
"replace": "tupu"
28+
}
29+
},
30+
{
31+
"upper": {
32+
"@comment": "We want all surnames uppercased, like SMITH",
33+
"field": "surname"
34+
}
35+
},
36+
{
37+
"lower": {
38+
"field": "dawsesad"
39+
}
40+
},
41+
{
42+
"trim": {
43+
"field": "surnaasdffdsdfsme",
44+
"find": "A"
45+
}
46+
}
47+
]
48+
},
49+
"valid": true
50+
}
51+
]
52+
}

test/v2.9/qos/service_redis_ratelimit.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"description": "All options",
1212
"data": {
1313
"@comment": "Hello",
14-
"connection_pool": "shared_instance",
14+
"connection_name": "shared_instance",
1515
"on_failure_allow": false,
1616
"max_rate": 10,
1717
"capacity": 10,
@@ -26,15 +26,15 @@
2626
{
2727
"description": "Minimum options max_rate",
2828
"data": {
29-
"connection_pool": "shared_instance",
29+
"connection_name": "shared_instance",
3030
"max_rate": 10
3131
},
3232
"valid": true
3333
},
3434
{
3535
"description": "Minimum options client_max_rate",
3636
"data": {
37-
"connection_pool": "shared_instance",
37+
"connection_name": "shared_instance",
3838
"client_max_rate": 10
3939
},
4040
"valid": true
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{
2+
"description": "Backend object test",
3+
"target": "https://www.krakend.io/schema/v2.9/validation/response-json-schema.json",
4+
"tests": [
5+
{
6+
"description": "Missing schema",
7+
"data": {
8+
"error": {
9+
"body": "We couldn't process you request, try again later.",
10+
"status": 401
11+
}
12+
},
13+
"valid": false
14+
},
15+
{
16+
"description": "Valid schema",
17+
"data": {
18+
"schema": {
19+
"$schema": "http://json-schema.org/draft-07/schema#",
20+
"type": "object",
21+
"properties": {
22+
"user": {
23+
"type": "object",
24+
"properties": {
25+
"username": {
26+
"type": "string"
27+
},
28+
"user_id": {
29+
"type": "number"
30+
},
31+
"status": {
32+
"type": "string",
33+
"enum": [
34+
"registered",
35+
"banned"
36+
]
37+
}
38+
},
39+
"required": [
40+
"username",
41+
"user_id"
42+
]
43+
}
44+
},
45+
"required": [
46+
"user"
47+
]
48+
},
49+
"error": {
50+
"body": "We couldn't process you request, try again later.",
51+
"status": 401
52+
}
53+
},
54+
"valid": true
55+
}
56+
]
57+
}

v2.9/backend_extra_config.json

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@
8787
"modifier/request-body-generator": {
8888
"$ref": "modifier/body-generator.json"
8989
},
90+
"modifier/response-body": {
91+
"$ref": "modifier/response-body.json"
92+
},
9093
"modifier/response-body-generator": {
9194
"$ref": "modifier/body-generator.json"
9295
},
@@ -104,12 +107,45 @@
104107
},
105108
"qos/http-cache": {
106109
"title": "Backend Cache",
107-
"description": "Enable in-memory caching for backend responses for as long as its Cache-Control header permits.\n\nSee: https://www.krakend.io/docs/backends/caching/",
110+
"description": "Enable in-memory caching for backend responses for as long as its `Cache-Control` header permits. Only safe methods are cached (GET or HEAD). The final backend URL and the `Vary` headers are used to create the caching key.\n\nSee: https://www.krakend.io/docs/backends/caching/",
108111
"type": "object",
112+
"oneOf": [
113+
{
114+
"required": [
115+
"max_size",
116+
"max_items"
117+
]
118+
},
119+
{
120+
"required": [
121+
"shared"
122+
]
123+
},
124+
{
125+
"maxProperties": 0
126+
}
127+
],
109128
"properties": {
129+
"max_items": {
130+
"title": "Max items",
131+
"description": "Enterprise only. To be released on open source on v2.10. The maximum number of items the LRU cache will store **for this cache bucket** before starting to do evictions. When `max_items` is declared, you must declare `max_size` as well.\n\nSee: https://www.krakend.io/docs/backends/caching/",
132+
"examples": [],
133+
"type": "integer",
134+
"minimum": 1
135+
},
136+
"max_size": {
137+
"title": "Max size",
138+
"description": "Enterprise only. To be released on open source on v2.10. The maximum number of bytes you allow the LRU cache to store **for this cache bucket** before starting to do evictions. This is not the total cache you allow to the system, but the number of bytes you reserve to this backend (or its `shared` neighbours). will store before starting to do evictions. When `max_size` is declared, you must declare `max_items` as well.\n\nSee: https://www.krakend.io/docs/backends/caching/",
139+
"examples": [
140+
104857600,
141+
1048576
142+
],
143+
"type": "integer",
144+
"minimum": 1024
145+
},
110146
"shared": {
111147
"title": "Shared cache",
112-
"description": "The `shared` cache makes that different backend definitions with this flag enabled can reuse the cache. When the `shared` flag is missing or set to false, the backend uses its own cache private context.\n\nSee: https://www.krakend.io/docs/backends/detailed-errors/",
148+
"description": "Allows different backend definitions with this flag set to true to reuse the store between them when the request is the same. Otherwise, each backend uses a private cache context that is not accessible by other endpoints. The cache definition is unique for every backend URL + `Vary` header combination.\n\nSee: https://www.krakend.io/docs/backends/caching/",
113149
"type": "boolean"
114150
}
115151
},
@@ -151,6 +187,9 @@
151187
"validation/cel": {
152188
"$ref": "validation/cel.json"
153189
},
190+
"validation/response-json-schema": {
191+
"$ref": "validation/response-json-schema.json"
192+
},
154193
"workflow": {
155194
"title": "Workflow",
156195
"description": "Enterprise only. A whole new endpoint that is executed within this backend context.",

v2.9/endpoint_extra_config.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@
7272
"modifier/request-body-generator": {
7373
"$ref": "modifier/body-generator.json"
7474
},
75+
"modifier/response-body": {
76+
"$ref": "modifier/response-body.json"
77+
},
7578
"modifier/response-body-generator": {
7679
"$ref": "modifier/body-generator.json"
7780
},
@@ -211,6 +214,9 @@
211214
"description": "apply automatic validations using the JSON Schema vocabulary before the content passes to the backends. The json schema component allows you to define validation rules on the body, type definition, or even validate the fields' values.\n\nSee: https://www.krakend.io/docs/endpoints/json-schema/",
212215
"type": "object"
213216
},
217+
"validation/response-json-schema": {
218+
"$ref": "validation/response-json-schema.json"
219+
},
214220
"websocket": {
215221
"$ref": "websocket.json"
216222
}

0 commit comments

Comments
 (0)