Skip to content

Commit 6963d27

Browse files
committed
get paths from sitemap
1 parent afb6906 commit 6963d27

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

changelog.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,34 @@
11
import yaml
22
import argparse
3+
import urllib.request
4+
import xmltodict
5+
36

47
def main(args):
58

9+
with urllib.request.urlopen('http://developer.devrev.ai/sitemap.xml') as f:
10+
xml_data = f.read().decode('utf-8')
11+
612
if args.beta:
7-
spec_src = './fern/apis/beta/openapi-beta.yaml'
13+
version = 'beta'
14+
elif args.public:
15+
version = 'public'
16+
17+
data_dict = xmltodict.parse(xml_data)
18+
urls = []
19+
for i in data_dict['urlset']['url']:
20+
loc = i['loc'].replace('https://developer.devrev.ai', '')
21+
if '/api-reference' in loc and loc.startswith(f"/{version}"):
22+
path = loc.split('/')
23+
link = f"- [{path[-2]} > {path[-1]}]({loc})"
24+
print(link)
25+
26+
27+
#get_specs(version)
828

9-
get_specs(spec_src)
29+
def get_specs(version):
1030

11-
def get_specs(src):
31+
src = f"./fern/apis/{version}/openapi-beta.yaml"
1232

1333
with open(src, 'r') as s:
1434
spec = yaml.safe_load(s)

0 commit comments

Comments
 (0)