OpenApiCodeGen.Ast (openapi_codegen v0.1.0)

Contains functions to help with Ast operations.

Summary

Functions

Generates an interpolated string given a URL path.

Converts a string or atom into a variable. It also checks for reserved words and appends _param to the variable name if it is a reserved word.

Converts the AST into a string, formats it, styles it and writes it to a file and returns the path to the file.

Converts a string or atom into a variable.

Functions

Link to this function

generate_path_interpolation(client_module_name, path)

Generates an interpolated string given a URL path.

Link to this function

sanitize_name(name, transform \\ :underscore)

@spec sanitize_name(binary(), :camelize | :underscore) :: atom()

Converts a string or atom into a variable. It also checks for reserved words and appends _param to the variable name if it is a reserved word.

Link to this function

to_file!(ast, key, path)

@spec to_file!(Macro.t(), String.t(), Path.t()) :: Path.t()

Converts the AST into a string, formats it, styles it and writes it to a file and returns the path to the file.

Link to this function

to_var(name, context)

@spec to_var(binary() | atom(), atom()) :: Macro.t()

Converts a string or atom into a variable.

Examples

iex> to_var(:my_var, __MODULE__)
{:my_var, [], __MODULE__}

iex> to_var("my_var", __MODULE__)
{:my_var, [], __MODULE__}

iex> to_var("myVar", __MODULE__)
{:my_var, [], __MODULE__}