Skip to contents

Choose fixture values using reviewed overrides followed by parameter or media examples, schema examples, defaults, enums, and type fixtures.

Usage

operation_fixtures(
  operations,
  overrides = list(),
  mode = c("default", "minimal")
)

Arguments

operations

Supported operation record or named list of records.

overrides

Reviewed per-operation fixture input values.

mode

Default exercises optional inputs. Explicit minimal mode omits optional parameters and optional bodies unless overridden, and records their names in each input list's omitted_inputs attribute.

Value

A named list of per-operation input lists. Each input list records where every value came from in its input_sources attribute: override, parameter_example, media_example, schema_example, schema_default, schema_enum, schema_const, schema_placeholder (Swagger UI's 'string'), or synthesized (built from the type). Stops when a fixture cannot be selected or fails supported constraints.

Details

The selected value must satisfy supported type, enum, numeric, string-length, and pattern constraints. An invalid selected candidate raises an error rather than falling through to a lower-priority source. Automatic selection uses the singular example field; plural examples collections require a reviewed override to select a member. Empty query values require allowEmptyValue, matching generated wrapper validation. Examples never become public function defaults. Minimal mode reduces coverage; omission can activate a wrapper default and does not guarantee wire omission. Explicit NULL, empty strings, FALSE, and zero are selected values and remain subject to validation. Contradictory declarations are separately available from read_operations() as fixture_diagnostics; optional contradictions do not prevent rendering. Schema examples are never executed. Candidate inputs are not independent expected request or response contracts.

See also

Examples

schema <- system.file('catalogue/schema.json', package = 'specmill')
operation_fixtures(read_operations(schema)$operations)
#> $get_item
#> $get_item$item_id
#> [1] "example"
#> 
#> $get_item$language
#> [1] "en"
#> 
#> attr(,"input_sources")
#>       item_id      language 
#> "synthesized" "schema_enum" 
#> 
#> $list_items
#> $list_items$page
#> [1] 1
#> 
#> attr(,"input_sources")
#>          page 
#> "synthesized" 
#> 
#> $create_item
#> $create_item$body
#> $create_item$body$title
#> [1] "example"
#> 
#> $create_item$body$count
#> [1] 1
#> 
#> 
#> attr(,"input_sources")
#>          body 
#> "synthesized" 
#> 
#> $refresh
#> named list()
#> attr(,"input_sources")
#> character(0)
#>