ApifyClient.Generator.Naming (apify_client v1.0.0)

Copy Markdown View Source

Naming rules shared by the generator plugins.

The Apify API uses camelCase for fields and parameters, kebab-case for path segments and a few UPPER_SNAKE keys (usage services, run status counts). The generated client uses snake_case everywhere and keeps the original names only where they go over the wire.

Generation-time only

Runs under mix apify.gen only; lives in dev/ because the plugins depend on the dev-only :oapi_generator.

Summary

Functions

Converts a path segment to a module name segment.

Converts an API name to snake_case.

Maps each name to its snake_case form, raising if two names collide.

Functions

camel(segment)

@spec camel(String.t()) :: String.t()

Converts a path segment to a module name segment.

iex> camel("key-value-stores")
"KeyValueStores"

snake(name)

@spec snake(String.t()) :: String.t()

Converts an API name to snake_case.

iex> snake("defaultDatasetId")
"default_dataset_id"
iex> snake("isPPEPlatformUsagePaidByUser")
"is_ppe_platform_usage_paid_by_user"
iex> snake("publicActorRunStats30Days")
"public_actor_run_stats30_days"
iex> snake("TIMED-OUT")
"timed_out"
iex> snake("_id")
"_id"

snake_map(names, context)

@spec snake_map([String.t()], String.t()) :: %{required(String.t()) => String.t()}

Maps each name to its snake_case form, raising if two names collide.