From fffecd50720b49f0bcf4580198c6e4b1d8621a01 Mon Sep 17 00:00:00 2001 From: Fabrice Lecomte Date: Fri, 30 Aug 2019 10:07:47 +0200 Subject: [PATCH] feature #11: describe "create/delete follow to article" in openAPI --- .../kotlin/fr/dcproject/routes/Article.kt | 1 - .../fr/dcproject/routes/FollowArticle.kt | 2 +- src/main/resources/openApi.yaml | 34 +++++++++++++++++++ src/test/resources/feature/follow.feature | 4 +-- 4 files changed, 37 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/fr/dcproject/routes/Article.kt b/src/main/kotlin/fr/dcproject/routes/Article.kt index 4415693..8514c81 100644 --- a/src/main/kotlin/fr/dcproject/routes/Article.kt +++ b/src/main/kotlin/fr/dcproject/routes/Article.kt @@ -24,7 +24,6 @@ object ArticlesPaths { val limit: Int = if (limit > 50) 50 else if (limit < 1) 1 else limit } @Location("/articles/{article}") class ArticleRequest(val article: ArticleEntity) - @Location("/articles/{article}/follow") class ArticleFollowRequest(val article: ArticleEntity) @Location("/articles") class PostArticleRequest } diff --git a/src/main/kotlin/fr/dcproject/routes/FollowArticle.kt b/src/main/kotlin/fr/dcproject/routes/FollowArticle.kt index 8af9417..0bc6db5 100644 --- a/src/main/kotlin/fr/dcproject/routes/FollowArticle.kt +++ b/src/main/kotlin/fr/dcproject/routes/FollowArticle.kt @@ -13,7 +13,7 @@ import fr.dcproject.repository.FollowArticle as FollowArticleRepository @KtorExperimentalLocationsAPI object FollowArticlePaths { - @Location("/articles/{article}/follow") class ArticleFollowRequest(val article: ArticleEntity) + @Location("/articles/{article}/follows") class ArticleFollowRequest(val article: ArticleEntity) @Location("/citizens/{citizen}/follows/articles") class CitizenFollowArticleRequest(val citizen: Citizen) } diff --git a/src/main/resources/openApi.yaml b/src/main/resources/openApi.yaml index 8460dca..f316f9a 100644 --- a/src/main/resources/openApi.yaml +++ b/src/main/resources/openApi.yaml @@ -323,6 +323,34 @@ paths: application/json: schema: $ref: '#/components/schemas/CommentResponse' + /articles/{article}/follows: + parameters: + - name: article + in: path + description: The ID of article + example: e74be8e4-6823-47c4-bd1b-789725b2fa8e + required: true + schema: + type: string + format: uuid + post: + security: + - JWTAuth: [] + summary: Follow one article + tags: + - follow + responses: + 201: + description: Return only http status 201 on success + delete: + security: + - JWTAuth: [] + summary: Unfollow one article + tags: + - follow + responses: + 204: + description: Return only http status 204 on success components: @@ -661,6 +689,12 @@ components: - $ref: '#/components/schemas/UUID' - $ref: '#/components/schemas/UUID' + FollowBase: + allOf: + - $ref: '#/components/schemas/Extra' + FollowResponse: + allOf: + - $ref: '#/components/schemas/FollowBase' requestBodies: diff --git a/src/test/resources/feature/follow.feature b/src/test/resources/feature/follow.feature index 17551f9..2afade1 100644 --- a/src/test/resources/feature/follow.feature +++ b/src/test/resources/feature/follow.feature @@ -3,7 +3,7 @@ Feature: follow Article and Constitution # Article Scenario: The route for follow article must response a 201 and return object Given I am authenticated as John Doe with id "64b7b379-2298-43ec-b428-ba134930cabd" - When I send a POST request to "/articles/9226c1a3-8091-c3fa-7d0d-c2e98c9bee7b/follow" + When I send a POST request to "/articles/9226c1a3-8091-c3fa-7d0d-c2e98c9bee7b/follows" Then the response status code should be 201 Scenario: The route for get follows of articles must response a 200 and return objects @@ -16,7 +16,7 @@ Feature: follow Article and Constitution Scenario: The route for unfollow article must response a 204 Given I am authenticated as John Doe with id "64b7b379-2298-43ec-b428-ba134930cabd" - When I send a DELETE request to "/articles/9226c1a3-8091-c3fa-7d0d-c2e98c9bee7b/follow" + When I send a DELETE request to "/articles/9226c1a3-8091-c3fa-7d0d-c2e98c9bee7b/follows" Then the response status code should be 204 # Constitution