Add schema privacy to docs
This commit is contained in:
parent
889db717d1
commit
179947b536
@ -25,6 +25,7 @@ master_debug = False
|
||||
DB_URL = 'https://pd.manticorum.com/api/'
|
||||
AUTH_TOKEN = f'{os.environ.get("API_TOKEN")}'
|
||||
AUTH_HEADER = {'Authorization': f'Bearer {AUTH_TOKEN}'}
|
||||
PRIVATE_IN_SCHEMA = True if os.environ.get('PRIVATE_IN_SCHEMA').upper() == 'TRUE' else False
|
||||
|
||||
|
||||
if os.environ.get('TESTING') == 'False':
|
||||
|
||||
@ -5,7 +5,7 @@ import logging
|
||||
import pydantic
|
||||
|
||||
from ..db_engine import db, Current, model_to_dict
|
||||
from ..dependencies import oauth2_scheme, valid_token, LOG_DATA
|
||||
from ..dependencies import oauth2_scheme, valid_token, LOG_DATA, PRIVATE_IN_SCHEMA
|
||||
|
||||
logging.basicConfig(
|
||||
filename=LOG_DATA['filename'],
|
||||
@ -26,7 +26,7 @@ class CurrentModel(pydantic.BaseModel):
|
||||
gsheet_version: str
|
||||
|
||||
|
||||
@router.get('')
|
||||
@router.get('', response_model=CurrentModel)
|
||||
async def get_current(season: Optional[int] = None, csv: Optional[bool] = False):
|
||||
if season:
|
||||
current = Current.get_or_none(season=season)
|
||||
@ -48,7 +48,7 @@ async def get_current(season: Optional[int] = None, csv: Optional[bool] = False)
|
||||
return return_val
|
||||
|
||||
|
||||
@router.get('/{current_id}')
|
||||
@router.get('/{current_id}', response_model=CurrentModel, include_in_schema=PRIVATE_IN_SCHEMA)
|
||||
async def get_one_current(current_id, csv: Optional[bool] = False):
|
||||
try:
|
||||
current = Current.get_by_id(current_id)
|
||||
@ -71,7 +71,7 @@ async def get_one_current(current_id, csv: Optional[bool] = False):
|
||||
return return_val
|
||||
|
||||
|
||||
@router.post('')
|
||||
@router.post('', response_model=CurrentModel, include_in_schema=PRIVATE_IN_SCHEMA)
|
||||
async def post_current(current: CurrentModel, token: str = Depends(oauth2_scheme)):
|
||||
if not valid_token(token):
|
||||
logging.warning(f'Bad Token: {token}')
|
||||
@ -102,7 +102,7 @@ async def post_current(current: CurrentModel, token: str = Depends(oauth2_scheme
|
||||
raise HTTPException(status_code=418, detail='Well slap my ass and call me a teapot; I could not save that team')
|
||||
|
||||
|
||||
@router.patch('/{current_id}')
|
||||
@router.patch('/{current_id}', response_model=CurrentModel, include_in_schema=PRIVATE_IN_SCHEMA)
|
||||
async def patch_current(
|
||||
current_id: int, season: Optional[int] = None, week: Optional[int] = None,
|
||||
gsheet_template: Optional[str] = None, gsheet_version: Optional[str] = None,
|
||||
@ -142,7 +142,7 @@ async def patch_current(
|
||||
)
|
||||
|
||||
|
||||
@router.delete('/{current_id}')
|
||||
@router.delete('/{current_id}', include_in_schema=PRIVATE_IN_SCHEMA)
|
||||
async def delete_current(current_id, token: str = Depends(oauth2_scheme)):
|
||||
if not valid_token(token):
|
||||
logging.warning(f'Bad Token: {token}')
|
||||
|
||||
Loading…
Reference in New Issue
Block a user