def load_spec(self, spec_url, base_url=None): """Load a Swagger Spec from the given URL :param spec_url: URL to swagger.json :param base_url: TODO: need this? :returns: json spec in dict form """ response = request( self.http_client, spec_url, self.request_headers, ).result() content_type = response.headers.get('content-type', '').lower() if is_yaml(spec_url, content_type): return self.load_yaml(response.text) else: return response.json()
def __init__(self, path): self.path = path self.is_yaml = is_yaml(path)