Skip to content

Support example static values for collection elements #17

@apenlor

Description

@apenlor

Right now there is no option to generate a collection with static values, they always have to be random

@PactDslBodyBuilder
public class Student {

    @Example("idSample")
    private List<String> id;
}

Output

{
  "id" : [ "fVuayin3uOzdV" ]
}

As a developer, I need to have the option to define those values.

One alternative may be to accept as example collections in string format, like these:

@Example("[\"one\", \"two\", \"three\"]")
private List<String> stringList;

@Example("[1, 2, 3]")
private Set<Integer> integerSet;

@Example("{\"key1\": 1, \"key2\": 2, \"key3\": 3}")
private Map<String, Integer> stringToIntegerMap;

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    Status

    Planning

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions