flask_jsonrpc.contrib.openrpc package¶
Submodules¶
flask_jsonrpc.contrib.openrpc.methods module¶
- openrpc_discover_method(jsonrpc_sites, *, openrpc_schema=None)[source]¶
Create an OpenRPC discover method.
- Parameters:
jsonrpc_sites (list[flask_jsonrpc.site.JSONRPCSite]) – List of JSON-RPC site instances.
openrpc_schema (flask_jsonrpc.contrib.openrpc.typing.OpenRPCSchema | None) – The OpenRPC schema instance. If None, a default schema will be created.
- Returns:
The OpenRPC discover method.
- Return type:
Callable[…, flask_jsonrpc.contrib.openrpc.typing.OpenRPCSchema]
See also
flask_jsonrpc.contrib.openrpc._openrpc_discover_method()
flask_jsonrpc.contrib.openrpc.typing module¶
- class BaseModel[source]¶
Bases:
BaseModel- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class OAuth2FlowType(value, names=_not_given, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
Enum- AUTHORIZATION_CODE = 'authorizationCode'¶
- CLIENT_CREDENTIALS = 'clientCredentials'¶
- PASSWORD = 'password'¶
- class OAuth2Flow(*, type, authorization_url=None, refresh_url=None, token_url=None, scopes=<factory>)[source]¶
Bases:
BaseModel- Parameters:
- type: OAuth2FlowType¶
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class OAuth2(*, flows, type='oauth2', description=None)[source]¶
Bases:
BaseModel- Parameters:
flows (list[OAuth2Flow])
type (Literal['oauth2'])
description (str | None)
- flows: list[OAuth2Flow]¶
- type: t.Literal['oauth2']¶
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class BearerAuth(*, in_, type='bearer', name='Authorization', description=None, scopes=<factory>)[source]¶
Bases:
BaseModel- Parameters:
- type: t.Literal['bearer']¶
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class APIKeyAuth(*, in_, type='apikey', name='api_key', description=None, scopes=<factory>)[source]¶
Bases:
BaseModel- Parameters:
- type: t.Literal['apikey']¶
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class ParamStructure(value, names=_not_given, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
Enum- BY_NAME = 'by-name'¶
- BY_POSITION = 'by-position'¶
- EITHER = 'either'¶
- class SchemaDataType(value, names=_not_given, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
Enum- NULL = 'null'¶
- BOOLEAN = 'boolean'¶
- OBJECT = 'object'¶
- ARRAY = 'array'¶
- INTEGER = 'integer'¶
- STRING = 'string'¶
- class Schema(*, id=None, title=None, format=None, enum=None, type=None, all_of=None, any_of=None, one_of=None, not_=None, pattern=None, minimum=None, maximum=None, exclusive_minimum=None, exclusive_maximum=None, multiple_of=None, min_length=None, max_length=None, properties=None, pattern_properties=None, additional_properties=None, property_names=None, min_properties=None, max_properties=None, required=None, defs=None, items=None, prefix_items=None, contains=None, min_contains=None, max_contains=None, min_items=None, max_items=None, unique_items=None, ref=None, description=None, deprecated=None, default=None, examples=None, read_only=None, write_only=None, const=None, dependent_required=None, dependent_schemas=None, if_=None, then=None, else_=None, schema=None)[source]¶
Bases:
BaseModel- Parameters:
id (str | None)
title (str | None)
format (str | None)
type (SchemaDataType | list[SchemaDataType] | None)
not_ (Schema | None)
pattern (str | None)
minimum (float | None)
maximum (float | None)
exclusive_minimum (float | None)
exclusive_maximum (float | None)
multiple_of (float | None)
min_length (int | None)
max_length (int | None)
additional_properties (Schema | None)
property_names (Schema | None)
min_properties (int | None)
max_properties (int | None)
items (Schema | None)
contains (Schema | None)
min_contains (int | None)
max_contains (int | None)
min_items (int | None)
max_items (int | None)
unique_items (bool | None)
ref (str | None)
description (str | None)
deprecated (bool | None)
default (Any | None)
read_only (bool | None)
write_only (bool | None)
const (Any | None)
if_ (Schema | None)
then (Schema | None)
else_ (Schema | None)
schema (str | None)
- type: SchemaDataType | list[SchemaDataType] | None¶
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class Reference(*, ref)[source]¶
Bases:
BaseModel- Parameters:
ref (str)
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class ContentDescriptor(*, name, schema, summary=None, description=None, required=None, deprecated=None)[source]¶
Bases:
BaseModel- Parameters:
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class Contact(*, name=None, url=None, email=None)[source]¶
Bases:
BaseModel- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class License(*, name, url=None)[source]¶
Bases:
BaseModel- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class Info(*, title, version, description=None, terms_of_service=None, contact=None, license=None)[source]¶
Bases:
BaseModel- Parameters:
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class ServerVariable(*, default, enum=None, description=None)[source]¶
Bases:
BaseModel- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class Server(*, url, name='default', summary=None, description=None, variables=None)[source]¶
Bases:
BaseModel- Parameters:
- variables: dict[str, ServerVariable] | None¶
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class Example(*, name, value, summary=None, description=None, external_value=None)[source]¶
Bases:
BaseModel- Parameters:
- value: t.Any¶
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class ExamplePairing(*, name=None, params=None, summary=None, description=None, result=None)[source]¶
Bases:
BaseModel- Parameters:
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class Link(*, name, summary=None, description=None, method=None, params=None, server=None)[source]¶
Bases:
BaseModel- Parameters:
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class Error(*, code, message, data=None)[source]¶
Bases:
BaseModel- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class ExternalDocumentation(*, url, description=None)[source]¶
Bases:
BaseModel- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class Tag(*, name, summary=None, description=None, external_docs=None)[source]¶
Bases:
BaseModel- Parameters:
name (str)
summary (str | None)
description (str | None)
external_docs (ExternalDocumentation | None)
- external_docs: ExternalDocumentation | None¶
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class Components(*, content_descriptors=None, schemas=None, examples=None, links=None, errors=None, example_pairing_objects=None, tags=None, x_security_schemes=None)[source]¶
Bases:
BaseModel- Parameters:
content_descriptors (dict[str, ContentDescriptor] | None)
example_pairing_objects (dict[str, ExamplePairing] | None)
x_security_schemes (dict[str, OAuth2 | BearerAuth | APIKeyAuth] | None)
- content_descriptors: dict[str, ContentDescriptor] | None¶
- example_pairing_objects: dict[str, ExamplePairing] | None¶
- x_security_schemes: dict[str, OAuth2 | BearerAuth | APIKeyAuth] | None¶
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class Method(*, name, params, result, tags=None, summary=None, description=None, external_docs=None, deprecated=None, servers=None, errors=None, links=None, param_structure=None, examples=None, x_security=None)[source]¶
Bases:
BaseModel- Parameters:
name (str)
params (list[ContentDescriptor])
result (ContentDescriptor)
summary (str | None)
description (str | None)
external_docs (ExternalDocumentation | None)
deprecated (bool | None)
param_structure (ParamStructure | None)
examples (list[ExamplePairing] | None)
- params: list[ContentDescriptor]¶
- result: ContentDescriptor¶
- external_docs: ExternalDocumentation | None¶
- param_structure: ParamStructure | None¶
- examples: list[ExamplePairing] | None¶
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class OpenRPCSchema(*, info, openrpc='1.3.2', methods=[], servers=Server(url='localhost', name='default', summary=None, description=None, variables=None), components=None, external_docs=None)[source]¶
Bases:
BaseModel- Parameters:
info (Info)
openrpc (str)
components (Components | None)
external_docs (ExternalDocumentation | None)
- components: Components | None¶
- external_docs: ExternalDocumentation | None¶
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
flask_jsonrpc.contrib.openrpc.utils module¶
- class BaseModel[source]¶
Bases:
BaseModel- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}¶
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class MethodExtendSchema(*, name=None, params=None, result=None, tags=None, summary=None, description=None, external_docs=None, deprecated=None, servers=None, errors=None, links=None, param_structure=None, examples=None, x_security=None)[source]¶
Bases:
BaseModel- Parameters:
name (str | None)
params (list[ContentDescriptor] | None)
result (ContentDescriptor | None)
summary (str | None)
description (str | None)
external_docs (ExternalDocumentation | None)
deprecated (bool | None)
param_structure (ParamStructure | None)
examples (list[ExamplePairing] | None)
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}¶
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- extend_schema(name=None, params=None, tags=None, summary=None, description=None, external_docs=None, result=None, deprecated=None, servers=None, errors=None, links=None, param_structure=None, examples=None, x_security=None)[source]¶
Decorator to extend the schema of a JSON-RPC method.
- Parameters:
name (str | None) – The name of the method.
params (list[flask_jsonrpc.contrib.openrpc.typing.ContentDescriptor] | None) – The list of parameter descriptors.
tags (list[flask_jsonrpc.contrib.openrpc.typing.Tag] | None) – The list of tags.
summary (str | None) – The summary of the method.
description (str | None) – The description of the method.
external_docs (flask_jsonrpc.contrib.openrpc.typing.ExternalDocumentation | None) – The external documentation.
result (flask_jsonrpc.contrib.openrpc.typing.ContentDescriptor | None) – The result descriptor.
deprecated (bool | None) – Whether the method is deprecated.
servers (list[flask_jsonrpc.contrib.openrpc.typing.Server] | None) – The list of servers.
errors (list[flask_jsonrpc.contrib.openrpc.typing.Error] | None) – The list of errors.
links (list[flask_jsonrpc.contrib.openrpc.typing.Link] | None) – The list of links.
param_structure (flask_jsonrpc.contrib.openrpc.typing.ParamStructure | None) – The parameter structure.
examples (list[flask_jsonrpc.contrib.openrpc.typing.ExamplePairing] | None) – The list of example pairings.
x_security (dict[str, list[str]] | None) – The security requirements.
- Returns:
The decorator function.
- Return type:
flask_jsonrpc.contrib.openrpc.wrappers module¶
Module contents¶
- class OpenRPC(app=None, jsonrpc_app=None, *, openrpc_schema=None)[source]¶
Bases:
OpenRPCExtendSchemaDecoratorMixinFlask-JSONRPC OpenRPC contrib extension.
- Parameters:
app (flask.Flask | None) – The Flask application instance. Defaults to None.
jsonrpc_app (flask_jsonrpc.app.JSONRPC | None) – The JSON-RPC application instance. Defaults to None.
openrpc_schema (flask_jsonrpc.contrib.openrpc.typing.OpenRPCSchema | None) – The OpenRPC schema instance. Defaults to None.
- jsonrpc_app¶
The JSON-RPC application instance.
- Type:
flask_jsonrpc.app.JSONRPC | None
- openrpc_schema¶
The OpenRPC schema instance.
- Type:
- init_app(app, jsonrpc_app)[source]¶
Initialize the OpenRPC extension with the Flask and JSON-RPC application instances.
Registers the OpenRPC discover method to the JSON-RPC site.
- Parameters:
app (flask.Flask) – The Flask application instance.
jsonrpc_app (flask_jsonrpc.app.JSONRPC) – The JSON-RPC application instance.
self (Self)
- Return type:
None