From 3e2555084388b8d23113ce4698714b993895142b Mon Sep 17 00:00:00 2001 From: dm1sh Date: Tue, 1 Aug 2023 15:57:43 +0300 Subject: [PATCH] Added typings for /api/trashbox response and /api/announcement/dispose request --- back/main.py | 4 ++-- back/schemas.py | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/back/main.py b/back/main.py index 772fc43..b316acf 100644 --- a/back/main.py +++ b/back/main.py @@ -7,7 +7,7 @@ from fastapi.templating import Jinja2Templates from fastapi.requests import Request from pydantic import json -from typing import Any +from typing import List from starlette.staticfiles import StaticFiles import requests @@ -184,7 +184,7 @@ async def read_users_me(current_user: Annotated[schemas.User, Depends(get_curren -@app.get("/api/trashbox") +@app.get("/api/trashbox", response_model=List[schemas.TrashboxResponse]) def get_trashboxes(lat:float, lng:float):#крутая функция для работы с api BASE_URL='https://geointelect2.gate.petersburg.ru'#адрес сайта и мой токин my_token='eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJhU1RaZm42bHpTdURYcUttRkg1SzN5UDFhT0FxUkhTNm9OendMUExaTXhFIn0.eyJleHAiOjE3ODM3ODk4NjgsImlhdCI6MTY4OTA5NTQ2OCwianRpIjoiNDUzNjQzZTgtYTkyMi00NTI4LWIzYmMtYWJiYTNmYjkyNTkxIiwiaXNzIjoiaHR0cHM6Ly9rYy5wZXRlcnNidXJnLnJ1L3JlYWxtcy9lZ3MtYXBpIiwiYXVkIjoiYWNjb3VudCIsInN1YiI6ImJjYjQ2NzljLTU3ZGItNDU5ZC1iNWUxLWRlOGI4Yzg5MTMwMyIsInR5cCI6IkJlYXJlciIsImF6cCI6ImFkbWluLXJlc3QtY2xpZW50Iiwic2Vzc2lvbl9zdGF0ZSI6ImM2ZDJiOTZhLWMxNjMtNDAxZS05ZjMzLTI0MmE0NDcxMDY5OCIsImFjciI6IjEiLCJhbGxvd2VkLW9yaWdpbnMiOlsiLyoiXSwicmVhbG1fYWNjZXNzIjp7InJvbGVzIjpbImRlZmF1bHQtcm9sZXMtZWdzLWFwaSIsIm9mZmxpbmVfYWNjZXNzIiwidW1hX2F1dGhvcml6YXRpb24iXX0sInJlc291cmNlX2FjY2VzcyI6eyJhY2NvdW50Ijp7InJvbGVzIjpbIm1hbmFnZS1hY2NvdW50IiwibWFuYWdlLWFjY291bnQtbGlua3MiLCJ2aWV3LXByb2ZpbGUiXX19LCJzY29wZSI6ImVtYWlsIHByb2ZpbGUiLCJzaWQiOiJjNmQyYjk2YS1jMTYzLTQwMWUtOWYzMy0yNDJhNDQ3MTA2OTgiLCJlbWFpbF92ZXJpZmllZCI6ZmFsc2UsIm5hbWUiOiLQktC70LDQtNC40LzQuNGAINCv0LrQvtCy0LvQtdCyIiwicHJlZmVycmVkX3VzZXJuYW1lIjoiZTBmYzc2OGRhOTA4MjNiODgwZGQzOGVhMDJjMmQ5NTciLCJnaXZlbl9uYW1lIjoi0JLQu9Cw0LTQuNC80LjRgCIsImZhbWlseV9uYW1lIjoi0K_QutC-0LLQu9C10LIifQ.E2bW0B-c6W5Lj63eP_G8eI453NlDMnW05l11TZT0GSsAtGayXGaolHtWrmI90D5Yxz7v9FGkkCmcUZYy1ywAdO9dDt_XrtFEJWFpG-3csavuMjXmqfQQ9SmPwDw-3toO64NuZVv6qVqoUlPPj57sLx4bLtVbB4pdqgyJYcrDHg7sgwz4d1Z3tAeUfSpum9s5ZfELequfpLoZMXn6CaYZhePaoK-CxeU3KPBPTPOVPKZZ19s7QY10VdkxLULknqf9opdvLs4j8NMimtwoIiHNBFlgQz10Cr7bhDKWugfvSRsICouniIiBJo76wrj5T92s-ztf1FShJuqnQcKE_QLd2A' diff --git a/back/schemas.py b/back/schemas.py index 0569960..09131de 100644 --- a/back/schemas.py +++ b/back/schemas.py @@ -1,6 +1,7 @@ from pydantic import BaseModel from typing import Annotated, Union from datetime import date +from typing import List class Book(BaseModel): id: int @@ -55,3 +56,18 @@ class Poem(BaseModel): text: str author: str +class TrashboxBase(BaseModel): + Name: str + Lat: float + Lng: float + +class TrashboxResponse(TrashboxBase): + Address: str + Categories: List[str] + +class TrashboxRequest(TrashboxBase): + Category: str + +class DisposeRequest(BaseModel): + ann_id: int + trashbox: TrashboxRequest