{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/sociallisteningapi/main/json-schema/sociallisteningapi-comment-search-response-schema.json",
  "title": "CommentSearchResponse",
  "x-generated": "2026-09-23",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/sociallisteningapi-openapi.yml#/components/schemas/CommentSearchResponse",
  "type": "object",
  "required": [
    "success",
    "platform",
    "endpoint",
    "data",
    "pagination",
    "request_id",
    "credits_used",
    "credits_remaining"
  ],
  "properties": {
    "success": {
      "type": "boolean",
      "const": true
    },
    "platform": {
      "type": "string",
      "const": "reddit"
    },
    "endpoint": {
      "type": "string"
    },
    "data": {
      "$ref": "#/$defs/CommentSearchData"
    },
    "pagination": {
      "$ref": "#/$defs/Pagination"
    },
    "raw": {
      "$ref": "#/$defs/RawResponse"
    },
    "request_id": {
      "type": "string"
    },
    "credits_used": {
      "type": "integer",
      "minimum": 0
    },
    "credits_remaining": {
      "type": [
        "integer",
        "null"
      ],
      "minimum": 0
    }
  },
  "additionalProperties": false,
  "$defs": {
    "Author": {
      "type": "object",
      "required": [
        "id",
        "username",
        "display_name",
        "avatar_url",
        "verified"
      ],
      "properties": {
        "id": {
          "type": [
            "string",
            "null"
          ]
        },
        "username": {
          "type": [
            "string",
            "null"
          ]
        },
        "display_name": {
          "type": [
            "string",
            "null"
          ]
        },
        "avatar_url": {
          "type": [
            "string",
            "null"
          ],
          "format": "uri"
        },
        "verified": {
          "type": [
            "boolean",
            "null"
          ]
        }
      },
      "additionalProperties": false
    },
    "Comment": {
      "type": "object",
      "required": [
        "id",
        "platform",
        "url",
        "parent_id",
        "post_id",
        "text",
        "author",
        "engagement",
        "flags",
        "published_at",
        "ext",
        "replies"
      ],
      "properties": {
        "id": {
          "type": "string"
        },
        "platform": {
          "type": "string",
          "const": "reddit"
        },
        "url": {
          "type": [
            "string",
            "null"
          ],
          "format": "uri"
        },
        "parent_id": {
          "type": [
            "string",
            "null"
          ]
        },
        "post_id": {
          "type": [
            "string",
            "null"
          ]
        },
        "text": {
          "type": [
            "string",
            "null"
          ]
        },
        "author": {
          "$ref": "#/$defs/Author"
        },
        "engagement": {
          "$ref": "#/$defs/CommentEngagement"
        },
        "flags": {
          "$ref": "#/$defs/CommentFlags"
        },
        "published_at": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "ext": {
          "type": "object",
          "description": "Platform-specific normalized comment fields.",
          "additionalProperties": true
        },
        "replies": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Comment"
          }
        }
      },
      "additionalProperties": false
    },
    "CommentEngagement": {
      "type": "object",
      "required": [
        "likes",
        "replies"
      ],
      "properties": {
        "likes": {
          "type": [
            "integer",
            "null"
          ]
        },
        "replies": {
          "type": [
            "integer",
            "null"
          ]
        }
      },
      "additionalProperties": false
    },
    "CommentFlags": {
      "type": "object",
      "required": [
        "pinned",
        "deleted"
      ],
      "properties": {
        "pinned": {
          "type": [
            "boolean",
            "null"
          ]
        },
        "deleted": {
          "type": "boolean"
        }
      },
      "additionalProperties": false
    },
    "CommentSearchData": {
      "type": "object",
      "required": [
        "items"
      ],
      "properties": {
        "items": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Comment"
          }
        }
      },
      "additionalProperties": false
    },
    "Pagination": {
      "type": "object",
      "required": [
        "next_cursor",
        "has_more",
        "page_size"
      ],
      "properties": {
        "next_cursor": {
          "type": [
            "string",
            "null"
          ],
          "description": "A provider cursor for a future paginated request, when available."
        },
        "has_more": {
          "type": "boolean"
        },
        "page_size": {
          "type": "integer",
          "minimum": 0
        }
      },
      "additionalProperties": false
    },
    "RawResponse": {
      "description": "The unchanged upstream provider response. Returned only when the request sets raw to true."
    }
  }
}