mirror of
https://github.com/shlinkio/shlink.git
synced 2024-11-27 08:18:24 +03:00
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:
commit
c36e43e249
3 changed files with 82 additions and 29 deletions
31
docs/swagger/definitions/SetShortUrlRedirectRule.json
Normal file
31
docs/swagger/definitions/SetShortUrlRedirectRule.json
Normal 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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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"
|
||||
}]
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue