Class ExampleBuilder

java.lang.Object
org.mockserver.openapi.examples.ExampleBuilder

public class ExampleBuilder extends Object
See: https://github.com/swagger-api/swagger-inflector
  • Field Details

  • Constructor Details

    • ExampleBuilder

      public ExampleBuilder()
  • Method Details

    • fromSchema

      public static Example fromSchema(io.swagger.v3.oas.models.media.Schema<?> property, Map<String,io.swagger.v3.oas.models.media.Schema> definitions)
    • 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-run GenerationOptions (a caller-chosen seed for reproducible realistic values and per-field value overrides). When generationOptions is null behaviour is identical to the historic two-arg overload (fixed seed 42, no overrides).
    • fromProperty

      public static Example fromProperty(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)
    • alreadyProcessedRefExample

      public static Example alreadyProcessedRefExample(String name, Map<String,io.swagger.v3.oas.models.media.Schema> definitions, Map<String,Example> processedModels)
    • mergeTo

      public static void mergeTo(ObjectExample output, List<Example> examples)
    • normalizeFlattenedExample

      public static Object normalizeFlattenedExample(Object example, io.swagger.v3.oas.models.media.Schema<?> schema)
      Undoes the swagger-parser resolveFully/resolveCombinators artefact whereby a scalar schema flattened from allOf: [ $ref to a scalar ] ends up with its example wrapped in a single-element Collection (a Set or List). 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.