MCPcopy
hub / github.com/sparckles/Robyn / add_openapi_path_obj

Method add_openapi_path_obj

robyn/openapi.py:266–359  ·  view source on GitHub ↗

Adds the given path to openapi spec @param route_type: str the http method as string (get, post ...) @param endpoint: str the endpoint to be added @param openapi_name: str the name of the endpoint @param openapi_tags: list[str] for grouping of endpoints

(
        self,
        route_type: str,
        endpoint: str,
        openapi_name: str,
        openapi_tags: list[str],
        handler: Callable,
        auth_required: bool = False,
        meta: "RouteOpenAPIMeta | None" = None,
    )

Source from the content-addressed store, hash-verified

264 del components[key]
265
266 def add_openapi_path_obj(
267 self,
268 route_type: str,
269 endpoint: str,
270 openapi_name: str,
271 openapi_tags: list[str],
272 handler: Callable,
273 auth_required: bool = False,
274 meta: "RouteOpenAPIMeta | None" = None,
275 ):
276 """
277 Adds the given path to openapi spec
278
279 @param route_type: str the http method as string (get, post ...)
280 @param endpoint: str the endpoint to be added
281 @param openapi_name: str the name of the endpoint
282 @param openapi_tags: list[str] for grouping of endpoints
283 @param handler: Callable the handler function for the endpoint
284 @param auth_required: bool whether the route requires authentication (adds a security requirement)
285 @param meta: RouteOpenAPIMeta | None per-route OpenAPI metadata from the decorator
286 """
287
288 if self.openapi_file_override:
289 return
290
291 if meta is None:
292 meta = RouteOpenAPIMeta()
293
294 if not meta.include_in_schema:
295 return
296
297 query_params = None
298 request_body = None
299 return_annotation = None
300
301 signature = inspect.signature(handler)
302 openapi_description = inspect.getdoc(handler) or ""
303
304 if signature:
305 parameters = signature.parameters
306
307 if "query_params" in parameters:
308 query_params = parameters["query_params"].default
309
310 if query_params is Signature.empty:
311 query_params = None
312
313 if "body" in parameters:
314 request_body = parameters["body"].default
315
316 if request_body is Signature.empty:
317 request_body = None
318
319 # priority to typing
320 for parameter in parameters:
321 param_annotation = parameters[parameter].annotation
322
323 if inspect.isclass(param_annotation):

Calls 3

get_path_objMethod · 0.95
is_pydantic_modelFunction · 0.90
RouteOpenAPIMetaClass · 0.85