langchain.utilities.openapi.OpenAPISpec¶
- class langchain.utilities.openapi.OpenAPISpec(*, openapi: str = '3.1.0', info: Info, jsonSchemaDialect: Optional[str] = None, servers: List[Server] = [Server(url='/', description=None, variables=None)], paths: Optional[Dict[str, PathItem]] = None, webhooks: Optional[Dict[str, Union[PathItem, Reference]]] = None, components: Optional[Components] = None, security: Optional[List[Dict[str, List[str]]]] = None, tags: Optional[List[Tag]] = None, externalDocs: Optional[ExternalDocumentation] = None)[source]¶
Bases:
OpenAPIOpenAPI Model that removes misformatted parts of the spec.
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
- param components: Optional[openapi_schema_pydantic.v3.v3_1_0.components.Components] = None¶
An element to hold various schemas for the document.
- param externalDocs: Optional[openapi_schema_pydantic.v3.v3_1_0.external_documentation.ExternalDocumentation] = None¶
Additional external documentation.
- param info: openapi_schema_pydantic.v3.v3_1_0.info.Info [Required]¶
REQUIRED. Provides metadata about the API. The metadata MAY be used by tooling as required.
- param jsonSchemaDialect: Optional[str] = None¶
The default value for the $schema keyword within [Schema Objects](#schemaObject) contained within this OAS document. This MUST be in the form of a URI.
- param openapi: str = '3.1.0'¶
REQUIRED. This string MUST be the [version number](#versions) of the OpenAPI Specification that the OpenAPI document uses. The openapi field SHOULD be used by tooling to interpret the OpenAPI document. This is not related to the API [info.version](#infoVersion) string.
- param paths: Optional[Dict[str, openapi_schema_pydantic.v3.v3_1_0.path_item.PathItem]] = None¶
The available paths and operations for the API.
- param security: Optional[List[Dict[str, List[str]]]] = None¶
A declaration of which security mechanisms can be used across the API. The list of values includes alternative security requirement objects that can be used. Only one of the security requirement objects need to be satisfied to authorize a request. Individual operations can override this definition. To make security optional, an empty security requirement ({}) can be included in the array.
- param servers: List[openapi_schema_pydantic.v3.v3_1_0.server.Server] = [Server(url='/', description=None, variables=None)]¶
An array of Server Objects, which provide connectivity information to a target server. If the servers property is not provided, or is an empty array, the default value would be a [Server Object](#serverObject) with a [url](#serverUrl) value of /.
- param tags: Optional[List[openapi_schema_pydantic.v3.v3_1_0.tag.Tag]] = None¶
A list of tags used by the document with additional metadata. The order of the tags can be used to reflect on their order by the parsing tools. Not all tags that are used by the [Operation Object](#operationObject) must be declared. The tags that are not declared MAY be organized randomly or based on the tools’ logic. Each tag name in the list MUST be unique.
- param webhooks: Optional[Dict[str, Union[openapi_schema_pydantic.v3.v3_1_0.path_item.PathItem, openapi_schema_pydantic.v3.v3_1_0.reference.Reference]]] = None¶
The incoming webhooks that MAY be received as part of this API and that the API consumer MAY choose to implement. Closely related to the callbacks feature, this section describes requests initiated other than by an API call, for example by an out of band registration. The key name is a unique string to refer to each webhook, while the (optionally referenced) Path Item Object describes a request that may be initiated by the API provider and the expected responses. An [example](../examples/v3.1/webhook-example.yaml) is available.
- classmethod from_file(path: Union[str, Path]) OpenAPISpec[source]¶
Get an OpenAPI spec from a file path.
- classmethod from_spec_dict(spec_dict: dict) OpenAPISpec[source]¶
Get an OpenAPI spec from a dict.
- classmethod from_text(text: str) OpenAPISpec[source]¶
Get an OpenAPI spec from a text.
- classmethod from_url(url: str) OpenAPISpec[source]¶
Get an OpenAPI spec from a URL.
- static get_cleaned_operation_id(operation: Operation, path: str, method: str) str[source]¶
Get a cleaned operation id from an operation id.
- get_methods_for_path(path: str) List[str][source]¶
Return a list of valid methods for the specified path.
- get_operation(path: str, method: str) Operation[source]¶
Get the operation object for a given path and HTTP method.
- get_parameters_for_operation(operation: Operation) List[Parameter][source]¶
Get the components for a given operation.
- get_request_body_for_operation(operation: Operation) Optional[RequestBody][source]¶
Get the request body for a given operation.
- classmethod parse_obj(obj: dict) OpenAPISpec[source]¶
- property base_url: str¶
Get the base url.