openapi: 3.1.0
info:
  title: ExploreMyProfile API
  version: v1
  description: Tenant-scoped API contract for published profile content and grounded chat.
servers:
  - url: /profiles/{slug}/api/v1
    variables:
      slug:
        default: bravo-studio
        description: Published profile slug
security:
  - ApiKeyAuth: []
paths:
  /content/profile:
    get:
      summary: Fetch published profile content
      operationId: getProfileContent
      responses:
        "200":
          description: Profile response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ProfileResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /content/case_studies:
    get:
      summary: Fetch published case studies
      operationId: getProfileCaseStudies
      responses:
        "200":
          description: Case studies response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CaseStudiesResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /content/posts:
    get:
      summary: Fetch published writing posts
      operationId: getProfilePosts
      responses:
        "200":
          description: Posts response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PostsResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /content/experiences:
    get:
      summary: Fetch published experience entries
      operationId: getProfileExperiences
      responses:
        "200":
          description: Experiences response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ExperiencesResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /chat/messages:
    post:
      summary: Ask grounded questions about a published profile
      operationId: createProfileChatMessage
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ChatMessageRequest"
      responses:
        "200":
          description: Chat response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ChatMessageResponse"
        "400":
          description: Invalid request payload
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: Required when API_V1_KEY is configured on the server.
  schemas:
    ErrorObject:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: string
        message:
          type: string
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          $ref: "#/components/schemas/ErrorObject"
    ProfileData:
      type: object
      required:
        - name
        - tagline
        - bio
        - location
      properties:
        name:
          type: string
        tagline:
          type: string
        bio:
          type: string
        location:
          type: string
    ProfileResponse:
      type: object
      required:
        - data
      properties:
        data:
          $ref: "#/components/schemas/ProfileData"
    CaseStudy:
      type: object
      required:
        - title
        - summary
        - outcome
        - slug
      properties:
        title:
          type: string
        summary:
          type: string
        outcome:
          type: string
        slug:
          type: string
    CaseStudiesResponse:
      type: object
      required:
        - data
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/CaseStudy"
    Post:
      type: object
      required:
        - title
        - summary
        - date
        - slug
      properties:
        title:
          type: string
        summary:
          type: string
        date:
          type: string
        slug:
          type: string
    PostsResponse:
      type: object
      required:
        - data
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/Post"
    Experience:
      type: object
      required:
        - company
        - role
        - location
        - start_date
        - end_date
        - current
        - summary
      properties:
        company:
          type: string
        role:
          type: string
        location:
          type: string
        start_date:
          type: string
        end_date:
          type: string
        current:
          type: boolean
        summary:
          type: string
    ExperiencesResponse:
      type: object
      required:
        - data
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/Experience"
    ChatMessageRequest:
      type: object
      required:
        - message
      properties:
        message:
          type: object
          required:
            - question
          properties:
            question:
              type: string
    ChatSource:
      type: object
      required:
        - label
        - path
        - href
      properties:
        label:
          type: string
        path:
          type: string
        href:
          type: string
    ChatMessageData:
      type: object
      required:
        - question
        - answer
        - sources
      properties:
        question:
          type: string
        answer:
          type: string
        error_code:
          type:
            - string
            - "null"
        sources:
          type: array
          items:
            $ref: "#/components/schemas/ChatSource"
    ChatMessageResponse:
      type: object
      required:
        - data
      properties:
        data:
          $ref: "#/components/schemas/ChatMessageData"
