OpenAPISpec#

class langchain_community.utilities.openapi.OpenAPISpec[source]#

OpenAPI Model that removes mis-formatted parts of the spec.

Attributes

base_url

Get the base url.

openapi

Methods

__init__()

from_file(path)

Get an OpenAPI spec from a file path.

from_spec_dict(spec_dict)

Get an OpenAPI spec from a dict.

from_text(text)

Get an OpenAPI spec from a text.

from_url(url)

Get an OpenAPI spec from a URL.

get_cleaned_operation_id(operation,Β path,Β method)

Get a cleaned operation id from an operation id.

get_methods_for_path(path)

Return a list of valid methods for the specified path.

get_operation(path,Β method)

Get the operation object for a given path and HTTP method.

get_parameters_for_operation(operation)

Get the components for a given operation.

get_parameters_for_path(path)

get_referenced_schema(ref)

Get a schema (or nested reference) or err.

get_request_body_for_operation(operation)

Get the request body for a given operation.

get_schema(schema[,Β depth,Β max_depth])

parse_obj(obj)

__init__()#
classmethod from_file(path: str | Path) β†’ OpenAPISpec[source]#

Get an OpenAPI spec from a file path.

Parameters:

path (str | Path) –

Return type:

OpenAPISpec

classmethod from_spec_dict(spec_dict: dict) β†’ OpenAPISpec[source]#

Get an OpenAPI spec from a dict.

Parameters:

spec_dict (dict) –

Return type:

OpenAPISpec

classmethod from_text(text: str) β†’ OpenAPISpec[source]#

Get an OpenAPI spec from a text.

Parameters:

text (str) –

Return type:

OpenAPISpec

classmethod from_url(url: str) β†’ OpenAPISpec[source]#

Get an OpenAPI spec from a URL.

Parameters:

url (str) –

Return type:

OpenAPISpec

static get_cleaned_operation_id(operation: Operation, path: str, method: str) β†’ str[source]#

Get a cleaned operation id from an operation id.

Parameters:
  • operation (Operation) –

  • path (str) –

  • method (str) –

Return type:

str

get_methods_for_path(path: str) β†’ List[str][source]#

Return a list of valid methods for the specified path.

Parameters:

path (str) –

Return type:

List[str]

get_operation(path: str, method: str) β†’ Operation[source]#

Get the operation object for a given path and HTTP method.

Parameters:
  • path (str) –

  • method (str) –

Return type:

Operation

get_parameters_for_operation(operation: Operation) β†’ List[Parameter][source]#

Get the components for a given operation.

Parameters:

operation (Operation) –

Return type:

List[Parameter]

get_parameters_for_path(path: str) β†’ List[Parameter][source]#
Parameters:

path (str) –

Return type:

List[Parameter]

get_referenced_schema(ref: Reference) β†’ Schema[source]#

Get a schema (or nested reference) or err.

Parameters:

ref (Reference) –

Return type:

Schema

get_request_body_for_operation(operation: Operation) β†’ RequestBody | None[source]#

Get the request body for a given operation.

Parameters:

operation (Operation) –

Return type:

Optional[RequestBody]

get_schema(schema: Reference | Schema, depth: int = 0, max_depth: int | None = None) β†’ Schema[source]#
Parameters:
  • schema (Union[Reference, Schema]) –

  • depth (int) –

  • max_depth (Optional[int]) –

Return type:

Schema

classmethod parse_obj(obj: dict) β†’ OpenAPISpec[source]#
Parameters:

obj (dict) –

Return type:

OpenAPISpec