|
1 | 1 | from flask_restplus import fields, Resource, Namespace |
2 | 2 | from time_tracker_api.api import audit_fields |
3 | 3 | from time_tracker_api import database |
| 4 | +from faker import Faker |
| 5 | + |
| 6 | +faker = Faker() |
4 | 7 |
|
5 | 8 | ns = Namespace('time-entries', description='API for time entries') |
6 | 9 |
|
|
11 | 14 | title='Project', |
12 | 15 | max_length=64, |
13 | 16 | description='The id of the selected project', |
| 17 | + example=faker.uuid4() |
14 | 18 | ), |
15 | 19 | 'activity_id': fields.String( |
16 | 20 | required=False, |
17 | 21 | title='Activity', |
18 | 22 | max_length=64, |
19 | 23 | description='The id of the selected activity', |
| 24 | + example=faker.uuid4() |
20 | 25 | ), |
21 | 26 | 'technologies': fields.String( |
22 | 27 | required=True, |
|
26 | 31 | ), |
27 | 32 | 'description': fields.String( |
28 | 33 | title='Comments', |
29 | | - description='Comments about the time entry' |
| 34 | + description='Comments about the time entry', |
| 35 | + example=faker.paragraph() |
30 | 36 | ), |
31 | 37 | 'start_date': fields.DateTime( |
32 | 38 | required=True, |
33 | 39 | title='Start date', |
34 | 40 | description='When the user started doing this activity', |
| 41 | + example=faker.iso8601(end_datetime=None) |
35 | 42 | ), |
36 | 43 | 'end_date': fields.DateTime( |
37 | 44 | required=True, |
38 | 45 | title='End date', |
39 | 46 | description='When the user ended doing this activity', |
| 47 | + example=faker.iso8601(end_datetime=None) |
40 | 48 | ), |
41 | 49 | }) |
42 | 50 |
|
|
46 | 54 | required=True, |
47 | 55 | title='Identifier', |
48 | 56 | description='The unique identifier', |
| 57 | + example=faker.uuid4() |
49 | 58 | ), |
50 | 59 | 'running': fields.Boolean( |
51 | 60 | readOnly=True, |
52 | 61 | title='Is it running?', |
53 | | - description='Whether this time entry is currently running or not' |
| 62 | + description='Whether this time entry is currently running or not', |
| 63 | + example=faker.boolean() |
54 | 64 | ), |
55 | 65 | } |
56 | 66 | time_entry_response_fields.update(audit_fields) |
|
64 | 74 |
|
65 | 75 | model = database.create('time-entries') |
66 | 76 |
|
| 77 | + |
67 | 78 | @ns.route('') |
68 | 79 | class TimeEntries(Resource): |
69 | 80 | @ns.doc('list_time_entries') |
|
0 commit comments