I would like to add an image to the FastAPI automatic documentation (provided by Swagger UI), but I can't figure out how to do this. This is the code:
@api.get(path='/carbon-credit/',
responses={
200: {'description': 'Ok',
"content": {
"image/jpeg": {
"example": 'https://picsum.photos/seed/picsum/200/300'
}
}},
404: {"description": "not found"},
422: {'description': 'not found 2'},
},
name='API for Carbon Credit',
description="get carbon credit",
tags=['Images'],
response_class=Response)
As you can see from the code, I'm trying to do this using a URL, and what I get in both ReDoc and Swagger UI is just the URL as a text, not the actual image. Also, I would like to use an image stored in the local drive.
Screenshots from Swagger UI and ReDoc:
How can I achieve that?
Thanks in advance.