Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
50 lines (42 loc) · 1.33 KB

File metadata and controls

50 lines (42 loc) · 1.33 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
def link_sorting_key(link_item):
keys, link = link_item
action_priority = {
'': 0, 'get': 0,
'post': 1,
'put': 2,
'patch': 3,
'delete': 4
}.get(link.action, 5)
return (link.url, action_priority)
def get_links_from_document(node, keys=()):
links = []
for key, link in getattr(node, 'links', {}).items():
# Get all the resources at this level
index = keys + (key,)
links.append((index, link))
for key, child in getattr(node, 'data', {}).items():
# Descend into any nested structures.
index = keys + (key,)
links.extend(get_links_from_document(child, index))
return sorted(links, key=link_sorting_key)
def get_method(link):
method = link.action.lower()
if not method:
method = 'get'
return method
def get_encoding(link):
encoding = link.encoding
has_body = any([get_location(link, field) in ('form', 'body') for field in link.fields])
if not encoding and has_body:
encoding = 'application/json'
elif encoding and not has_body:
encoding = ''
return encoding
def get_location(link, field):
location = field.location
if not location:
if get_method(link) in ('get', 'delete'):
location = 'query'
else:
location = 'form'
return location
Morty Proxy This is a proxified and sanitized view of the page, visit original site.