mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-14 15:43:33 +01:00
* r * fix * sw * x * s * . * . * . * CreateTypeFromJObject * . * . * f * c * . * . * . * . * . * . * ok * , * . * . * . * . * n * pact * fix * schema * null * fluent * r * -p * . * . * refs * .
23 lines
745 B
C#
23 lines
745 B
C#
using RandomDataGenerator.FieldOptions;
|
|
using RandomDataGenerator.Randomizers;
|
|
using WireMock.Net.OpenApiParser.Settings;
|
|
|
|
namespace WireMock.Net.OpenApiParser.ConsoleApp;
|
|
|
|
public class DynamicDataGeneration : WireMockOpenApiParserDynamicExampleValues
|
|
{
|
|
public override string String
|
|
{
|
|
get
|
|
{
|
|
// Since you have your Schema, you can get if max-length is set. You can generate accurate examples with this settings
|
|
var maxLength = Schema.MaxLength ?? 9;
|
|
|
|
return RandomizerFactory.GetRandomizer(new FieldOptionsTextRegex
|
|
{
|
|
Pattern = $"[0-9A-Z]{{{maxLength}}}"
|
|
}).Generate() ?? "example-string";
|
|
}
|
|
set { }
|
|
}
|
|
} |