From 051eb12a8d77e814d6eabd59a005feed22966e24 Mon Sep 17 00:00:00 2001 From: donnd-t Date: Fri, 12 Nov 2021 14:29:08 +1100 Subject: [PATCH] support for swagger v2 body specs --- lib/core/swagger.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/core/swagger.py b/lib/core/swagger.py index 3f0f2e587..700df9b89 100644 --- a/lib/core/swagger.py +++ b/lib/core/swagger.py @@ -29,8 +29,15 @@ class Operation: return list(filter(lambda p: (p["in"] in types), self.parameters())) def bodyRef(self): + # OpenAPI v3 if "requestBody" in self.props: 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 # header injection is not currently supported