# JSON Schema for API Responses

**Use case:** 

Generate a YAML JSON Schema from multiple API response examples and infer required fields across all samples.

## Input

```json
{
  "samples": [
    {
      "status": "ok",
      "data": {
        "productId": "sku-123",
        "price": 49.99,
        "tags": [
          "sale",
          "watch"
        ]
      }
    },
    {
      "status": "ok",
      "data": {
        "productId": "sku-456",
        "price": 89.5,
        "inventory": 12,
        "tags": []
      }
    }
  ],
  "schemaTitle": "ProductApiResponse",
  "schemaDescription": "Schema inferred from product API responses.",
  "outputFormat": "yaml",
  "inferRequired": true,
  "allowAdditionalProperties": false,
  "mergeAllSamples": true
}
```

## Output

```json
{
  "sampleIndex": {
    "label": "Sample #",
    "format": "number"
  },
  "schemaTitle": {
    "label": "Title",
    "format": "text"
  },
  "fieldCount": {
    "label": "Fields",
    "format": "number"
  },
  "requiredCount": {
    "label": "Required",
    "format": "number"
  },
  "outputFormat": {
    "label": "Format",
    "format": "text"
  },
  "schema": {
    "label": "Schema",
    "format": "text"
  }
}
```

## About this Actor

This example demonstrates how to use [JSON Schema Generator](https://apify.com/automation-lab/json-schema-generator) with a specific input configuration. Visit the [Actor detail page](https://apify.com/automation-lab/json-schema-generator) to learn more, explore other use cases, and run it yourself.