maximdanilchenko / aiohttp-apispec

Build and document REST APIs with aiohttp and apispec
https://aiohttp-apispec.rtfd.io
MIT License
220 stars 58 forks source link

Set body parameters to requestBody field in case if openapi 3 is used #131

Open arcan1s opened 1 year ago

arcan1s commented 1 year ago

According to documentation https://apispec.readthedocs.io/en/latest/api_ext.html#apispec.ext.marshmallow.openapi.OpenAPIConverter.schema2parameters in=body parameter is no longer allowed for parameters list and must be set to requestBody

This MR simply set data to another field based on location parameter, only tests have to be significantly hacked.

arcan1s commented 1 year ago

Probably we should consider split root openapi definition class (AiohttpApiSpec) into multiple subclasses each of them provides support only for specific openapi version, at least it would allow to decrease amount of if openapi_version.major < 3 blahblah and adjust tests accordingly (i.e. instead of testing aiohttp application, just check generator)

Also (but I'm not sure probably I miss something), in my environment asyncio tests are skipped, because it failed to find plugin, iirc asyncio_mode = auto has to be added to pytest configuration