From 1a165be929de22ddb9b860401100da42685cae1d Mon Sep 17 00:00:00 2001 From: David Ortiz Date: Fri, 26 Jan 2018 12:12:11 +0100 Subject: [PATCH] policy: replace enums with oneOfs in the schemas The reason is that this way, we can add a description for each of the options. --- .../policy/caching/apicast-policy.json | 20 +++++++++++++++++-- .../apicast/policy/echo/apicast-policy.json | 14 ++++++++++--- .../policy/headers/apicast-policy.json | 16 +++++++++++++-- .../policy/url_rewriting/apicast-policy.json | 12 +++++++++-- 4 files changed, 53 insertions(+), 9 deletions(-) diff --git a/gateway/src/apicast/policy/caching/apicast-policy.json b/gateway/src/apicast/policy/caching/apicast-policy.json index d437b915d..280043e42 100644 --- a/gateway/src/apicast/policy/caching/apicast-policy.json +++ b/gateway/src/apicast/policy/caching/apicast-policy.json @@ -23,8 +23,24 @@ "properties": { "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." + } + ] } } } diff --git a/gateway/src/apicast/policy/echo/apicast-policy.json b/gateway/src/apicast/policy/echo/apicast-policy.json index cd77dd6b0..62143e16e 100644 --- a/gateway/src/apicast/policy/echo/apicast-policy.json +++ b/gateway/src/apicast/policy/echo/apicast-policy.json @@ -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." + } + ] } } } diff --git a/gateway/src/apicast/policy/headers/apicast-policy.json b/gateway/src/apicast/policy/headers/apicast-policy.json index 97ed938ef..e1a5d041b 100644 --- a/gateway/src/apicast/policy/headers/apicast-policy.json +++ b/gateway/src/apicast/policy/headers/apicast-policy.json @@ -18,8 +18,20 @@ "properties": { "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", diff --git a/gateway/src/apicast/policy/url_rewriting/apicast-policy.json b/gateway/src/apicast/policy/url_rewriting/apicast-policy.json index ef54b21c3..ccc443cbd 100644 --- a/gateway/src/apicast/policy/url_rewriting/apicast-policy.json +++ b/gateway/src/apicast/policy/url_rewriting/apicast-policy.json @@ -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",