Skip to content

Commit

Permalink
add openapi support, added tuna for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
mahtin committed Nov 24, 2022
1 parent 3af9aa8 commit afa8cc0
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ TWINE = twine
EMAIL = "[email protected]"
NAME = "cloudflare"

OPENAPI_URL = "https://github.com/cloudflare/api-schemas/raw/main/openapi.json"

#all: README.rst CHANGELOG.md build
all: CHANGELOG.md build

Expand Down Expand Up @@ -103,6 +105,33 @@ api:
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 ; \
rm $$tmp.?

openapi:
@tmp=/tmp/_$$$$_ ; \
$(PYTHON) -m cli4 --dump | sort > $$tmp.1 ; \
$(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 ; \
egrep -v '; deprecated' < $$tmp.2 | diff $$tmp.1 - > $$tmp.3 ; \
echo "In code:" ; \
egrep '< ' < $$tmp.3 | sed -e 's/< / /' | sort | tee $$tmp.4 ; \
echo "In docs:" ; \
egrep '> ' < $$tmp.3 | sed -e 's/> / /' | sort | sed -e "s/\//self.add('AUTH', '/" -e "s/$$/'\)/" -e "s/\/:id\//', '/g" ; \
echo "Deprecated:" ; \
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 ; \
rm $$tmp.?

TUNA_CLI4_TEST_COMMAND = "/ips"
TUNA_CLI4_TEST_COMMAND = "--openapi http://localhost/~martin/openapi.json"
TUNA_CLI4_TEST_COMMAND = "--api"
TUNA_CLI4_TEST_COMMAND = "--openapi $(OPENAPI_URL)"

tuna:
@tmp=/tmp/_$$$$_ ; \
$(PYTHON) -X importtime -m cli4 $(TUNA_CLI4_TEST_COMMAND) > /dev/null 2> $$tmp.1 ; \
tuna $$tmp.1 2> /dev/null & \
tunapid=$$! ; \
sleep 1 ; \
kill $$tunapid ; \
rm $$tmp.?

clean:
rm -rf build
rm -rf dist
Expand Down

0 comments on commit afa8cc0

Please sign in to comment.