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
@type api_key_type() :: :public | :minimal | :limited | :full
@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
@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
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
@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"]
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.