openapi: "3.0.3"
info:
  title: "Form submission API"
  version: "1.0.0"
  description: "The payload column is json, so a submission missing a required field is a schema-level invalid instance rather than a SQL error. The fields count is strictly positive, which catches a form defined with no inputs. The form key is unique and is what the public URL resolves against. The foreign key means every submission needs a form row."
paths: {}
x-domain-id: "prob_forms"
x-dialect: "postgres"
components:
  schemas:
    forms:
      type: "object"
      x-primary-key: "id"
      required: ["id", "key", "fields"]
      properties:
        id:
          type: "string"
          format: "uuid"
        key:
          type: "string"
          x-unique: true
        fields:
          type: "integer"
          minimum: 1
    submissions:
      type: "object"
      x-primary-key: "id"
      required: ["id", "form_id", "payload", "submitted_at"]
      properties:
        id:
          type: "string"
          format: "uuid"
        form_id:
          $ref: "#/components/schemas/forms"
        payload:
          type: "object"
        submitted_at:
          type: "string"
          format: "date-time"
