def __init__(self, url=None, spec=None):
    self.url = url
    self.headers = {}
    self.querystring_params = {}
    self.body_params = {}
    self.body_json_params = {}
    self.options = {}
    self.should_exit = False
    self.root = Node('root')
    if spec:
        if (not self.url):
            schemes = spec.get('schemes')
            scheme = (schemes[0] if schemes else 'https')
            self.url = (((scheme + '://') + spec.get('host', 'http://localhost:8000')) + spec.get('basePath', ''))
        base_path_tokens = list(filter((lambda s: s), spec.get('basePath', '').split('/')))
        paths = spec.get('paths')
        if paths:
            for path in paths:
                path_tokens = (base_path_tokens + list(filter((lambda s: s), path.split('/'))))
                if (path == '/'):
                    path_tokens.insert(len(base_path_tokens), '/')
                elif (path[(- 1)] == '/'):
                    path_tokens[(- 1)] = (path_tokens[(- 1)] + '/')
                self.root.add_path(*path_tokens)
                endpoint = paths[path]
                for (method, info) in endpoint.items():
                    params = info.get('parameters')
                    if params:
                        for param in params:
                            if param.get('$ref'):
                                for section in param.get('$ref').split('/'):
                                    param = (param.get(section) if (not (section == '#')) else spec)
                            if (param.get('in') != 'path'):
                                full_path = (path_tokens + [param['name']])
                                self.root.add_path(*full_path, node_type='file')
    elif (not self.url):
        self.url = 'http://localhost:8000'
def __init__(self, url=None, spec=None):
    self.url = url
    self.headers = {}
    self.querystring_params = {}
    self.body_params = {}
    self.body_json_params = {}
    self.options = {}
    self.should_exit = False
    self.root = Node('root')
    if spec:
        if (not self.url):
            schemes = spec.get('schemes')
            scheme = (schemes[0] if schemes else 'https')
            self.url = (((scheme + '://') + spec.get('host', 'http://localhost:8000')) + spec.get('basePath', ))
        base_path_tokens = list(filter((lambda s: s), spec.get('basePath', ).split('/')))
        paths = spec.get('paths')
        if paths:
            for path in paths:
                path_tokens = (base_path_tokens + list(filter((lambda s: s), path.split('/'))))
                if (path == '/'):
                    path_tokens.insert(len(base_path_tokens), '/')
                elif (path[(- 1)] == '/'):
                    path_tokens[(- 1)] = (path_tokens[(- 1)] + '/')
                self.root.add_path(*path_tokens)
                endpoint = paths[path]
                for (method, info) in endpoint.items():
                    params = info.get('parameters')
                    if params:
                        for param in params:
                            if param.get('$ref'):
                                for section in param.get('$ref').split('/'):
                                    param = (param.get(section) if (not (section == '#')) else spec)
                            if (param.get('in') != 'path'):
                                full_path = (path_tokens + [param['name']])
                                self.root.add_path(*full_path, node_type='file')
    elif (not self.url):
        self.url = 'http://localhost:8000'