Class OpenApiSampleGenerator
- Namespace
- Kuestenlogik.Bowire.Protocol.Rest.OpenApi3
- Assembly
- Kuestenlogik.Bowire.Protocol.Rest.OpenApi3.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:
integer→1(orminimum/example/defaultwhen set)number→1.5string→"sample", or a format-aware placeholder (date-time,uuid,email,uri,byte)boolean→truearray→ 3 items of the inner schemaobject→ 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
schemaIOpenApiSchema