Skip to content
This repository was archived by the owner on Nov 22, 2024. It is now read-only.

Commit afa8cc0

Browse files
committed
add openapi support, added tuna for testing
1 parent 3af9aa8 commit afa8cc0

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

Makefile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ TWINE = twine
77
EMAIL = "mahtin@mahtin.com"
88
NAME = "cloudflare"
99

10+
OPENAPI_URL = "https://github.com/cloudflare/api-schemas/raw/main/openapi.json"
11+
1012
#all: README.rst CHANGELOG.md build
1113
all: CHANGELOG.md build
1214

@@ -103,6 +105,33 @@ api:
103105
egrep '; deprecated' < $$tmp.2 | while read cmd x deprecated deprecated_date ; do egrep "$$cmd" $$tmp.4 | sed -e "s/$$/ ; deprecated $$deprecated_date/" ; done | sort | uniq ; \
104106
rm $$tmp.?
105107

108+
openapi:
109+
@tmp=/tmp/_$$$$_ ; \
110+
$(PYTHON) -m cli4 --dump | sort > $$tmp.1 ; \
111+
$(PYTHON) -m cli4 --openapi $(OPENAPI_URL) | sed -e 's/^[A-Z][A-Z]* *//' -e 's/?.*//' -e 's/\/:[a-z][A-Za-z_]*/\/:id/g' -e 's/\/:[a-z][A-Za-z_]*}/\/:id/g' -e 's/:id\/:id/:id/' -e 's/\/:id$$//' -e 's/\/:id$$//' -e 's/\/:id ;/ ;/' -e 's/\/$$//' | sort -u > $$tmp.2 ; \
112+
egrep -v '; deprecated' < $$tmp.2 | diff $$tmp.1 - > $$tmp.3 ; \
113+
echo "In code:" ; \
114+
egrep '< ' < $$tmp.3 | sed -e 's/< / /' | sort | tee $$tmp.4 ; \
115+
echo "In docs:" ; \
116+
egrep '> ' < $$tmp.3 | sed -e 's/> / /' | sort | sed -e "s/\//self.add('AUTH', '/" -e "s/$$/'\)/" -e "s/\/:id\//', '/g" ; \
117+
echo "Deprecated:" ; \
118+
egrep '; deprecated' < $$tmp.2 | while read cmd x deprecated deprecated_date ; do egrep "$$cmd" $$tmp.4 | sed -e "s/$$/ ; deprecated $$deprecated_date/" ; done | sort | uniq ; \
119+
rm $$tmp.?
120+
121+
TUNA_CLI4_TEST_COMMAND = "/ips"
122+
TUNA_CLI4_TEST_COMMAND = "--openapi http://localhost/~martin/openapi.json"
123+
TUNA_CLI4_TEST_COMMAND = "--api"
124+
TUNA_CLI4_TEST_COMMAND = "--openapi $(OPENAPI_URL)"
125+
126+
tuna:
127+
@tmp=/tmp/_$$$$_ ; \
128+
$(PYTHON) -X importtime -m cli4 $(TUNA_CLI4_TEST_COMMAND) > /dev/null 2> $$tmp.1 ; \
129+
tuna $$tmp.1 2> /dev/null & \
130+
tunapid=$$! ; \
131+
sleep 1 ; \
132+
kill $$tunapid ; \
133+
rm $$tmp.?
134+
106135
clean:
107136
rm -rf build
108137
rm -rf dist

0 commit comments

Comments
 (0)