View Source OpenApiTypesense

Restful client for Typesense with adherence to Open API spec 3 (formerly Swagger)

Dependabot Hex.pm Hexdocs.pm Hex.pm Typesense badge Coverage Status CI Status

TODO

  • Custom Http client adapter (currently Req)

Installation

If available in Hex, the package can be installed by adding open_api_typesense to your list of dependencies in mix.exs:

def deps do
  [
    {:open_api_typesense, "~> 0.4"}

    # Or from GitHub repository, if you want the latest greatest from main branch
    {:open_api_typesense, git: "https://github.com/jaeyson/open_api_typesense.git"}
  ]
end

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/open_api_typesense.

Getting started

Adding credentials

Spin up local Typesense instance

docker compose up -d

# check if "peer refreshed" in logs
docker container logs --follow --tail 50 typesense
# e.g. config/runtime.exs
if config_env() == :prod do # if you'll use this in prod environment
  config :open_api_typesense,
    api_key: "xyz",
    host: "localhost",
    port: 8108,
    scheme: "http",
    options: %{}
  ...

Note: The options key can be used to pass additional configuration options such as custom Finch instance or receive timeout settings. You can add any options supported by Req here. For more details check Req documentation.

Note: If you use this for adding tests in your app, you might want to add this in config/test.exs:

For Cloud hosted, you can generate and obtain the credentials from cluster instance admin interface:

config :open_api_typesense,
  api_key: "credential", # Admin API key
  host: "111222333aaabbbcc-9.x9.typesense.net", # Nodes
  port: 443,
  scheme: "https",
  options: %{}