support for swagger v2 body specs

This commit is contained in:
donnd-t 2021-11-12 14:29:08 +11:00
parent 35cb10fd69
commit 051eb12a8d

View File

@ -29,8 +29,15 @@ class Operation:
return list(filter(lambda p: (p["in"] in types), self.parameters())) return list(filter(lambda p: (p["in"] in types), self.parameters()))
def bodyRef(self): def bodyRef(self):
# OpenAPI v3
if "requestBody" in self.props: if "requestBody" in self.props:
return self.props["requestBody"]["content"]["application/json"]["schema"]["$ref"] return self.props["requestBody"]["content"]["application/json"]["schema"]["$ref"]
# swagger v2
elif "parameters" in self.props:
inParameters = self.parametersForTypes(["body"])
if not isinstance(inParameters, list) or len(inParameters) < 1:
return None
return inParameters[0]["schema"]["$ref"]
return None return None
# header injection is not currently supported # header injection is not currently supported