From 753d705388610b516699fd6163be1538f4e1bd32 Mon Sep 17 00:00:00 2001 From: Md Afzal Ali <43498308+ermdafzalali@users.noreply.github.com> Date: Fri, 23 Aug 2024 07:37:24 +0000 Subject: [PATCH] chore: Update FastAPI version from 0.103.2 to 0.109.1 --- webapp/.well-known/openapi.json | 2 +- webapp/main.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/webapp/.well-known/openapi.json b/webapp/.well-known/openapi.json index 1fc1339..ddac29f 100644 --- a/webapp/.well-known/openapi.json +++ b/webapp/.well-known/openapi.json @@ -1 +1 @@ -{"openapi": "3.0.2", "info": {"title": "FastAPI", "version": "0.1.0"}, "paths": {"/": {"get": {"summary": "Root", "description": "Allows to open the API documentation in the browser directly instead of\nrequiring to open the /docs path.", "operationId": "root__get", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}}}}, "/countries": {"get": {"summary": "Countries", "operationId": "countries_countries_get", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}}}}, "/countries/{country}": {"get": {"summary": "Cities", "operationId": "cities_countries__country__get", "parameters": [{"required": true, "schema": {"title": "Country", "type": "string"}, "name": "country", "in": "path"}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/countries/{country}/{city}/{month}": {"get": {"summary": "Monthly Average", "operationId": "monthly_average_countries__country___city___month__get", "parameters": [{"required": true, "schema": {"title": "Country", "type": "string"}, "name": "country", "in": "path"}, {"required": true, "schema": {"title": "City", "type": "string"}, "name": "city", "in": "path"}, {"required": true, "schema": {"title": "Month", "type": "string"}, "name": "month", "in": "path"}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}}, "components": {"schemas": {"HTTPValidationError": {"title": "HTTPValidationError", "type": "object", "properties": {"detail": {"title": "Detail", "type": "array", "items": {"$ref": "#/components/schemas/ValidationError"}}}}, "ValidationError": {"title": "ValidationError", "required": ["loc", "msg", "type"], "type": "object", "properties": {"loc": {"title": "Location", "type": "array", "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]}}, "msg": {"title": "Message", "type": "string"}, "type": {"title": "Error Type", "type": "string"}}}}}} \ No newline at end of file +{"openapi": "3.1.0", "info": {"title": "FastAPI", "version": "0.1.0"}, "paths": {"/": {"get": {"summary": "Root", "description": "Allows to open the API documentation in the browser directly instead of\nrequiring to open the /docs path.", "operationId": "root__get", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}}}}, "/countries": {"get": {"summary": "Countries", "operationId": "countries_countries_get", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}}}}, "/countries/{country}/{city}/{month}": {"get": {"summary": "Monthly Average", "operationId": "monthly_average_countries__country___city___month__get", "parameters": [{"name": "country", "in": "path", "required": true, "schema": {"type": "string", "title": "Country"}}, {"name": "city", "in": "path", "required": true, "schema": {"type": "string", "title": "City"}}, {"name": "month", "in": "path", "required": true, "schema": {"type": "string", "title": "Month"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/countries/{country}": {"get": {"summary": "Cities", "operationId": "cities_countries__country__get", "parameters": [{"name": "country", "in": "path", "required": true, "schema": {"type": "string", "title": "Country"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/cities": {"get": {"summary": "Cities", "operationId": "cities_cities_get", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}}}}}, "components": {"schemas": {"HTTPValidationError": {"properties": {"detail": {"items": {"$ref": "#/components/schemas/ValidationError"}, "type": "array", "title": "Detail"}}, "type": "object", "title": "HTTPValidationError"}, "ValidationError": {"properties": {"loc": {"items": {"anyOf": [{"type": "string"}, {"type": "integer"}]}, "type": "array", "title": "Location"}, "msg": {"type": "string", "title": "Message"}, "type": {"type": "string", "title": "Error Type"}}, "type": "object", "required": ["loc", "msg", "type"], "title": "ValidationError"}}}} \ No newline at end of file diff --git a/webapp/main.py b/webapp/main.py index 4640f23..a41dd68 100644 --- a/webapp/main.py +++ b/webapp/main.py @@ -35,6 +35,22 @@ def countries(): def monthly_average(country: str, city: str, month: str): return data[country][city][month] +#return cities +@app.get('/countries/{country}') +def cities(country: str): + return list(data[country].keys()) + +#return cities for all countries +@app.get('/cities') +def cities(): + cities = [] + for country in data: + for city in data[country]: + cities.append(city) + return + + + # Generate the OpenAPI schema: openapi_schema = app.openapi() with open(join(wellknown_path, "openapi.json"), "w") as f: