Skip to content

Commit

Permalink
Fixes #68
Browse files Browse the repository at this point in the history
  • Loading branch information
Shubham Mishra committed Aug 17, 2019
1 parent faf8b93 commit 4b62a0f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 4 additions & 3 deletions app/main/controller/article_controller.py
Expand Up @@ -15,14 +15,15 @@
api = PostDto.api


@api.route("/<int:post_id>")
@api.route("/")
class ArticleFetch(Resource):
@api.marshal_with(PostDto.article)
@api.doc(params={'post_id': 'Post Id'})
def get(self, post_id):
@api.expect(PostDto.articleReq)
def get(self):
"""
Fetches the article given by the id.
"""
post_id = request.args.get('post_id')
p = Post.getArticles(post_id)
if p is not None:
article = {
Expand Down
6 changes: 6 additions & 0 deletions app/main/util/dto.py
Expand Up @@ -50,6 +50,12 @@ class UserDto:

class PostDto:
api = Namespace('article', description='article related operations')

articleReq = api.model('articleReq', {
'post_id': fields.Integer(required=True,
description="Post id of the required post")
})

article = api.model('article', {
'author': fields.String(required=True,
description="Author of the post"),
Expand Down

0 comments on commit 4b62a0f

Please sign in to comment.