{
  "openapi": "3.1.0",
  "info": {
    "title": "Fun Data Bridge API",
    "version": "1.0",
    "description": "Generate small deterministic JSON fixtures using fundata-style schemas, then reuse them in API tests."
  },
  "servers": [
    {
      "url": "https://funapi.dev/api/data/v1"
    }
  ],
  "tags": [
    {
      "name": "generate",
      "description": "schemas and fixtures"
    }
  ],
  "paths": {
    "/types": {
      "get": {
        "tags": [
          "generate"
        ],
        "summary": "List supported field types",
        "operationId": "dg-types",
        "responses": {
          "200": {
            "description": "Types",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          }
        }
      }
    },
    "/generate": {
      "post": {
        "tags": [
          "generate"
        ],
        "summary": "Generate deterministic JSON rows",
        "operationId": "dg-generate",
        "responses": {
          "200": {
            "description": "Generated rows",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "422": {
            "description": "Invalid schema",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "seed": {
                    "type": "integer"
                  },
                  "rows": {
                    "type": "integer"
                  },
                  "fields": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "name": {
                          "type": "string"
                        },
                        "type": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "name",
                        "type"
                      ],
                      "additionalProperties": false
                    }
                  }
                },
                "required": [
                  "seed",
                  "rows",
                  "fields"
                ],
                "additionalProperties": false
              },
              "example": {
                "seed": 42,
                "rows": 5,
                "fields": [
                  {
                    "name": "id",
                    "type": "row"
                  },
                  {
                    "name": "email",
                    "type": "email"
                  }
                ]
              }
            }
          }
        }
      }
    },
    "/jobs": {
      "post": {
        "tags": [
          "generate"
        ],
        "summary": "Queue a large fixture job",
        "operationId": "dg-job",
        "responses": {
          "202": {
            "description": "Job accepted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "422": {
            "description": "Invalid job",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "rows": {
                    "type": "integer"
                  },
                  "format": {
                    "type": "string"
                  }
                },
                "required": [
                  "rows",
                  "format"
                ],
                "additionalProperties": false
              },
              "example": {
                "rows": 100000,
                "format": "csv"
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    },
    "/jobs/{id}": {
      "get": {
        "tags": [
          "generate"
        ],
        "summary": "Poll fixture job",
        "operationId": "dg-job-get",
        "responses": {
          "200": {
            "description": "Job state",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "404": {
            "description": "Missing job",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "example": 1
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "description": "Use qa-admin-token / qa-viewer-token, or a JWT from POST /auth/v1/login."
      },
      "apiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key",
        "description": "Cargo demo key: cargo-key-123."
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error",
          "message"
        ],
        "properties": {
          "error": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "requestId": {
            "type": "string"
          }
        },
        "additionalProperties": true
      }
    }
  }
}
