ft3.api.utl module¶
Api utility functions.
- api_from_package(name: str, version: str, api_path: str, include_heartbeat: bool = True, include_version_prefix: bool = False, include_default_response_headers: bool = True, lazy_docs: bool = True) Api¶
Generate a RESTful API from passed python package name.
- filter_to_unique_params(parameters: list[Parameter]) list[Parameter]¶
Filters to a unique parameter set.
- operation_from_object(cls: type[Object], method: Literal['delete', 'get', 'options', 'patch', 'post', 'put'], parent_tags: list[str] | None = None, parent_path_parameters: list[Parameter] | None = None, include_default_response_headers: bool = True, include_docs: bool = True) Operation | None¶
Generate RESTful API
Operationfrom anObject.
- parameters_from_object(cls: type[Object], include_schema_details: bool = True) list[Parameter]¶
Generate RESTful API
ParemeterObjects from anObject.
- paths_from_object(cls: type[Object], parent_tags: list[str] | None = None, parent_path_parameters: list[Parameter] | None = None, include_default_response_headers: bool = True, include_docs: bool = True) list[Path]¶
Generate RESTful API
PathObjects from anObject.
- response_type_from_object(cls: type[Object], method: Literal['delete', 'get', 'options', 'patch', 'post', 'put']) Literal['EMPTY', 'MANY', 'ONE']¶
Calculate response type from an
Object.
- runtime_api_from_package(name: str, version: str, api_path: str, include_heartbeat: bool = True, include_version_prefix: bool = False, include_default_response_headers: bool = True) Api¶
Generate a RESTful API with only runtime dispatch metadata.
- serve(package: str, port: int, version: str, api_path: str, include_heartbeat: bool, include_version_prefix: bool, include_default_response_headers: bool, lazy_docs: bool = True) None¶
CLI entrypoint for serving an application.
Specify the name of your API package to serve it via simple http server.
Example¶
$ ft3 api ft3.templateYou may specify a port as a positional argument following the package name. By default, your application will be served on port 80 without generated docs for faster startup. Use `--generate-docs` to serve Swagger at http://localhost/swagger.
DISCLAIMER¶
$ ft3 api serveis highly insecure and should NOT be used in any production environment.This may change in the future.