encode / apistar

The Web API toolkit. 🛠
https://docs.apistar.com
BSD 3-Clause "New" or "Revised" License
5.57k stars 411 forks source link

CLI arguments are not validated correctly. #652

Closed carltongibson closed 4 years ago

carltongibson commented 5 years ago

This is related to #650 (which is about --path).

CLI arguments aren't enforced, or given sensible defaults.

The one I hit is --format. If you don't provide this there is no error until you get to the final "Valid schema" message. At that point you get a totally mysterious KeyError:

(apistar) ~/Desktop $ apistar validate --path schema.yml 
Traceback (most recent call last):
...
  File ".../apistar/cli.py", line 163, in validate
    }[format]
KeyError: None

Cracking open cli.py, format there is the missing CLI argument. Sending --format=openapi resolves the issue.

format should be required, so as to provide a helpful error message. Maybe it should default to openapi...