# Review Required Fields in a Generated JSON Schema

> A schema inferred from one successful response may reject valid variants. Use the generator for observed types, then review required fields and closed-object rules against the API contract.

- Author: [Shashank Rawlani](https://shashank.rawlani.com)

- Published: 2026-10-11T05:30:00.000Z

- Updated: 2026-10-14T10:26:49.548Z

- Category: Tools & Reviews

- Canonical source: https://automationtester.in/blog/tools-reviews/review-generated-json-schema-required-fields

- Tags: json-schema, api-contracts, json, validation

Paste one representative JSON response into the [JSON to Schema Generator](https://automationtester.in/tools/json-schema) to get a Draft 2020-12 starting point. Review `required` and `additionalProperties` before using it as a contract. One example cannot tell you which fields are optional across all valid responses.

A response from a successful request contains every field. A schema inferred from that one response may reject a perfectly valid response from an older account with no profile data. The generator can identify observed types; it cannot infer the API's full rules from one instance.

## Generate from a small response

Open the tool, replace the sample with this JSON, leave “Required fields” checked, and leave “Allow additional properties” unchecked:

```
{"status":"paid","amount":499,"roles":["sdet"]}
```

[Try this in JSON to Schema Generator](https://automationtester.in/tools/json-schema#p=eyJ2IjoxLCJpbnB1dCI6IntcInN0YXR1c1wiOlwicGFpZFwiLFwiYW1vdW50XCI6NDk5LFwicm9sZXNcIjpbXCJzZGV0XCJdfSJ9)

The generated object has `status` as a string, `amount` as an integer, and `roles` as an array of strings. It lists all three keys in `required` and sets `additionalProperties` to `false`. The `$schema` value names Draft 2020-12.

Those choices are visible decisions, not facts established by the sample. If `roles` can be omitted, remove it from `required`. If the API allows new response fields, turn on “Allow additional properties” or edit that rule after copying. JSON Schema defines `required` as property presence and `additionalProperties` as a rule for names outside those declared in `properties`.

## Types are evidence; business rules need review

The observed string `"paid"` becomes `{"type":"string"}`. It does not become an enum, so the schema would also accept `"unknown"` unless you add an allowed-value rule. The number `499` becomes an integer, but the generator does not know whether negative amounts are forbidden or what unit the amount uses.

Array inference examines the elements it sees. An empty array gives the generator no item type to learn. Try a response with several valid shapes, then edit the schema against the actual API contract. [JSON Diff](https://automationtester.in/tools/json-diff) can help find fields that changed across two captured responses, but neither tool replaces contract review. If the schema is headed for an MCP tool's `outputSchema`, paste the tool definition into the [MCP Tool Schema Checker](https://automationtester.in/tools/mcp-tool-schema-checker) too; it reports `required` names that no longer match a property.

**Does the generator validate my API?** No. It produces a schema document from an example. Run that schema through a validator against separate positive and negative fixtures. When the JSON comes from a language model rather than an API, the reviewed schema can become a promptfoo `is-json` assertion; the [LLM Eval Test-Case Builder](https://automationtester.in/tools/llm-eval-case-builder) writes it into the config as a mapping.

**Should every observed field be required?** Only if the contract says it must always appear. The checkbox expresses a starting assumption, not a discovery.

## Review the contract before CI

Generate a schema from one real response. Mark every required field and closed-object rule that came from the sample alone. Check those decisions against the API specification or at least two contrasting fixtures before adding the schema to CI.

## Schema specification and tool reference

- [JSON Schema Draft 2020-12 Validation](https://json-schema.org/draft/2020-12/json-schema-validation): meanings of `type`, `required`, and `additionalProperties`.

- [AutomationTester.in JSON to Schema Generator](https://automationtester.in/tools/json-schema): input, options, and generated output.

## Continue reading on AutomationTester.in

- [Build a k6 Load Model from Real Traffic, Not a VU Count](https://automationtester.in/blog/tools-reviews/generate-k6-load-model-traffic-assumptions)
- [Test Cron Schedules by Their Fire Times, Not Their Strings](https://automationtester.in/blog/tools-reviews/verify-cron-schedules-time-zones-boundaries)
- [Create a Failure Triage Toolkit Before the Next Flake](https://automationtester.in/blog/tools-reviews/failure-triage-toolkit-before-flake)
- [Freeze Generated Test Data Before CI Needs It](https://automationtester.in/blog/tools-reviews/freeze-generated-test-data-fixtures)
- [Check JSONPath Matches Before Writing the Assertion](https://automationtester.in/blog/tools-reviews/find-jsonpath-matches-before-asserting)

Source: [Review Required Fields in a Generated JSON Schema](https://automationtester.in/blog/tools-reviews/review-generated-json-schema-required-fields) by Shashank Rawlani.
