def test_merge_examples_no_body_examples(): parameter_examples = [ { "type": "query", "name": "queryParam", "examples": ["example1", "example2", "example3"] }, { "type": "headers", "name": "headerParam", "examples": ["example1"] }, { "type": "path_parameters", "name": "pathParam", "examples": ["example1", "example2"] }, ] request_body_examples = {} result = examples.merge_examples(parameter_examples, request_body_examples) assert len(result) == 3 assert all("query" in static_parameters and "queryParam" in static_parameters["query"] for static_parameters in result) assert all("headers" in static_parameters and "headerParam" in static_parameters["headers"] for static_parameters in result) assert all("path_parameters" in static_parameters and "pathParam" in static_parameters["path_parameters"] for static_parameters in result)
def test_merge_examples_with_empty_examples(): parameter_examples = [] request_body_examples = { "type": "body", "examples": [], } result = examples.merge_examples(parameter_examples, request_body_examples) assert len(result) == 0
def test_merge_examples_with_body_examples(): parameter_examples = [] request_body_examples = { "type": "body", "examples": [{"foo": "example1"}, {"foo": "example2"}, {"foo": "example3"}], } result = examples.merge_examples(parameter_examples, request_body_examples) assert len(result) == 3 assert all("body" in static_parameters and "foo" in static_parameters["body"] for static_parameters in result)