Merge pull request #2037 from acelaya-forks/feature/improve-rules-swagger

Define different swagger models for get and set redirect rules
This commit is contained in:
Alejandro Celaya 2024-03-01 08:58:11 +01:00 committed by GitHub
commit c36e43e249
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 82 additions and 29 deletions

View file

@ -0,0 +1,31 @@
{
"type": "object",
"required": ["longUrl", "conditions"],
"properties": {
"longUrl": {
"description": "Long URL to redirect to when this condition matches",
"type": "string"
},
"conditions": {
"description": "List of conditions that need to match in order to consider this rule matches",
"type": "array",
"items": {
"type": "object",
"required": ["type", "matchKey", "matchValue"],
"properties": {
"type": {
"type": "string",
"enum": ["device", "language", "query"],
"description": "The type of the condition, which will condition the logic used to match it"
},
"matchKey": {
"type": ["string", "null"]
},
"matchValue": {
"type": "string"
}
}
}
}
}
}

View file

@ -1,35 +1,13 @@
{
"type": "object",
"required": ["priority", "longUrl", "conditions"],
"required": ["priority"],
"properties": {
"longUrl": {
"description": "Long URL to redirect to when this condition matches",
"type": "string"
},
"priority": {
"description": "Order in which attempting to match the rule. Lower goes first",
"type": "number"
},
"conditions": {
"description": "List of conditions that need to match in order to consider this rule matches",
"type": "array",
"items": {
"type": "object",
"required": ["type", "matchKey", "matchValue"],
"properties": {
"type": {
"type": "string",
"enum": ["device", "language", "query"],
"description": "The type of the condition, which will condition the logic used to match it"
},
"matchKey": {
"type": ["string", "null"]
},
"matchValue": {
"type": "string"
}
}
}
}
}
},
"allOf": [{
"$ref": "./SetShortUrlRedirectRule.json"
}]
}

View file

@ -145,7 +145,7 @@
"Redirect rules"
],
"summary": "Set short URL redirect rules",
"description": "Overwrites redirect rules for a short URL with the ones provided here.",
"description": "Sets redirect rules for a short URL, with priorities matching the order in which they are provided.",
"parameters": [
{
"$ref": "../parameters/version.json"
@ -173,10 +173,54 @@
"redirectRules": {
"type": "array",
"items": {
"$ref": "../definitions/ShortUrlRedirectRule.json"
"$ref": "../definitions/SetShortUrlRedirectRule.json"
}
}
}
},
"example": {
"redirectRules": [
{
"longUrl": "https://example.com/android-en-us",
"conditions": [
{
"type": "device",
"matchValue": "android",
"matchKey": null
},
{
"type": "language",
"matchValue": "en-US",
"matchKey": null
}
]
},
{
"longUrl": "https://example.com/fr",
"conditions": [
{
"type": "language",
"matchValue": "fr",
"matchKey": null
}
]
},
{
"longUrl": "https://example.com/query-foo-bar-hello-world",
"conditions": [
{
"type": "query",
"matchKey": "foo",
"matchValue": "bar"
},
{
"type": "query",
"matchKey": "hello",
"matchValue": "world"
}
]
}
]
}
}
}