fix: camel case response
This commit is contained in:
@@ -33,7 +33,7 @@ from api.db.logic.process_schema import update_process_schema_settings_by_id
|
|||||||
|
|
||||||
from orm.tables.process import NodeType
|
from orm.tables.process import NodeType
|
||||||
|
|
||||||
|
from api.utils.to_camel_dict import to_camel_dict
|
||||||
|
|
||||||
|
|
||||||
api_router = APIRouter(
|
api_router = APIRouter(
|
||||||
@@ -82,7 +82,7 @@ async def get_all_process_schema_endpoint(
|
|||||||
if process_schema_page is None:
|
if process_schema_page is None:
|
||||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Process schema not found")
|
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Process schema not found")
|
||||||
|
|
||||||
return process_schema_page
|
return to_camel_dict(process_schema_page.model_dump())
|
||||||
|
|
||||||
|
|
||||||
@api_router.get("/{process_schema_id}", dependencies=[Depends(bearer_schema)], response_model=ProcessSchema)
|
@api_router.get("/{process_schema_id}", dependencies=[Depends(bearer_schema)], response_model=ProcessSchema)
|
||||||
@@ -103,7 +103,7 @@ async def get_process_schema_endpoint(
|
|||||||
if process_schema_id is None:
|
if process_schema_id is None:
|
||||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Process schema not found")
|
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Process schema not found")
|
||||||
|
|
||||||
return process_schema_validation
|
return to_camel_dict(process_schema_validation.model_dump())
|
||||||
|
|
||||||
|
|
||||||
@api_router.post("", dependencies=[Depends(bearer_schema)], response_model=ProcessSchemaResponse)
|
@api_router.post("", dependencies=[Depends(bearer_schema)], response_model=ProcessSchemaResponse)
|
||||||
@@ -135,7 +135,7 @@ async def create_processschema_endpoint(
|
|||||||
node = ProcessSchemaSettingsNode(
|
node = ProcessSchemaSettingsNode(
|
||||||
id=db_start_schema.id,
|
id=db_start_schema.id,
|
||||||
node_type=NodeType.START.value,
|
node_type=NodeType.START.value,
|
||||||
data=validated_start_schema.data.model_dump(),
|
data=validated_start_schema.data.model_dump(by_alias=True),
|
||||||
from_node=None,
|
from_node=None,
|
||||||
links=None)
|
links=None)
|
||||||
|
|
||||||
@@ -155,10 +155,10 @@ async def create_processschema_endpoint(
|
|||||||
|
|
||||||
|
|
||||||
response_data = {
|
response_data = {
|
||||||
"process_schema": process_schema_new.model_dump(mode='json'),
|
"process_schema": process_schema_new.model_dump(),
|
||||||
"node_start":ps_node_front_response.model_dump(mode='json')}
|
"node_start": ps_node_front_response.model_dump()}
|
||||||
|
|
||||||
return response_data
|
return to_camel_dict(response_data)
|
||||||
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
@@ -20,6 +20,7 @@ from api.db.logic.process_schema import update_process_schema_settings_by_id
|
|||||||
from core import VorkNodeRegistry, VorkNodeLink
|
from core import VorkNodeRegistry, VorkNodeLink
|
||||||
|
|
||||||
from model_nodes import VorkNodeLinkData
|
from model_nodes import VorkNodeLinkData
|
||||||
|
from api.utils.to_camel_dict import to_camel_dict
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -96,7 +97,7 @@ async def create_ps_node_endpoint(
|
|||||||
node_type=db_ps_node.node_type,
|
node_type=db_ps_node.node_type,
|
||||||
data=node_instance_validated.data.model_dump(),
|
data=node_instance_validated.data.model_dump(),
|
||||||
from_node=None,
|
from_node=None,
|
||||||
links=links_settings)
|
links=links_settings.model_dump())
|
||||||
|
|
||||||
|
|
||||||
settings_dict = {"node": node_settings.model_dump(mode='json')}
|
settings_dict = {"node": node_settings.model_dump(mode='json')}
|
||||||
@@ -109,8 +110,8 @@ async def create_ps_node_endpoint(
|
|||||||
node=Ps_NodeFrontResponseNode(
|
node=Ps_NodeFrontResponseNode(
|
||||||
id=db_ps_node.id,
|
id=db_ps_node.id,
|
||||||
node_type=db_ps_node.node_type,
|
node_type=db_ps_node.node_type,
|
||||||
data=node_instance_validated.data.model_dump()),
|
data=to_camel_dict(node_instance_validated.data.model_dump())),
|
||||||
link=links_settings)
|
link=links_settings.model_dump())
|
||||||
|
|
||||||
|
|
||||||
return ps_node_front_response.model_dump(mode='json')
|
return ps_node_front_response
|
||||||
|
9
api/api/utils/to_camel_dict.py
Normal file
9
api/api/utils/to_camel_dict.py
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
from pydantic.alias_generators import to_camel
|
||||||
|
|
||||||
|
def to_camel_dict(obj):
|
||||||
|
if isinstance(obj, dict):
|
||||||
|
return {to_camel(key): to_camel_dict(value) for key, value in obj.items()}
|
||||||
|
elif isinstance(obj, list):
|
||||||
|
return [to_camel_dict(item) for item in obj]
|
||||||
|
else:
|
||||||
|
return obj
|
Reference in New Issue
Block a user