From 85512b901d99c51875d87715b646bad5604e016a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 24 Feb 2024 14:08:38 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20[pre-commit.ci]=20Auto=20format?= =?UTF-8?q?=20from=20pre-commit.com=20hooks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fastapi/openapi/utils.py | 5 ++++- tests/test_schema_extra_examples.py | 24 ++++++++++++------------ 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/fastapi/openapi/utils.py b/fastapi/openapi/utils.py index f5c478768..2ce6a379b 100644 --- a/fastapi/openapi/utils.py +++ b/fastapi/openapi/utils.py @@ -126,7 +126,10 @@ def get_openapi_operation_parameters( parameter["examples"] = jsonable_encoder(field_info.examples) else: parameter["examples"] = jsonable_encoder( - [{"value": item, "summary": item} for item in field_info.examples] + [ + {"value": item, "summary": item} + for item in field_info.examples + ] ) if field_info.example != Undefined: parameter["example"] = jsonable_encoder(field_info.example) diff --git a/tests/test_schema_extra_examples.py b/tests/test_schema_extra_examples.py index 2bef1d9a9..982dc6e7a 100644 --- a/tests/test_schema_extra_examples.py +++ b/tests/test_schema_extra_examples.py @@ -479,13 +479,13 @@ def test_openapi_schema(): "title": "Item Id", "type": "string", "examples": ["item_1", "item_2"], - }, + }, "name": "item_id", - "in": "path", + "in": "path", "examples": [ {"value": "item_1", "summary": "item_1"}, {"value": "item_2", "summary": "item_2"}, - ], + ], } ], "responses": { @@ -511,7 +511,7 @@ def test_openapi_schema(): "summary": "Path Example Examples", "operationId": "path_example_examples_path_example_examples__item_id__get", "parameters": [ - { + { "required": True, "schema": { "title": "Item Id", @@ -520,11 +520,11 @@ def test_openapi_schema(): }, "example": "item_overridden", "name": "item_id", - "in": "path", + "in": "path", "examples": [ {"value": "item_1", "summary": "item_1"}, {"value": "item_2", "summary": "item_2"}, - ], + ], } ], "responses": { @@ -612,7 +612,7 @@ def test_openapi_schema(): "examples": [ {"value": "query1", "summary": "query1"}, {"value": "query2", "summary": "query2"}, - ], + ], } ], "responses": { @@ -661,7 +661,7 @@ def test_openapi_schema(): "examples": [ {"value": "query1", "summary": "query1"}, {"value": "query2", "summary": "query2"}, - ], + ], } ], "responses": { @@ -749,7 +749,7 @@ def test_openapi_schema(): "examples": [ {"value": "header1", "summary": "header1"}, {"value": "header2", "summary": "header2"}, - ], + ], } ], "responses": { @@ -798,7 +798,7 @@ def test_openapi_schema(): "examples": [ {"value": "header1", "summary": "header1"}, {"value": "header2", "summary": "header2"}, - ], + ], } ], "responses": { @@ -886,7 +886,7 @@ def test_openapi_schema(): "examples": [ {"value": "cookie1", "summary": "cookie1"}, {"value": "cookie2", "summary": "cookie2"}, - ], + ], } ], "responses": { @@ -935,7 +935,7 @@ def test_openapi_schema(): "examples": [ {"value": "cookie1", "summary": "cookie1"}, {"value": "cookie2", "summary": "cookie2"}, - ], + ], } ], "responses": {