{
  "openapi": "3.0.1",
  "info": {
    "title": "PetalPal API",
    "description": "A tiny OAuth-protected garden API shaped for ChatGPT through MCP Stack.",
    "version": "v1"
  },
  "paths": {
    "/api/gardens/me": {
      "get": {
        "tags": [
          "Gardens"
        ],
        "summary": "Get the signed-in user's PetalPal garden",
        "description": "Returns the OAuth user's garden and plants. MCP Stack Gateway can expose this as a read-only ChatGPT tool.",
        "operationId": "get_my_petalpal_garden",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GardenResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/gardens/plants": {
      "get": {
        "tags": [
          "Gardens"
        ],
        "summary": "List plants in the signed-in user's garden",
        "description": "Use when ChatGPT needs a compact inventory of the user's plants, moods, water counts, and notes.",
        "operationId": "list_petalpal_plants",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/PlantResponse"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Gardens"
        ],
        "summary": "Create a plant in the signed-in user's garden",
        "description": "Use after the user asks ChatGPT to add a small plant, reminder, or mood note to their PetalPal garden.",
        "operationId": "create_petalpal_plant",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreatePlantRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": { }
            }
          },
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PlantResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/gardens/plants/{plantId}/water": {
      "post": {
        "tags": [
          "Gardens"
        ],
        "summary": "Water one PetalPal plant",
        "description": "Use when ChatGPT needs to perform a tiny write action for a specific plant after user confirmation.",
        "operationId": "water_petalpal_plant",
        "parameters": [
          {
            "name": "plantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PlantResponse"
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          }
        }
      }
    },
    "/api/gardens/plants/{plantId}/fga-trace": {
      "get": {
        "tags": [
          "Gardens"
        ],
        "summary": "Trace the FGA decision for watering a plant",
        "description": "Debug helper for the blog walkthrough: shows why SqlOS FGA allowed or denied the plant write.",
        "operationId": "trace_petalpal_plant_access",
        "parameters": [
          {
            "name": "plantId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "404": {
            "description": "Not Found"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "CreatePlantRequest": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "nullable": true
          },
          "mood": {
            "type": "string",
            "nullable": true
          },
          "note": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "GardenResponse": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string",
            "nullable": true
          },
          "resourceId": {
            "type": "string",
            "nullable": true
          },
          "subjectId": {
            "type": "string",
            "nullable": true
          },
          "plants": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PlantResponse"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "PlantResponse": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string",
            "nullable": true
          },
          "mood": {
            "type": "string",
            "nullable": true
          },
          "note": {
            "type": "string",
            "nullable": true
          },
          "waterCount": {
            "type": "integer",
            "format": "int32"
          },
          "lastWateredAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "resourceId": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      }
    },
    "securitySchemes": {
      "Bearer": {
        "type": "http",
        "description": "Bearer token minted by the PetalPal SqlOS authorization server.",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      }
    }
  },
  "security": [
    {
      "Bearer": [ ]
    }
  ]
}