Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support example static values for collection elements #17

Open
apenlor opened this issue Nov 1, 2023 · 0 comments
Open

Support example static values for collection elements #17

apenlor opened this issue Nov 1, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@apenlor
Copy link
Contributor

apenlor commented Nov 1, 2023

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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Development

No branches or pull requests

2 participants