Class OpenApiSampleGenerator

Namespace
Kuestenlogik.Bowire.Protocol.Rest.OpenApi2
Assembly
Kuestenlogik.Bowire.Protocol.Rest.OpenApi2.dll

Phase 3d: generates a plausible JSON sample from an OpenAPI response schema so the mock can replay operations that were never recorded — the mock becomes a schema-first stub server without any hand-written responses.

public static class OpenApiSampleGenerator
Inheritance
OpenApiSampleGenerator
Inherited Members

Remarks

Generation is type-aware:

  • integer1 (or minimum/example/default when set)
  • number1.5
  • string"sample", or a format-aware placeholder (date-time, uuid, email, uri, byte)
  • booleantrue
  • array → 3 items of the inner schema
  • object → walks properties recursively, emitting the required set plus every defined property
  • enums → the first enum value

Any example or default baked into the schema wins over the generator's guess. Recursion depth is capped (cyclic $ref trees hit the cap and get a stub object).

Methods

Generate(IOpenApiSchema?)

Generate a compact JSON string representing a plausible instance of schema. Returns "null" when the schema is missing.

public static string Generate(IOpenApiSchema? schema)

Parameters

schema IOpenApiSchema

Returns

string