aiohttp_apiset icon indicating copy to clipboard operation
aiohttp_apiset copied to clipboard

Allow using `operationId` to find the handler

Open underyx opened this issue 9 years ago • 6 comments

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 automatically getattr(mymodule.handlers, yaml['operationId']) the handlers from there.
  • or specify a dict in my app that maps operationIds to callables.

underyx avatar Nov 08 '16 09:11 underyx

I did not know about the "operationId", and it is an interesting idea. Must think how to organize operations subsystem.

aamalev avatar Nov 08 '16 11:11 aamalev

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 '$'.

aleufroy avatar Nov 15 '16 14:11 aleufroy

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)

aamalev avatar Nov 15 '16 15:11 aamalev

add_operations renamed to add

aamalev avatar Nov 16 '16 21:11 aamalev

Wow, awesome job, @aamalev!

Would you like me to close this issue or is there any reason you kept it open?

underyx avatar Nov 19 '16 16:11 underyx

Need to document this functionality

aamalev avatar Nov 19 '16 23:11 aamalev