openapi: 3.1.0
info:
  title: Lose It! Food Logger
  description: Log food entries to your Lose It! diary via ChatGPT.
  version: 1.0.0

servers:
  - url: https://loseitmcp.mywire.org
    description: Replace with your deployed server URL.

paths:
  /v1/log_food:
    post:
      operationId: logFood
      summary: Log a food entry
      description: >
        Logs a food item to the authenticated user's Lose It! food diary.
        Calories are computed automatically from macros: fat*9 + carbs*4 + protein*4.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [name, fat_g, carbs_g, protein_g]
              properties:
                name:
                  type: string
                  description: Display name shown in the diary (e.g. "Chicken breast 200g").
                fat_g:
                  type: number
                  description: Fat in grams (>= 0).
                carbs_g:
                  type: number
                  description: Carbohydrates in grams (>= 0).
                protein_g:
                  type: number
                  description: Protein in grams (>= 0).
                meal:
                  type: string
                  enum: [breakfast, lunch, dinner, evening_snack]
                  default: lunch
                  description: Meal slot.
                date_str:
                  type: string
                  default: today
                  description: '"today", "yesterday", or ISO date (YYYY-MM-DD).'
                weight_grams:
                  type: number
                  description: Portion weight in grams. If omitted, logged as 1 serving.
      responses:
        "200":
          description: Food entry logged successfully.
          content:
            application/json:
              schema:
                type: object
                properties:
                  result:
                    type: string
        "400":
          description: Validation error.
          content:
            application/json:
              schema:
                type: object
                properties:
                  result:
                    type: string
        "401":
          description: Unauthorized — missing or invalid Bearer token.

components:
  schemas: {}
  securitySchemes:
    oauth:
      type: oauth2
      flows:
        authorizationCode:
          authorizationUrl: /chatgpt/authorize
          tokenUrl: /chatgpt/token
          scopes: {}

security:
  - oauth: []
