Skip to content

Commit

Permalink
feat: use gioConfig.banner.text as description by default
Browse files Browse the repository at this point in the history
So that the plugin's json schema is compatible with the 2 json-schema components. I add some capabilities to this one.
  • Loading branch information
ThibaudAV committed Jun 27, 2023
1 parent 810514b commit 6dec123
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,8 @@ export class GvSchemaFormControl extends UpdateAfterBrowser(LitElement) {
element.type = 'password';
}

if (this.control.description) {
element.description = this.control.description;
if (this.control.description || this.control.gioConfig?.banner) {
element.description = this.control.gioConfig?.banner?.text ?? this.control.description;
}

if (placeholder != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { makeStory } from '../../../testing/lib/make-story';
import mixed from '../../../testing/resources/schemas/mixed.json';
import htmlToJson from '../../../testing/resources/schemas/html-to-json.json';
import httpConnector from '../../../testing/resources/schemas/http-connector.json';
import policyCache from '../../../testing/resources/schemas/policy-cache.json';
import { fetch } from 'whatwg-fetch';
import grammar from '../../../testing/resources/el-grammar.json';
import resourceCacheRedis from '../../../testing/resources/schemas/resource-cache-redis.json';
Expand Down Expand Up @@ -133,6 +134,10 @@ export const HttpConnector = makeStory(conf, {
items: [{ schema: httpConnector }],
});

export const PolicyCache = makeStory(conf, {
items: [{ schema: policyCache }],
});

export const ResourceCacheRedis = makeStory(conf, {
items: [{ schema: resourceCacheRedis, 'has-footer': true }],
});
Expand Down
45 changes: 39 additions & 6 deletions testing/resources/schemas/policy-cache.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"id": "urn:jsonschema:io:gravitee:policy:cache:configuration:CachePolicyConfiguration",
"additionalProperties": false,
"properties": {
"cacheName": {
"title": "Cache name",
Expand All @@ -9,32 +10,64 @@
"x-schema-form": {
"event": {
"name": "fetch-resources",
"types": ["cache"]
"regexTypes": "^cache"
}
}
},
"key": {
"title": "Key",
"description": "The key used to store the element (support EL).",
"type": "string"
"description": "The key used to store the element (Support EL).",
"type": "string",
"x-schema-form": {
"expression-language": true
}
},
"timeToLiveSeconds": {
"title": "Time to live (in seconds)",
"default": 600,
"description": "Time to live of the element put in cache (Default to 10 minutes).",
"type": "integer"
},
"methods": {
"title": "Methods to cache",
"description": "Select which method you want to cache.",
"type": "array",
"default": ["GET", "OPTIONS", "HEAD"],
"items": {
"type": "string",
"enum": ["CONNECT", "DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT", "TRACE"]
}
},
"responseCondition": {
"title": "Response Condition",
"description": "(Support EL)",
"type": "string",
"x-schema-form": {
"expression-language": true
},
"gioConfig": {
"banner": {
"title": "Response Condition",
"text": "Add an extra condition (with Expression Language) based on the response to activate cache.<br>For example use <strong>{#upstreamResponse.status == 200}</strong> to only cache 200 responses status. By default, 2xx only are cached.<br> \uD83D\uDEA8 <code>upstreamResponse.content</code> is not supported."
}
}
},
"useResponseCacheHeaders": {
"title": "Use response headers",
"description": "Time to live based on 'Cache-Control' and / or 'Expires' headers from response.",
"type": "boolean"
},
"scope": {
"title": "Scope",
"description": "Cached response can be set for a single consumer (application) or for all consumers.<br><strong>WARNING:</strong> Please be aware that by using an \"API\" scope, data will be shared between all consumers!",
"type": "string",
"default": "APPLICATION",
"enum": ["API", "APPLICATION"]
"enum": ["API", "APPLICATION"],
"gioConfig": {
"banner": {
"title": "Scope",
"text": "Cached response can be set for a single consumer (application) or for all consumers.<br><strong>WARNING:</strong> Please be aware that by using an \"API\" scope, data will be shared between all consumers!"
}
}
}
},
"required": ["cacheName", "timeToLiveSeconds"]
Expand Down

0 comments on commit 6dec123

Please sign in to comment.