Closed Nniol closed 1 month ago
aiohttp_cors works with aiohttp.web.view but PydanticView is a aiohttp.abc.AbstractView.
from aiohttp import web
class EP1View(web.View, PydanticView, aiohttp_cors.CorsViewMixin):
cors_config = {
"*": aiohttp_cors.ResourceOptions(
allow_credentials=True,
allow_headers="*",
)
}
async def get(self) -> Union[r200[ThingList], r500[Error]]:
...
cors = aiohttp_cors.setup(app, ...)
cors.add(app.router.add_route("*", "/json/ep1", EP1View))
Looks good.
Thank you for your help
Hi,
I have a website, which runs fine with CORS.
So I added in pydantic models and then aiohttp_pydantic , however if I use add_get it works fine but the the oas swagger page fails. If I use add_view then the swagger page (oas) works but cors gives an error:
Gives
Using _addget insead of _addview in the above code gets the website running and the endpoints work however on using oas endpoint i get:
EP1View defined as