{
  "openapi": "3.0.4",
  "info": {
    "title": "Comments API",
    "description": "API for managing comments",
    "version": "v1"
  },
  "paths": {
    "/v1/comments": {
      "get": {
        "tags": [
          "Comments"
        ],
        "summary": "Get all comments with pagination. Filter by resourceUrn for resource-specific comments.",
        "parameters": [
          {
            "name": "pageNumber",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 1
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 25
            }
          },
          {
            "name": "resourceUrn",
            "in": "query",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          },
          {
            "name": "authorId",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "hasAnchor",
            "in": "query",
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/CommentVMPagedResponseVM"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CommentVMPagedResponseVM"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/CommentVMPagedResponseVM"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Forbidden"
          }
        }
      },
      "post": {
        "tags": [
          "Comments"
        ],
        "summary": "Create a new comment",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateCommentVM"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateCommentVM"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/CreateCommentVM"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "application/json": {
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "text/json": {
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          }
        }
      }
    },
    "/v1/comments/resource-urn-prefixes": {
      "get": {
        "tags": [
          "Comments"
        ],
        "summary": "Get configured resource URN entries for the current environment.",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/AllowedResourceUrnVM"
                  }
                }
              },
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/AllowedResourceUrnVM"
                  }
                }
              },
              "text/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/AllowedResourceUrnVM"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Forbidden"
          }
        }
      }
    },
    "/v1/comments/mentionable-users": {
      "get": {
        "tags": [
          "Comments"
        ],
        "parameters": [
          {
            "name": "filter",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/MentionableUserVM"
                  }
                }
              },
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/MentionableUserVM"
                  }
                }
              },
              "text/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/MentionableUserVM"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Forbidden"
          }
        }
      }
    },
    "/v1/comments/{id}": {
      "get": {
        "tags": [
          "Comments"
        ],
        "summary": "Get a comment by ID",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/CommentVM"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CommentVM"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/CommentVM"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Forbidden"
          }
        }
      },
      "put": {
        "tags": [
          "Comments"
        ],
        "summary": "Update an existing comment",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateCommentVM"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateCommentVM"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateCommentVM"
              }
            }
          }
        },
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          }
        }
      },
      "delete": {
        "tags": [
          "Comments"
        ],
        "summary": "Delete a comment (soft delete)\nDeleted comments are excluded from all queries",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          }
        }
      }
    },
    "/v1/comments/{id}/replies": {
      "get": {
        "tags": [
          "Comments"
        ],
        "summary": "Get replies for a comment",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/CommentVM"
                  }
                }
              },
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/CommentVM"
                  }
                }
              },
              "text/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/CommentVM"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Forbidden"
          }
        }
      }
    },
    "/public/comments": {
      "post": {
        "tags": [
          "PublicComments"
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PublicCreateCommentVM"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/PublicCreateCommentVM"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/PublicCreateCommentVM"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/PublicCommentVM"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicCommentVM"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicCommentVM"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          }
        }
      }
    },
    "/public/comments/{id}": {
      "get": {
        "tags": [
          "PublicComments"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/PublicCommentVM"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicCommentVM"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicCommentVM"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Forbidden"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "AllowedResourceUrnVM": {
        "required": [
          "resourceType",
          "uriTemplate",
          "urnPrefix",
          "urnTemplate"
        ],
        "type": "object",
        "properties": {
          "urnTemplate": {
            "type": "string",
            "nullable": true
          },
          "urnPrefix": {
            "type": "string",
            "nullable": true
          },
          "uriTemplate": {
            "type": "string",
            "nullable": true
          },
          "resourceType": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "CommentVM": {
        "required": [
          "authorId",
          "authorName",
          "content",
          "createdAt",
          "id",
          "resourceUrn"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "content": {
            "type": "string",
            "nullable": true
          },
          "authorId": {
            "type": "string",
            "format": "uuid"
          },
          "authorName": {
            "type": "string",
            "description": "Display name of the comment author.",
            "nullable": true
          },
          "resourceUrn": {
            "type": "string",
            "nullable": true
          },
          "anchorContext": {
            "type": "string",
            "nullable": true
          },
          "parentCommentId": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "replyCount": {
            "type": "integer",
            "description": "Number of replies to this comment. Only populated for root comments.",
            "format": "int32"
          },
          "isRoot": {
            "type": "boolean",
            "description": "Whether this is a root comment (thread starter).",
            "readOnly": true
          }
        },
        "additionalProperties": false
      },
      "CommentVMPagedResponseVM": {
        "required": [
          "hasNextPage",
          "hasPreviousPage",
          "items",
          "pageNumber",
          "pageSize",
          "totalCount",
          "totalPages"
        ],
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CommentVM"
            },
            "nullable": true
          },
          "pageNumber": {
            "type": "integer",
            "format": "int32"
          },
          "pageSize": {
            "type": "integer",
            "format": "int32"
          },
          "totalCount": {
            "type": "integer",
            "format": "int32"
          },
          "totalPages": {
            "type": "integer",
            "format": "int32"
          },
          "hasPreviousPage": {
            "type": "boolean"
          },
          "hasNextPage": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "CreateCommentVM": {
        "required": [
          "content"
        ],
        "type": "object",
        "properties": {
          "content": {
            "type": "string",
            "description": "The comment content in Markdown format.",
            "nullable": true
          },
          "resourceUrn": {
            "type": "string",
            "description": "URN identifying the resource this comment belongs to.\nFormat: urn:<service>:<type>:<id>",
            "nullable": true
          },
          "anchorContext": {
            "type": "string",
            "description": "Optional JSON string describing a precise location within the resource.\nOnly valid for root comments (when ParentCommentId is null).",
            "nullable": true
          },
          "parentCommentId": {
            "type": "string",
            "description": "Reference to parent comment for replies.\nLeave null to create a root comment.",
            "format": "uuid",
            "nullable": true
          },
          "resourceName": {
            "type": "string",
            "description": "Resource name shown in notifications, for example the part name.\nMust not contain '<' or '>' characters.\nReplies reuse the parent comment's value when omitted.",
            "nullable": true,
            "example": "part-5592-r16454"
          },
          "resourceOwnerId": {
            "type": "string",
            "description": "User ID of the resource owner, who gets notified about new comments.\nReplies reuse the parent comment's value when omitted.",
            "format": "uuid",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "MentionableUserVM": {
        "required": [
          "displayName",
          "email",
          "id"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "nullable": true
          },
          "displayName": {
            "type": "string",
            "nullable": true
          },
          "email": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "ProblemDetails": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "nullable": true
          },
          "title": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "detail": {
            "type": "string",
            "nullable": true
          },
          "instance": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": { }
      },
      "PublicApiLinkVM": {
        "required": [
          "href"
        ],
        "type": "object",
        "properties": {
          "href": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "PublicCommentVM": {
        "required": [
          "author_id",
          "author_name",
          "content",
          "created_at",
          "id",
          "links",
          "resource_urn"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "content": {
            "type": "string",
            "nullable": true
          },
          "author_id": {
            "type": "string",
            "format": "uuid"
          },
          "author_name": {
            "type": "string",
            "nullable": true
          },
          "resource_urn": {
            "type": "string",
            "nullable": true
          },
          "parent_comment_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "reply_count": {
            "type": "integer",
            "format": "int32"
          },
          "is_root": {
            "type": "boolean"
          },
          "links": {
            "type": "object",
            "additionalProperties": {
              "$ref": "#/components/schemas/PublicApiLinkVM"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "PublicCreateCommentVM": {
        "required": [
          "content"
        ],
        "type": "object",
        "properties": {
          "content": {
            "type": "string",
            "nullable": true
          },
          "resource_urn": {
            "type": "string",
            "nullable": true
          },
          "parent_comment_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "resource_name": {
            "type": "string",
            "nullable": true
          },
          "resource_owner_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "UpdateCommentVM": {
        "required": [
          "content"
        ],
        "type": "object",
        "properties": {
          "content": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      }
    },
    "securitySchemes": {
      "OAuth2": {
        "type": "oauth2",
        "flows": {
          "clientCredentials": {
            "tokenUrl": "https://login.co-am.com/realms/co-am/protocol/openid-connect/token",
            "scopes": {
              "coam:comments:comments-write": "Create comments as the authenticated user or API client",
              "coam:api:on-behalf": "Act on behalf of a user on supported endpoints"
            }
          },
          "authorizationCode": {
            "authorizationUrl": "https://login.co-am.com/realms/co-am/protocol/openid-connect/auth",
            "tokenUrl": "https://login.co-am.com/realms/co-am/protocol/openid-connect/token",
            "scopes": {
              "coam:comments:comments-write": "Create comments as the authenticated user or API client",
              "coam:api:on-behalf": "Act on behalf of a user on supported endpoints"
            }
          }
        }
      }
    }
  },
  "security": [
    {
      "OAuth2": [ ]
    }
  ],
  "tags": [
    {
      "name": "Comments"
    },
    {
      "name": "PublicComments"
    }
  ]
}