Skip to content

Commit 97e84e8

Browse files
mansiagCuriousLearner
authored andcommitted
feat(serialize_data): Add file-path option for path to proposed endpoints doc (#4)
1 parent f479328 commit 97e84e8

File tree

5 files changed

+167
-104
lines changed

5 files changed

+167
-104
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Changelog
2+
=========
3+
4+
Features & Improvements
5+
-----------------------
6+
7+
#### 2019-1-29
8+
9+
- Allow `serialize_data.py` accept path for proposed endpoints docs as command line argument. ([@mansiag])
10+
11+
[@mansiag]: https://github.com/mansiag

Pipfile

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,17 @@
11
[[source]]
2-
32
name = "pypi"
43
verify_ssl = true
54
url = "https://pypi.python.org/simple"
65

7-
86
[dev-packages]
9-
107
pytest-datafiles = "*"
118
pytest = "*"
129
pytest-cov = "*"
1310

14-
1511
[requires]
16-
1712
python_version = "3.6"
1813

19-
2014
[packages]
21-
2215
flask = "*"
16+
click = "*"
17+
flake8 = "*"

Pipfile.lock

Lines changed: 144 additions & 92 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,13 @@ pipenv install
3232

3333
## Usage
3434

35-
Run `pipenv run python serialize_data.py` to generate JSON file named `endpoints_data.json`
35+
- Run `pipenv run python serialize_data.py` to generate JSON file named `endpoints_data.json`. Optionally, you can specify the path of the proposed endpoints docs using `--file-path` option like:
3636

37-
Run `pipenv run python create_mock_endpoints.py` to generate `app.py` with all the code for the Mocked end points.
37+
```pipenv run python serialize_data.py --file-path /pat/to/endpoints_data.json```
3838

39-
Run `pipenv run python app.py` & hit any endpoint that you defined in the `proposed_endpoints.md` doc.
39+
- Run `pipenv run python create_mock_endpoints.py` to generate `app.py` with all the code for the Mocked end points.
40+
41+
- Run `pipenv run python app.py` & hit any endpoint that you defined in the `proposed_endpoints.md` doc.
4042

4143

4244
## GET - SET - GO

src/serialize_data.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import json
2+
import click
23

34
HTTP_VERBS = ('GET', 'POST', 'HEAD', 'OPTIONS', 'PUT', 'PATCH', 'DELETE')
45

@@ -93,9 +94,11 @@ def get_json_from_endpoints(lines):
9394
return endpoint_json_list
9495

9596

96-
def generate_json_from_docs_file(filename='proposed_endpoints.md'):
97+
@click.command()
98+
@click.option('--file-path', default='proposed_endpoints.md', help='Path for the proposed endpoints docs')
99+
def generate_json_from_docs_file(file_path):
97100
lines = None
98-
with open(filename, 'r') as endpoint_file:
101+
with open(file_path, 'r') as endpoint_file:
99102
lines = endpoint_file.read()
100103
json_data = get_json_from_endpoints(lines)
101104

0 commit comments

Comments
 (0)