oas2mcp.utils.lookup¶
Lookup helpers for normalized catalogs.
- Purpose:
Provide convenient query helpers over normalized
ApiCatalogobjects so later classifiers and agents can work with targeted slices of the spec.- Design:
Keep helpers deterministic and side-effect free.
Return
Nonefor missing singular lookups rather than raising.Preserve original operation objects rather than copying them.
Examples
operation = get_operation(catalog, method="GET", path="/pets/{petId}")
tagged = list_operations_by_tag(catalog, tag="pet")
Functions¶
|
Return one operation by HTTP method and path. |
|
Return one operation by |
|
Return one security scheme by name. |
Return all mutating operations. |
|
Return all operations associated with a tag. |
|
|
Return all non-mutating operations. |
Module Contents¶
- oas2mcp.utils.lookup.get_operation(catalog: oas2mcp.models.normalized.ApiCatalog, *, method: str, path: str) oas2mcp.models.normalized.ApiOperation | None[source][source]¶
Return one operation by HTTP method and path.
- Parameters:
catalog – The normalized API catalog.
method – The HTTP method to match.
path – The normalized or raw operation path.
- Returns:
The matching operation if found, otherwise
None.- Raises:
None. –
Examples
operation = get_operation( catalog, method="GET", path="/pets/{petId}", )
- oas2mcp.utils.lookup.get_operation_by_id(catalog: oas2mcp.models.normalized.ApiCatalog, *, operation_id: str) oas2mcp.models.normalized.ApiOperation | None[source][source]¶
Return one operation by
operationId.- Parameters:
catalog – The normalized API catalog.
operation_id – The target
operationId.
- Returns:
The matching operation if found, otherwise
None.- Raises:
None. –
Examples
operation = get_operation_by_id( catalog, operation_id="getPetById", )
- oas2mcp.utils.lookup.get_security_scheme(catalog: oas2mcp.models.normalized.ApiCatalog, *, name: str) oas2mcp.models.normalized.ApiSecurityScheme | None[source][source]¶
Return one security scheme by name.
- Parameters:
catalog – The normalized API catalog.
name – The security scheme name.
- Returns:
The matching security scheme if found, otherwise
None.- Raises:
None. –
Examples
scheme = get_security_scheme(catalog, name="api_key")
- oas2mcp.utils.lookup.list_mutating_operations(catalog: oas2mcp.models.normalized.ApiCatalog) list[oas2mcp.models.normalized.ApiOperation][source][source]¶
Return all mutating operations.
- Parameters:
catalog – The normalized API catalog.
- Returns:
A list of mutating operations.
- Raises:
None. –
Examples
mutating = list_mutating_operations(catalog)
- oas2mcp.utils.lookup.list_operations_by_tag(catalog: oas2mcp.models.normalized.ApiCatalog, *, tag: str) list[oas2mcp.models.normalized.ApiOperation][source][source]¶
Return all operations associated with a tag.
- Parameters:
catalog – The normalized API catalog.
tag – The tag name to match.
- Returns:
A list of matching operations.
- Raises:
None. –
Examples
pet_operations = list_operations_by_tag(catalog, tag="pet")
- oas2mcp.utils.lookup.list_read_operations(catalog: oas2mcp.models.normalized.ApiCatalog) list[oas2mcp.models.normalized.ApiOperation][source][source]¶
Return all non-mutating operations.
- Parameters:
catalog – The normalized API catalog.
- Returns:
A list of read-oriented operations.
- Raises:
None. –
Examples
reads = list_read_operations(catalog)