I am creating a GET request in FastAPI as follows:
@router.get("/{ngo_id}")
def get_ngo_by_id(ngo_id: str):
# Get the NGO from the database
db = firestore.client()
ngo_ref = db.collection("ngos").document(ngo_id).get()
ngo_data = ngo_ref.to_dict()
# Return the NGO
if ngo_data:
return JSONResponse(
status_code=response_status.HTTP_200_OK,
content={
"message": "Success",
"data": jsonable_encoder({ngo_ref.id: ngo_ref.to_dict()}),
},
)
else:
return JSONResponse(
status_code=response_status.HTTP_404_NOT_FOUND,
content={"message": "NGO not found", "data": None},
)
This is how it shows up in my swagger.
In this case the example value just says "string"
and the schema is empty. I want to show a schema and an example value but I am NOT using a Pydantic model for the GET request.
My example value should show what the output of the NGO structure would look like and it's as follows.
{
"message": "Success",
"data": {
"7kKMwGsTyRD00tjY1zpb": {
"description": "string",
"website": "string",
"associatedMagazines": [
"string"
],
"contactNumber": "string",
"tagline": "string",
"displayName": "string",
"contactName": "string",
"createdBy": "string",
"updatedBy": "string",
"updatedOn": "string",
"createdOn": "string",
"associatedProjects": [
"string",
],
"publicRegistryId": null,
"status": "string",
"contactEmail": "string",
"docID": "string",
"isFeatured": false,
"bannerUrl": [
"string"
],
"logoUrl": "string"
}
}
}
How can I achieve this?