-
Notifications
You must be signed in to change notification settings - Fork 0
Add CLI commands to generate API definition #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add CLI commands to generate API definition #15
The head ref may contain hidden characters: "feature/create-cli-generate-file-with-api-def\u00C2#10"
Conversation
9995d71 to
5f521dd
Compare
cli.py
Outdated
| """ Generates a Postman collection for the API """ | ||
| data = api.as_postman(urlvars=False, swagger=True) | ||
| postman_collection_json_data = json.dumps(data) | ||
| parsed_json = postman_collection_json_data.replace("http://localhost", '{{timetracker_api_host}}') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be great if we can send http://localhost as a parameter to the cli.py file. I think by default it can be localhost.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By default it is actually localhost:5000 for development and localhost:8000 when it is using a wsgi server, like gunicorn. The idea behind setting a postman env variable is that you can set that env variable to whatever you want based on the environment you will be working at.
Nonetheless, I will create a param, so you can override the default param which by default will be localhost and everyone is happy :)
README.md
Outdated
| There are available commands aware of the API that can be verify useful for you. You | ||
| can check them out by running | ||
| ```angular2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LoL, thanks, I will fix it.
README.md
Outdated
| If you want to run an specific command, e.g. `gen_swagger_json`, specify it as a param | ||
| as well as its correspondent options. | ||
|
|
||
| ```angular2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep
cli.py
Outdated
| save_data(parsed_json, filename) | ||
|
|
||
|
|
||
| def save_data(data, filename): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we have type hints here? Not only for parameters but for return also i.e def function(..) -> None.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, sure.
| @@ -0,0 +1,52 @@ | |||
| #!/usr/bin/env python3 | |||
|
|
|||
| print("****************") | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it necessary to have these prints before the import section ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, because I wanted to know whether the CLI file is actually running before any error inside it happens.
README.md
Outdated
| ## CLI | ||
| There are available commands aware of the API that can be verify useful for you. You |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you meant
There are available commands that can be very useful for you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LOL, yes, thanks for the catch.
This PR makes possible to run CLI commands:
Check out the README for better information.