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 91bcf26 commit 156f20f
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 5 deletions.
19 changes: 18 additions & 1 deletion gateway/src/apicast/policy/caching/apicast-policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,24 @@
"caching_type": {
"description": "Caching mode",
"type": "string",
"enum": ["resilient", "strict", "allow", "none"]
"oneOf": [
{
"const": "resilient",
"description": "Authorize according to last request when backend is down."
},
{
"const": "strict",
"description": "It only caches authorized calls."
},
{
"const": "allow",
"description": "When backend is down, allow everything unless seen before and denied."
},
{
"const": "none",
"description": "Disables caching."
}
]
}
}
}
Expand Down
13 changes: 11 additions & 2 deletions gateway/src/apicast/policy/echo/apicast-policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,18 @@
"type": "integer"
},
"exit": {
"description": "Exit mode. 'request' interrupts the processing of the request, 'phase' only skips the rewrite phase.",
"description": "Exit mode",
"type": "string",
"enum": ["request", "phase"]
"oneOf": [
{
"const": "request",
"description": "Interrupts the processing of the request."
},
{
"const": "set",
"description": "Only skips the rewrite phase."
}
]
}
}
}
Expand Down
15 changes: 14 additions & 1 deletion gateway/src/apicast/policy/headers/apicast-policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,20 @@
"op": {
"description": "Operation to be applied",
"type": "string",
"enum": ["add", "set", "push"]
"oneOf": [
{
"const": "add",
"description": "Adds a value to an existing header."
},
{
"const": "set",
"description": "Creates the header when not set, replaces its value when set."
},
{
"const": "push",
"description": "Creates the header when not set, adds the value when set."
}
]
},
"header": {
"description": "Header to be modified",
Expand Down
11 changes: 10 additions & 1 deletion gateway/src/apicast/policy/url_rewriting/apicast-policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,16 @@
"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 156f20f

Please sign in to comment.