Tornex.Spec (Tornex v0.5.1)

Copy Markdown View Source

Utilities for handling the OpenAPI specification and its generated client.

Summary

Types

The parsed module documentation for an OpenAPI path in the following ordered list of sections

Functions

Get minimum API key type for the path module.

Determine if there is the path module can return a different response.

Get and split the @moduledoc of a generated path module.

Determine if a generated path module provides public information.

Types

api_key_type()

@type api_key_type() :: :public | :minimal | :limited | :full

parsed_path_module_docs()

@type parsed_path_module_docs() :: [String.t()]

The parsed module documentation for an OpenAPI path in the following ordered list of sections:

  • Path summary
  • Path description
  • Path parameters
  • Potential path response modules (under Torngen.Client.Schema)

Functions

api_key_type(path_module)

@spec api_key_type(path_module :: module()) :: api_key_type()

Get minimum API key type for the path module.

Example

iex> api_key_type(Torngen.Client.Path.Faction.Attacks) :limited

has_extended_response?(path_module)

@spec has_extended_response?(path_module :: module()) :: boolean()

Determine if there is the path module can return a different response.

Typically, the extended/different response occurs when the owner of the resource is making the call on a selection that only requires a public API key.

Examples

iex> has_extended_response?(Torngen.Client.Path.Faction.Attacks) false

iex> has_extended_response?(Torngen.Client.Path.User.Battlestats) false

iex> has_extended_response?(Torngen.Client.Path.User.Icons) true

path_module_docs(path_module)

@spec path_module_docs(path_module :: module()) :: parsed_path_module_docs()

Get and split the @moduledoc of a generated path module.

The response should be of form [summary, description, parameters, response_modules] may change as torngen changes.

Example

iex> path_module_docs(Torngen.Client.Path.Faction.Attacks) [

"Get your faction's detailed attacks.",
"Requires limited access key with faction API access permissions.",
"## Parmeters\n- filters: It's possible to use this query parameter to only get incoming or outgoing attacks / revives\n- limit: N/A\n- sort: Sorted by the greatest timestamps\n- to: Timestamp that sets the upper limit for the data returned\n- from: Timestamp that sets the lower limit for the data returned\n- timestamp: Timestamp to bypass cache\n- comment: Comment for your tool/service/bot/website to be visible in the logs.\n- key: API key (Limited)",
"## Response Module(s)\n- AttacksResponse\n"

]

path_module_public?(path_module)

@spec path_module_public?(path_module :: module()) :: boolean()

Determine if a generated path module provides public information.

For a path to be public:

  • There must not be differing responses depending on the invoker.
  • The minimum API key type must be public.
  • The queries must not require an additional in-game permission such as faction API access. This can be ensuring the API key is a public key.