Files
WireMock.Net/examples/WireMock.Net.OpenApiParser.ConsoleApp/DynamicDataGeneration.cs
Stef Heyenrath 54edf0bebc Add link to TIOBE Index on main page + fix issues (#1137)
* Add TIOBE + include SonarAnalyzer.CSharp

* .

* cp

* Copyright © WireMock.Net

* more fixes

* fix

* xpath

* if (Matchers == null || !Matchers.Any())

* if (Matchers != null)

* ?

* .

* .
2024-07-18 18:06:04 +02:00

24 lines
761 B
C#

// Copyright © WireMock.Net
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";
}
}
}