I'm trying to find a way to configure my connexion app. I want to be able to inject a variable that can affect the behavior of the operations associated to a route.
At first, I tried to use the MethodResolver so I could pass class_argument to inject dependencies but I prefer to keep explicit routing with clear operationId. (plus I have multiple /foooo/bar/{id} routes and the doc is no clear on how I should manage it : FooooView ? BarView in foo-oo module ?)
For now the operationId functions call a const which is an instance of a class to which I can give new parameters if my code evolves.
class ApiDependencies:
def __init__(self, criteria_collection):
self.criteria_collection = criteria_collection
criteria_collection = init_default_criteria_collection()
dependencies = ApiDependencies(criteria_collection)
from controller.api.dependencies_injection import dependencies
def status():
return "Criteria : " + criteria_collection, 200
but for testing for example, I would like to be able to give this parameters directly to the app itself and access it in my operationId function.
app = AsyncApp(__name__)
app.add_api(
"api.yaml",
resolver=RelativeResolver("controller.api.routes"),
config={criteria_collection : criteria_collection}
)
def status():
return "Criteria : " + connexion.config.criteria_collection, 200
Is it possible ? Did I miss something in the doc ? Thanks for your help