Package org.mockserver.openapi.examples
Class ExampleBuilder
java.lang.Object
org.mockserver.openapi.examples.ExampleBuilder
See: https://github.com/swagger-api/swagger-inflector
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final booleanstatic final Stringstatic final Stringstatic final Stringstatic final doublestatic final doublestatic final Stringstatic final floatstatic final intstatic final intstatic final Stringstatic final Stringstatic final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ExamplealreadyProcessedRefExample(String name, Map<String, io.swagger.v3.oas.models.media.Schema> definitions, Map<String, Example> processedModels) static ExamplefromProperty(String name, io.swagger.v3.oas.models.media.Schema<?> property, Map<String, io.swagger.v3.oas.models.media.Schema> definitions, Map<String, Example> processedModels, Set<String> modelsStartedProcessing, StringBuilder location) static ExamplefromSchema(io.swagger.v3.oas.models.media.Schema<?> property, Map<String, io.swagger.v3.oas.models.media.Schema> definitions) static ExamplefromSchema(io.swagger.v3.oas.models.media.Schema<?> property, Map<String, io.swagger.v3.oas.models.media.Schema> definitions, GenerationOptions generationOptions) Builds an example from a schema, optionally honouring per-runGenerationOptions(a caller-chosen seed for reproducible realistic values and per-field value overrides).static voidmergeTo(ObjectExample output, List<Example> examples) static ObjectnormalizeFlattenedExample(Object example, io.swagger.v3.oas.models.media.Schema<?> schema) Undoes the swagger-parserresolveFully/resolveCombinatorsartefact whereby a scalar schema flattened fromallOf: [ $ref to a scalar ]ends up with itsexamplewrapped in a single-elementCollection(aSetorList).
-
Field Details
-
SAMPLE_EMAIL_PROPERTY_VALUE
- See Also:
-
SAMPLE_UUID_PROPERTY_VALUE
- See Also:
-
SAMPLE_STRING_PROPERTY_VALUE
- See Also:
-
SAMPLE_INT_PROPERTY_VALUE
public static final int SAMPLE_INT_PROPERTY_VALUE- See Also:
-
SAMPLE_LONG_PROPERTY_VALUE
public static final int SAMPLE_LONG_PROPERTY_VALUE- See Also:
-
SAMPLE_BASE_INTEGER_PROPERTY_VALUE
public static final int SAMPLE_BASE_INTEGER_PROPERTY_VALUE- See Also:
-
SAMPLE_FLOAT_PROPERTY_VALUE
public static final float SAMPLE_FLOAT_PROPERTY_VALUE- See Also:
-
SAMPLE_DOUBLE_PROPERTY_VALUE
public static final double SAMPLE_DOUBLE_PROPERTY_VALUE- See Also:
-
SAMPLE_BOOLEAN_PROPERTY_VALUE
public static final boolean SAMPLE_BOOLEAN_PROPERTY_VALUE- See Also:
-
SAMPLE_BYTE_PROPERTY_VALUE
- See Also:
-
SAMPLE_DATE_PROPERTY_VALUE
- See Also:
-
SAMPLE_TIME_PROPERTY_VALUE
- See Also:
-
SAMPLE_DATETIME_PROPERTY_VALUE
- See Also:
-
SAMPLE_DECIMAL_PROPERTY_VALUE
public static final double SAMPLE_DECIMAL_PROPERTY_VALUE- See Also:
-
-
Constructor Details
-
ExampleBuilder
public ExampleBuilder()
-
-
Method Details
-
fromSchema
-
fromSchema
public static Example fromSchema(io.swagger.v3.oas.models.media.Schema<?> property, Map<String, io.swagger.v3.oas.models.media.Schema> definitions, GenerationOptions generationOptions) Builds an example from a schema, optionally honouring per-runGenerationOptions(a caller-chosen seed for reproducible realistic values and per-field value overrides). WhengenerationOptionsisnullbehaviour is identical to the historic two-arg overload (fixed seed 42, no overrides). -
fromProperty
-
alreadyProcessedRefExample
-
mergeTo
-
normalizeFlattenedExample
public static Object normalizeFlattenedExample(Object example, io.swagger.v3.oas.models.media.Schema<?> schema) Undoes the swagger-parserresolveFully/resolveCombinatorsartefact whereby a scalar schema flattened fromallOf: [ $ref to a scalar ]ends up with itsexamplewrapped in a single-elementCollection(aSetorList). For a scalar-typed schema such a collection is never a valid example, so it is unwrapped to the contained value. Non-scalar schemas (objects, arrays) and multi-element collections are returned unchanged. See #2357.
-