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

Method get_path_obj

robyn/openapi.py:395–527  ·  view source on GitHub ↗

Get the "path" openapi object according to spec @param endpoint: str the endpoint to be added @param name: str the name of the endpoint @param description: str | None short description of the endpoint (to be fetched from the endpoint definition by default) @

(
        self,
        endpoint: str,
        name: str,
        description: str,
        tags: list[str],
        query_params: str_typed_dict | None,
        request_body: str_typed_dict | None,
        return_annotation: str_typed_dict | None,
        auth_required: bool = False,
        meta: "RouteOpenAPIMeta | None" = None,
    )

Source from the content-addressed store, hash-verified

393 self._merge_component_schemas(subrouter_schemas)
394
395 def get_path_obj(
396 self,
397 endpoint: str,
398 name: str,
399 description: str,
400 tags: list[str],
401 query_params: str_typed_dict | None,
402 request_body: str_typed_dict | None,
403 return_annotation: str_typed_dict | None,
404 auth_required: bool = False,
405 meta: "RouteOpenAPIMeta | None" = None,
406 ) -> tuple[str, dict]:
407 """
408 Get the "path" openapi object according to spec
409
410 @param endpoint: str the endpoint to be added
411 @param name: str the name of the endpoint
412 @param description: str | None short description of the endpoint (to be fetched from the endpoint definition by default)
413 @param tags: list[str] for grouping of endpoints
414 @param query_params: TypedDict | None query params for the function
415 @param request_body: TypedDict | None request body for the function
416 @param return_annotation: TypedDict | None return type of the endpoint handler
417 @param auth_required: bool whether the route requires authentication
418 @param meta: RouteOpenAPIMeta | None per-route OpenAPI metadata (status_code, responses, ...)
419
420 @return: (str, dict) a tuple containing the endpoint with path params wrapped in braces and the "path" openapi object
421 according to spec
422 """
423
424 if meta is None:
425 meta = RouteOpenAPIMeta()
426
427 if not description:
428 description = "No description provided"
429
430 openapi_path_object: dict = {
431 "summary": name,
432 "description": description,
433 "parameters": [],
434 "tags": tags,
435 }
436
437 if meta.operation_id is not None:
438 openapi_path_object["operationId"] = meta.operation_id
439
440 if meta.deprecated:
441 openapi_path_object["deprecated"] = True
442
443 # auth_required routes advertise every configured security scheme so the
444 # Swagger UI "Authorize" lock appears on them (#1122, #1339).
445 if auth_required and self._security_scheme_names:
446 openapi_path_object["security"] = [{scheme_name: []} for scheme_name in self._security_scheme_names]
447
448 # robyn has paths like /:url/:etc whereas openapi requires path like /{url}/{path}
449 # this function is used for converting path params to the required form
450 # initialized with endpoint for handling endpoints without path params
451 endpoint_with_path_params_wrapped_in_braces = endpoint
452

Callers 1

add_openapi_path_objMethod · 0.95

Calls 7

get_openapi_typeMethod · 0.95
get_schema_objectMethod · 0.95
_build_responsesMethod · 0.95
is_pydantic_modelFunction · 0.90
RouteOpenAPIMetaClass · 0.85

Tested by

no test coverage detected