-
-
Notifications
You must be signed in to change notification settings - Fork 213
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
Provide open api schema to dynamic examples generator so you can generate accurate data #706
Provide open api schema to dynamic examples generator so you can generate accurate data #706
Conversation
…rate accurate data using settings like max-length in case of a string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my comments.
And I wonder how to can be used, can you add an example (maybe in the https://github.com/WireMock-Net/WireMock.Net/tree/master/examples/WireMock.Net.OpenApiParser.ConsoleApp ?)
public string String { get { return RandomizerFactory.GetRandomizer(new FieldOptionsTextRegex { Pattern = @"^[0-9]{2}[A-Z]{5}[0-9]{2}" }).Generate() ?? "example-string"; } set { } } | ||
public string String { get { return RandomizerFactory.GetRandomizer(new FieldOptionsTextRegex { Pattern = @"^[0-9]{2}[A-Z]{5}[0-9]{2}" }).Generate() ?? "example-string"; } set { } } | ||
/// <inheritdoc /> | ||
public OpenApiSchema SchemaExample { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe just call this Schema
?
@@ -25,5 +26,7 @@ public class WireMockOpenApiParserExampleValues : IWireMockOpenApiParserExampleV | |||
public object Object { get; set; } = "example-object"; | |||
/// <inheritdoc /> | |||
public string String { get; set; } = "example-string"; | |||
/// <inheritdoc /> | |||
public OpenApiSchema SchemaExample { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's probably not logical to define a default value for this like the Object and String?
…erties from settings like max-length
@StefH I've made the changes you suggested. Also I added some code on the ConsoleApp to show you how this can be useful. In you swagger file you can specify some attributes (maxLength on string types) So, if you are working with your own example values generator, you can use this settings as a result you can check on mapping those examples string with their own length In our case this is really useful Let me know if you need more information. Thanks in advance. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
Can you do these 2 changes:
Add virtual
to all public methods in:
WireMockOpenApiParserExampleValues.cs
WireMockOpenApiParserDynamicExampleValues.cs
With that change, you can just easily extend from the existing class and override the existing methods. (Can be useful for your new file "DynamicDataGeneration.cs").
…s and ireMockOpenApiParserDynamicExampleValues to extend and overrides examples values
@StefH I've made virtual changes and I extend my DynamicDataGeneration. |
Hi @StefH, good morning! do you know when this features will be release? |
New NuGet packages will be released in a few minutes... |
That sound great!!!!!!! Thanks!! |
@StefH Having ope api Schema we can use settings like max-length in case of a string to generate more accurate mock data when you implement your dynamic examples