From 73e3d5cdcea87ab6a91de5d281b7a736f5ea4d77 Mon Sep 17 00:00:00 2001 From: Hendrek Rodrigues Date: Wed, 9 Feb 2022 22:34:04 -0300 Subject: [PATCH 1/2] Update docs in space_flight_v1 --- .../space_flight_v1/docs/article_DELETE.yaml | 6 +++++ .../space_flight_v1/docs/article_id_GET.yaml | 6 +++++ .../space_flight_v1/docs/article_id_PUT.yaml | 6 +++++ .../space_flight_v1/docs/articles_POST.yaml | 6 +++++ .../blueprint/space_flight_v1/resources.py | 23 ++++++++++++++++++- Space_Flight/space_flight/ext/doc_swagger.py | 2 +- 6 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 Space_Flight/space_flight/blueprint/space_flight_v1/docs/article_DELETE.yaml create mode 100644 Space_Flight/space_flight/blueprint/space_flight_v1/docs/article_id_GET.yaml create mode 100644 Space_Flight/space_flight/blueprint/space_flight_v1/docs/article_id_PUT.yaml create mode 100644 Space_Flight/space_flight/blueprint/space_flight_v1/docs/articles_POST.yaml diff --git a/Space_Flight/space_flight/blueprint/space_flight_v1/docs/article_DELETE.yaml b/Space_Flight/space_flight/blueprint/space_flight_v1/docs/article_DELETE.yaml new file mode 100644 index 0000000..abeb02e --- /dev/null +++ b/Space_Flight/space_flight/blueprint/space_flight_v1/docs/article_DELETE.yaml @@ -0,0 +1,6 @@ +tags: +- "Article" +summary: "Deleta artigo." +description: "Essa rota deleta o artigo por {ID}." +produces: +- "application/json" diff --git a/Space_Flight/space_flight/blueprint/space_flight_v1/docs/article_id_GET.yaml b/Space_Flight/space_flight/blueprint/space_flight_v1/docs/article_id_GET.yaml new file mode 100644 index 0000000..7240377 --- /dev/null +++ b/Space_Flight/space_flight/blueprint/space_flight_v1/docs/article_id_GET.yaml @@ -0,0 +1,6 @@ +tags: +- "Article" +summary: "Lista artigo." +description: "Lista um artigo por {id}." +produces: +- "application/json" diff --git a/Space_Flight/space_flight/blueprint/space_flight_v1/docs/article_id_PUT.yaml b/Space_Flight/space_flight/blueprint/space_flight_v1/docs/article_id_PUT.yaml new file mode 100644 index 0000000..e66d1ed --- /dev/null +++ b/Space_Flight/space_flight/blueprint/space_flight_v1/docs/article_id_PUT.yaml @@ -0,0 +1,6 @@ +tags: +- "Article" +summary: "Atualiza artigo." +description: "Atualiza um artigo por {ID}." +produces: +- "application/json" diff --git a/Space_Flight/space_flight/blueprint/space_flight_v1/docs/articles_POST.yaml b/Space_Flight/space_flight/blueprint/space_flight_v1/docs/articles_POST.yaml new file mode 100644 index 0000000..eae8720 --- /dev/null +++ b/Space_Flight/space_flight/blueprint/space_flight_v1/docs/articles_POST.yaml @@ -0,0 +1,6 @@ +tags: +- "Article" +summary: "Adiciona artigo." +description: "Adiciona artigo por {ID}." +produces: +- "application/json" diff --git a/Space_Flight/space_flight/blueprint/space_flight_v1/resources.py b/Space_Flight/space_flight/blueprint/space_flight_v1/resources.py index 1d3363b..251b51d 100644 --- a/Space_Flight/space_flight/blueprint/space_flight_v1/resources.py +++ b/Space_Flight/space_flight/blueprint/space_flight_v1/resources.py @@ -33,6 +33,7 @@ def articles_get(): @bp.route('/articles', methods=['POST']) +@doc_swagger.swag_from("docs/articles_POST.yaml") def articles_post(): request_json = request.get_json() @@ -41,6 +42,26 @@ def articles_post(): return jsonify(data_return) +@bp.route('/articles/', methods=['DELETE']) +@doc_swagger.swag_from("docs/article_DELETE.yaml") +def article_delete(): + request_json = request.get_json() + + data_return = request_json + + return jsonify(data_return) + + + + @bp.route('/articles/', methods=['GET']) -def article(id_article): +@doc_swagger.swag_from("docs/article_id_GET.yaml") +def article_get(id_article): + return Response(f'artigo {id_article}', status=200, mimetype='text/html') + + + +@bp.route('/articles/', methods=['PUT']) +@doc_swagger.swag_from("docs/article_id_PUT.yaml") +def article_put(id_article): return Response(f'artigo {id_article}', status=200, mimetype='text/html') \ No newline at end of file diff --git a/Space_Flight/space_flight/ext/doc_swagger.py b/Space_Flight/space_flight/ext/doc_swagger.py index 0baf711..babd057 100644 --- a/Space_Flight/space_flight/ext/doc_swagger.py +++ b/Space_Flight/space_flight/ext/doc_swagger.py @@ -7,7 +7,7 @@ "info": { "title": "Spaceflight News API", "description": "Documentation for the Spaceflight News API. Join The Space Devs Discord server to contact me for support :) NOTE: to use filters like _contains, specify the field you want to filter. For example: title_contains=nasa. This can not be done in this Swagger interface. More info and examples.", - "version": "0.1", + "version": "0.2.1", } } From 1659edd3b144d94afd3930925195ad2d20bfca7a Mon Sep 17 00:00:00 2001 From: Hendrek Rodrigues Date: Wed, 9 Feb 2022 22:40:43 -0300 Subject: [PATCH 2/2] Teste Branch GitKraken --- .../blueprint/space_flight_v1/docs/article_id_GET.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Space_Flight/space_flight/blueprint/space_flight_v1/docs/article_id_GET.yaml b/Space_Flight/space_flight/blueprint/space_flight_v1/docs/article_id_GET.yaml index 7240377..db8ae13 100644 --- a/Space_Flight/space_flight/blueprint/space_flight_v1/docs/article_id_GET.yaml +++ b/Space_Flight/space_flight/blueprint/space_flight_v1/docs/article_id_GET.yaml @@ -1,6 +1,6 @@ tags: - "Article" summary: "Lista artigo." -description: "Lista um artigo por {id}." +description: "Lista um artigo por {id}. " produces: - "application/json"