Class MockDataGenerator


  • public class MockDataGenerator
    extends Object
    Generates realistic mock values for OpenAPI schema properties.

    Values are chosen using the following priority order:

    1. Schema format (date, date-time, email, uri, uuid, ipv4, hostname, byte, password, …)
    2. Field-name heuristic powered by Datafaker (case-insensitive, separator-agnostic lookup)
    3. Schema type fallback (generic string / integer / number / boolean)

    The generator uses a seeded Faker so results are deterministic and reproducible across test runs.

    Numeric and string constraints (minimum, maximum, minLength, maxLength) are respected when present.

    • Method Detail

      • generate

        public static Object generate​(String fieldName,
                                      io.swagger.v3.oas.models.media.Schema<?> schema)
        Generates a realistic mock value for the given field name and schema.
        Parameters:
        fieldName - the property name (may be null for anonymous/array items)
        schema - the OpenAPI schema for this field
        Returns:
        a mock value compatible with the schema type