openapi: 3.1.0
info:
  title: CenturyRides.org API
  description: Public API for querying and submitting 100-mile century cycling events across the United States.
  version: 1.0.0
servers:
  - url: https://centuryrides.org/api
paths:
  /rides:
    get:
      summary: Retrieve all published century rides grouped by state
      operationId: getPublishedRides
      responses:
        '200':
          description: A list of states containing their respective century rides.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/StateGroup'
  /admin/rides:
    post:
      summary: Submit a new century ride for moderation/publishing
      operationId: submitRide
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RideInput'
      responses:
        '200':
          description: Submission received and queued.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  id:
                    type: integer

components:
  schemas:
    Ride:
      type: object
      properties:
        name:
          type: string
          example: "Six Gap Century"
        location:
          type: string
          example: "Dahlonega"
        region:
          type: string
          example: "North Georgia Mountains"
        month:
          type: string
          example: "September"
        url:
          type: string
          example: "https://www.6gap.com"
        tags:
          type: array
          items:
            type: string
          example: ["Road", "Alpine", "11,200' Gain"]
        desc:
          type: string
          example: "104 grueling miles tackling 6 mountain passes."
    StateGroup:
      type: object
      properties:
        state:
          type: string
          example: "Georgia"
        code:
          type: string
          example: "GA"
        rides:
          type: array
          items:
            $ref: '#/components/schemas/Ride'
    RideInput:
      type: object
      required:
        - name
        - state
        - code
        - location
        - region
        - month
        - url
        - desc
      properties:
        name:
          type: string
        state:
          type: string
        code:
          type: string
        location:
          type: string
        region:
          type: string
        month:
          type: string
        url:
          type: string
        tags:
          type: string
          description: Comma-separated list of tags
        desc:
          type: string
        status:
          type: string
          default: pending