mirror of
https://github.com/thegeneralist01/twitter-openapi
synced 2026-01-11 23:50: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
|
|
@ -61,10 +61,12 @@ class OpenapiHookBase(HookBase):
|
||||||
def hook(self, value: dict) -> dict:
|
def hook(self, value: dict) -> dict:
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
|
||||||
class OtherHookBase(HookBase):
|
class OtherHookBase(HookBase):
|
||||||
def hook(self) -> tuple[str, dict]:
|
def hook(self) -> tuple[str, dict]:
|
||||||
return "", {}
|
return "", {}
|
||||||
|
|
||||||
|
|
||||||
class SchemasHookBase(HookBase):
|
class SchemasHookBase(HookBase):
|
||||||
def hook(self, value: dict) -> dict:
|
def hook(self, value: dict) -> dict:
|
||||||
return value
|
return value
|
||||||
|
|
@ -118,6 +120,14 @@ class AddSecuritySchemesOnHeader(RequestHookBase):
|
||||||
value["parameters"].extend(param)
|
value["parameters"].extend(param)
|
||||||
return path, value
|
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):
|
class SetResponsesHeader(RequestHookBase):
|
||||||
suffix: str
|
suffix: str
|
||||||
|
|
||||||
|
|
@ -132,6 +142,28 @@ class SetResponsesHeader(RequestHookBase):
|
||||||
return path, value
|
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
|
# OnParameters
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue