Turn examples into a draft-07 validation starting point and review required fields, extra properties, mixed arrays and the limits of sample-based inference.
Turn an observed response into a deliberately reviewed contract
A generated schema is a description of the examples you supplied, not evidence of every value an API can return. It can show where nested objects, arrays and different observed types occur. It cannot discover a business rule that never appeared in the data, such as a required identifier, an allowed range or a future optional field.
Use the generator to save transcription work, then review the result as a contract. Collect representative successful and edge-case examples, decide what should be allowed and test deliberately invalid documents. Keep the original sample separate from the resulting schema so an example value is not mistaken for a permanent rule.
Choose examples covering optional fields, empty arrays, nulls and alternative item shapes. Remove private records before creating a shareable test fixture.
Generate the draft-07 schema and review type choices, required properties and additional-property behavior.
Add only the constraints you actually intend to maintain. A sample quantity of three does not justify a maximum of three.
Validate both a passing example and a document that breaks one intended rule. Check the exact failing path and error before accepting the schema.
Distinguish a declared property from a required property
The first schema describes the type of id when it is present. Adding required makes an object without id invalid. Test both an empty object and an object containing a numeric id to see the difference. Whether a null id, additional properties or a fractional id should be accepted is a separate contract decision.
Check before you continue
A TypeScript declaration and a JSON Schema have different runtime roles. A generated compile-time type does not replace validation of incoming data.
Choose a schema draft deliberately. Keywords and their exact interpretation can differ between draft-07 and newer versions.
Do not infer a universal enum or numeric precision guarantee from one small sample. Keep large exact identifiers as strings when appropriate.
7 of 7 entries
Inference
Describe types, not just one value
{"active":true} → boolean property
The generator infers types from observed values. It does not turn a single example into an enum or copy private sample values into the schema. Add actual business rules separately.
Objects
Required fields are a decision
Sample: {"name":"Alex"}
Optional by default
A field present in one example is not automatically mandatory in all future data. Enable the required-fields option only when that matches the contract you intend to enforce.
Arrays
Merge object samples in an array
[{"id":1},{"id":2,"label":"API"}]
The item schema contains both observed properties. With required inference enabled, id is required and label remains optional because it does not occur in every sampled object in that group.
Arrays
Preserve mixed item types
["ready",null,42] → anyOf types
Different observed item types are represented with anyOf. Empty arrays provide no evidence about their item type, so the generated items schema remains unrestricted.
Objects
Choose an extra-property policy
additionalProperties: false
Closing objects rejects unknown properties. Leave this option disabled if data may acquire additional fields. Review the choice at every object boundary rather than assuming stricter is always better.
Numbers
Review numeric rules
type: number
No inferred minimum or maximum
Whole-number samples do not prove that decimals are invalid. The generator deliberately uses number without inferred ranges. Add integer, minimum, maximum or multipleOf only when the real contract requires those restrictions.
Review
Validate representative cases
Expected valid → passes
Expected invalid → fails
Test additional valid and invalid examples with the JSON Schema Validator. A generated schema can miss optional fields, formats and conditions that never appeared in the input.