Skip to content

Commit

Permalink
policy: replace enums with oneOfs in the schemas
Browse files Browse the repository at this point in the history
The reason is that this way, we can add a description for each of the
options.
  • Loading branch information
davidor committed Jan 26, 2018
1 parent 0ad88b4 commit a4081c3
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 28 deletions.
55 changes: 35 additions & 20 deletions gateway/src/apicast/policy/caching/apicast-policy.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,47 @@
{
"$schema": "http://apicast.io/policy-v1/schema#manifest#",
"name": "Caching policy",
"description":
["Configures a cache for the authentication calls against the 3scale ",
"backend. The 3scale backend can authorize (status code = 200) and deny ",
"(status code = 4xx) calls. When it fails, it returns a 5xx code. ",
"This policy support three kinds of caching: \n",
" - Strict: it only caches authorized calls. Denied and failed calls ",
"invalidate the cache entry.\n",
" - Resilient: caches authorized and denied calls. Failed calls do not ",
"invalidate the cache. This allows us to authorize and deny calls ",
"according to the result of the last request made even when backend is ",
"down.\n",
"- Allow: caches authorized and denied calls. When backend is ",
"unavailable, it will cache an authorization. In practice, this means ",
"that when backend is down _any_ request will be authorized unless last ",
"call to backend for that request returned 'deny' (status code = 4xx). ",
"Make sure to understand the implications of that before using this ",
"mode. It makes sense only in very specific use cases.\n",
"- None: disables caching."],
"description": "Configures a cache for the authentication calls against the 3scale backend",
"version": "0.1",
"configuration": {
"type": "object",
"properties": {
"caching_type": {
"description": "Caching mode",
"type": "string",
"enum": ["resilient", "strict", "allow", "none"]
"oneOf": [
{
"const": "resilient",
"description": [
"Caches authorized and denied calls. Failed calls do not ",
"invalidate the cache. This allows us to authorize and deny ",
"calls according to the result of the last request made even ",
"when backend is down."
]
},
{
"const": "strict",
"description": [
"It only caches authorized calls. Denied and failed calls ",
"invalidate the cache entry."
]
},
{
"const": "allow",
"description": [
"Caches authorized and denied calls. When backend is ",
"unavailable, it will cache an authorization. In practice, this ",
"means that when backend is down _any_ request will be ",
"authorized unless last call to backend for that request ",
"returned 'deny' (status code = 4xx).\n",
"Make sure to understand the implications of that before using this ",
"mode. It makes sense only in very specific use cases."
]
},
{
"const": "none",
"description": "Disables caching."
}
]
}
}
}
Expand Down
14 changes: 11 additions & 3 deletions gateway/src/apicast/policy/echo/apicast-policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,17 @@
"type": "integer"
},
"exit": {
"description": "Exit mode. 'request' interrupts the processing of the request, 'phase' only skips the rewrite phase.",
"type": "string",
"enum": ["request", "phase"]
"description": "Exit mode",
"oneOf": [
{
"const": "request",
"description": "Interrupts the processing of the request."
},
{
"const": "set",
"description": "Only skips the rewrite phase."
}
]
}
}
}
Expand Down
32 changes: 29 additions & 3 deletions gateway/src/apicast/policy/headers/apicast-policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,35 @@
"type": "object",
"properties": {
"op": {
"description": "Operation to be applied",
"type": "string",
"enum": ["add", "set", "push"]
"oneOf": [
{
"const": "add",
"description": [
"When the header is not set, it does nothing.\n",
"When the header is set, it creates a new header with the ",
"same name and the given value."
]
},
{
"const": "set",
"description": [
"When the header is not set, creates it with the given ",
"value.\n",
"When the header is set, replaces its value with the ",
"given one.\n",
"Deletes a header when the value is ''."
]
},
{
"const": "push",
"description": [
"When the header is not set, creates it with the given ",
"value.\n",
"When the header is set, it creates a new header with the ",
"same name and the given value."
]
}
]
},
"header": {
"description": "Header to be modified",
Expand Down
12 changes: 10 additions & 2 deletions gateway/src/apicast/policy/url_rewriting/apicast-policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,16 @@
"properties": {
"op": {
"description": "Operation to be applied (sub or gsub)",
"type": "string",
"enum": ["sub", "gsub"]
"oneOf": [
{
"const": "sub",
"description": "Substitutes the first match of the regex applied."
},
{
"const": "gsub",
"description": "Substitutes all the matches of the regex applied."
}
]
},
"regex": {
"description": "Regular expression to be matched",
Expand Down

0 comments on commit a4081c3

Please sign in to comment.