Skip to content

Conversation

@EliuX
Copy link
Contributor

@EliuX EliuX commented Mar 11, 2020

This PR makes possible to run CLI commands:

  • gen_swagger_json: Exports swagger specifications in JSON format, namely swagger.json
  • gen_postman_collection: Generates a Postman Collection for the API

Check out the README for better information.

@EliuX EliuX force-pushed the feature/create-cli-generate-file-with-api-defÂ#10 branch from 9995d71 to 5f521dd Compare March 11, 2020 23:26
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}}')
Copy link
Contributor

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.

Copy link
Contributor Author

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👀

Copy link
Contributor Author

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👀

Copy link
Contributor Author

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):
Copy link
Contributor

@Angeluz-07 Angeluz-07 Mar 12, 2020

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.

Copy link
Contributor Author

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("****************")
Copy link
Contributor

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 ?

Copy link
Contributor Author

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
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@EliuX EliuX merged commit 6294d82 into master Mar 12, 2020
@EliuX EliuX deleted the feature/create-cli-generate-file-with-api-defÂ#10 branch March 12, 2020 17:09
@EliuX EliuX self-assigned this Apr 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants