aiohttp_apiset
aiohttp_apiset copied to clipboard
Allow using `operationId` to find the handler
I'd much rather have unique IDs in the existing operationId value for each handler, and then
- either instantiate apiset with something like
handlers_module='mymodule.handlers'to have it automaticallygetattr(mymodule.handlers, yaml['operationId'])the handlers from there. - or specify a dict in my app that maps operationIds to callables.
I did not know about the "operationId", and it is an interesting idea. Must think how to organize operations subsystem.
This is a greate idea. As a generale purpose, it would be greate to only remove keys from the spec if its name starts with '$'.
Resolved
from aiohttp_apiset.swagger.operations import OperationIdMapping
router = SwaggerRouter(default_validate=True)
router.add_search_dir('...')
opmap = OperationIdMapping()
opmap.add_operations(
'mymodule',
module.module,
getPets='module.handler')
router.include('...yaml', basePath='/my/override/path', operationId_mapping=opmap)
add_operations renamed to add
Wow, awesome job, @aamalev!
Would you like me to close this issue or is there any reason you kept it open?
Need to document this functionality