1
Fork 0
mirror of https://github.com/thegeneralist01/twitter-openapi synced 2026-01-11 23:50:26 +01:00

update hook

Signed-off-by: ふぁ <yuki@yuki0311.com>
This commit is contained in:
ふぁ 2023-05-12 11:28:19 +09:00
parent cf65ef4e55
commit a677f61bea
No known key found for this signature in database
GPG key ID: 83A8A5E74872A8AA
2 changed files with 25 additions and 9 deletions

View file

@ -129,22 +129,24 @@ class AddParametersOnParameters(RequestHookBase):
def hook(self, path: str, value: dict):
path, value = super().hook(path, value)
for key in self.PLACEHOLDER[self.path_name].keys():
example = json.dumps(self.PLACEHOLDER[self.path_name][key])
data = self.PLACEHOLDER[self.path_name]
for key in data.keys():
if self.schemaType == "string":
example = json.dumps(data[key])
schema = {
"type": "string",
"default": example,
"example": example,
}
elif self.schemaType == "object":
example = json.dumps(data[key])
schema = {
"type": "object",
"default": example,
"example": example,
}
else:
schema = self.placeholder_to_yaml(example)
schema = self.placeholder_to_yaml(data[key])
value["parameters"].append(
{
"name": key,
@ -178,14 +180,14 @@ class AddParametersOnBody(RequestHookBase):
data = self.PLACEHOLDER[self.path_name]
if self.schemaType == "string":
example = json.dumps(self.PLACEHOLDER[self.path_name])
example = json.dumps(data)
schema = {
"type": "string",
"default": example,
"example": example,
}
elif self.schemaType == "object":
example = json.dumps(self.PLACEHOLDER[self.path_name])
example = json.dumps(data)
schema = {
"type": "object",
"default": example,