ExMCP.Testing.SchemaGenerator (ex_mcp v0.9.0)

View Source

Generates valid test values from JSON Schema definitions.

Useful for conformance testing, property-based testing, and automated tool exploration. Given a JSON Schema inputSchema, produces minimal valid arguments that satisfy the schema constraints.

Examples

iex> schema = %{"type" => "object", "properties" => %{
...>   "name" => %{"type" => "string"},
...>   "age" => %{"type" => "integer"}
...> }, "required" => ["name"]}
iex> ExMCP.Testing.SchemaGenerator.generate_args(schema)
%{"name" => "test", "age" => 1}

Summary

Functions

Generate a map of arguments from a JSON Schema object definition.

Generate a single value from a JSON Schema type definition.

Functions

generate_args(schema)

@spec generate_args(map() | nil) :: map()

Generate a map of arguments from a JSON Schema object definition.

Returns a map with generated values for all properties. Required properties always get values; optional properties get values too (conformance tests may validate them).

generate_value(schema)

@spec generate_value(map() | nil) :: term()

Generate a single value from a JSON Schema type definition.