Package: aiohttp-apispec-plugin
aiohttp-apispec-pluginLightweightapispecplugin that generates OpenAPI specification  foraiohttpweb applications.Installationpipinstallaiohttp-apispec-pluginExamplesWith class based viewfromaiohttpimportwebfromaiohttp_apispec_pluginimportAioHttpPluginfromapispecimportAPISpecclassUserView(web.View):asyncdefget(self)->web.Response:"""User Detail View---summary: Get Userdescription: Get User Data For Given `user_id`parameters:- name: user_idin: pathdescription: User IDrequired: trueschema:type: stringresponses:200:description: Successfully retrieved user detailscontent:application/json:schema:properties:id:type: integerusername:type: stringfirst_name:type: stringlast_name:type: string"""app=web.Application()app.router.add_view("/api/v1/users/{user_id}",UserView)# Create an APISpecspec=APISpec(title="AioHttp Application",version="1.0.0",openapi_version="3.0.3",plugins=[AioHttpPlugin(app),],)spec.path(resource=UserView)print(spec.to_yaml())"""info:title: AioHttp Applicationversion: 1.0.0openapi: 3.0.3paths:/api/v1/users/{user_id}:get:description: Get User Data For Given `user_id`parameters:- description: User IDin: pathname: user_idrequired: trueschema:type: stringresponses:'200':content:application/json:schema:properties:first_name:type: stringid:type: integerlast_name:type: stringusername:type: stringdescription: Successfully retrieved user detailssummary: Get User"""With function based viewfromaiohttpimportwebfromaiohttp_apispec_pluginimportAioHttpPluginfromapispecimportAPISpecasyncdefget_user(request:web.Request)->web.Response:"""User Detail View---summary: Get Userdescription: Get User Data For Given `user_id`responses:200:description: Successfully retrieved user details"""app=web.Application()app.router.add_get("/api/v1/users/{user_id}",get_user)# Create an APISpecspec=APISpec(title="AioHttp Application",version="1.0.0",openapi_version="3.0.3",plugins=[AioHttpPlugin(app),],)spec.path(resource=get_user)print(spec.to_yaml())# same behaviorWithdataclassespluginfromdataclassesimportdataclassfromaiohttpimportwebfromaiohttp_apispec_pluginimportAioHttpPluginfromapispecimportAPISpecfromdataclasses_jsonschemaimportJsonSchemaMixinfromdataclasses_jsonschema.apispecimportDataclassesPlugin@dataclassclassUser(JsonSchemaMixin):"""User Schema"""id:intusername:strasyncdefget_user(request:web.Request)->web.Response:"""User Detail View---summary: Get Userdescription: Get User Data For Given `user_id`responses:200:description: Successfully retrieved user detailscontent:application/json:schema: User"""app=web.Application()app.router.add_get("/api/v1/users/{user_id}",get_user)spec=APISpec(title="AioHttp Application",version="1.0.0",openapi_version="3.0.3",plugins=[AioHttpPlugin(app),DataclassesPlugin(),],)spec.components.schema("User",schema=User)spec.path(resource=get_user)print(spec.to_yaml())"""components:schemas:User:description: User Schemaproperties:id:type: integerusername:type: stringrequired:- id- usernametype: objectinfo:title: AioHttp Applicationversion: 1.0.0openapi: 3.0.3paths:/api/v1/users/{user_id}:get:description: Get User Data For Given `user_id`responses:'200':content:application/json:schema:$ref: '#/components/schemas/User'description: Successfully retrieved user detailssummary: Get User"""RequirementsPython >= 3.6Dependencies:aiohttpapispecPyYAMLOther libs to checkaiohttp-apispecfalcon-apispecdataclasses-jsonschema