mirror of
https://github.com/thegeneralist01/twitter-openapi
synced 2026-01-11 15:40:26 +01:00
add AddPathQueryIdOnParameters
Signed-off-by: ふぁ <yuki@yuki0311.com>
This commit is contained in:
parent
7706204624
commit
68664c581f
1 changed files with 37 additions and 5 deletions
|
|
@ -58,15 +58,17 @@ class HookBase:
|
|||
|
||||
|
||||
class OpenapiHookBase(HookBase):
|
||||
def hook(self, value: dict)->dict:
|
||||
def hook(self, value: dict) -> dict:
|
||||
return value
|
||||
|
||||
|
||||
class OtherHookBase(HookBase):
|
||||
def hook(self)->tuple[str, dict]:
|
||||
return "", {}
|
||||
def hook(self) -> tuple[str, dict]:
|
||||
return "", {}
|
||||
|
||||
|
||||
class SchemasHookBase(HookBase):
|
||||
def hook(self, value: dict)->dict:
|
||||
def hook(self, value: dict) -> dict:
|
||||
return value
|
||||
|
||||
|
||||
|
|
@ -78,7 +80,7 @@ class RequestHookBase(HookBase):
|
|||
super().__init__()
|
||||
self.split = split
|
||||
|
||||
def hook(self, path: str, value: dict)->tuple[str, dict]:
|
||||
def hook(self, path: str, value: dict) -> tuple[str, dict]:
|
||||
value["parameters"] = value.get("parameters", [])
|
||||
self.path_name = "/".join(path.split("/")[self.split :])
|
||||
return path, value
|
||||
|
|
@ -118,6 +120,14 @@ class AddSecuritySchemesOnHeader(RequestHookBase):
|
|||
value["parameters"].extend(param)
|
||||
return path, value
|
||||
|
||||
|
||||
class ReplaceQueryIdPlaceholder(RequestHookBase):
|
||||
def hook(self, path: str, value: dict):
|
||||
path, value = super().hook(path, value)
|
||||
new = self.PLACEHOLDER[self.path_name]["queryId"]
|
||||
return path.replace(r"{pathQueryId}", new), value
|
||||
|
||||
|
||||
class SetResponsesHeader(RequestHookBase):
|
||||
suffix: str
|
||||
|
||||
|
|
@ -132,6 +142,28 @@ class SetResponsesHeader(RequestHookBase):
|
|||
return path, value
|
||||
|
||||
|
||||
class AddPathQueryIdOnParameters(RequestHookBase):
|
||||
def __init__(self, split: str = 1):
|
||||
super().__init__(split=split)
|
||||
|
||||
def hook(self, path: str, value: dict):
|
||||
path, value = super().hook(path, value)
|
||||
data = self.PLACEHOLDER[self.path_name]
|
||||
value["parameters"].append(
|
||||
{
|
||||
"in": "path",
|
||||
"name": "pathQueryId",
|
||||
"required": True,
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"default": data["queryId"],
|
||||
"example": data["queryId"],
|
||||
},
|
||||
}
|
||||
)
|
||||
return path, value
|
||||
|
||||
|
||||
# OnParameters
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue