{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/open-government-portugal/json-schema/open-government-portugal-discussion-page-schema.json",
  "title": "DiscussionPage",
  "x-generated": "2026-11-11",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/open-government-portugal-discussions-api-openapi.yml#/components/schemas/DiscussionPage",
  "properties": {
    "data": {
      "description": "The page data",
      "items": {
        "$ref": "#/$defs/Discussion"
      },
      "type": "array"
    },
    "next_page": {
      "description": "The next page URL if exists",
      "type": "string"
    },
    "page": {
      "description": "The current page",
      "minimum": 1,
      "type": "integer"
    },
    "page_size": {
      "description": "The page size used for pagination",
      "minimum": 0,
      "type": "integer"
    },
    "previous_page": {
      "description": "The previous page URL if exists",
      "type": "string"
    },
    "total": {
      "description": "The total paginated items",
      "minimum": 0,
      "type": "integer"
    }
  },
  "required": [
    "page",
    "page_size",
    "total"
  ],
  "type": "object",
  "$defs": {
    "Badge__read": {
      "properties": {
        "kind": {
          "type": "string"
        }
      },
      "required": [
        "kind"
      ],
      "type": "object"
    },
    "BaseReference": {
      "properties": {
        "class": {
          "description": "The object class",
          "type": "string"
        },
        "id": {
          "description": "The object unique identifier",
          "type": "string"
        }
      },
      "required": [
        "class",
        "id"
      ],
      "type": "object"
    },
    "Discussion": {
      "properties": {
        "class": {
          "description": "The object class",
          "type": "string"
        },
        "closed": {
          "description": "The discussion closing date",
          "format": "date-time",
          "type": "string"
        },
        "closed_by": {
          "allOf": [
            {
              "$ref": "#/$defs/UserReference"
            }
          ],
          "description": "The user who closed the discussion"
        },
        "closed_by_organization": {
          "allOf": [
            {
              "$ref": "#/$defs/OrganizationReference"
            }
          ],
          "description": "The organization who closed the discussion"
        },
        "created": {
          "description": "The discussion creation date",
          "format": "date-time",
          "type": "string"
        },
        "discussion": {
          "$ref": "#/$defs/DiscussionMessage"
        },
        "extras": {
          "description": "Extra attributes as key-value pairs",
          "type": "object"
        },
        "id": {
          "description": "The discussion identifier",
          "type": "string"
        },
        "organization": {
          "allOf": [
            {
              "$ref": "#/$defs/OrganizationReference"
            }
          ],
          "description": "The discussion author"
        },
        "permissions": {
          "$ref": "#/$defs/DiscussionPermissions"
        },
        "self_web_url": {
          "description": "The discussion web URL",
          "type": "string"
        },
        "subject": {
          "allOf": [
            {
              "$ref": "#/$defs/ModelReference"
            }
          ],
          "description": "The discussion target object"
        },
        "title": {
          "description": "The discussion title",
          "type": "string"
        },
        "url": {
          "description": "The discussion API URI",
          "type": "string"
        },
        "user": {
          "allOf": [
            {
              "$ref": "#/$defs/UserReference"
            }
          ],
          "description": "The discussion author"
        }
      },
      "required": [
        "class"
      ],
      "type": "object"
    },
    "DiscussionMessage": {
      "properties": {
        "content": {
          "description": "The message body",
          "type": "string"
        },
        "id": {
          "description": "The message identifier",
          "type": "string"
        },
        "last_modified_at": {
          "description": "The message last edit date",
          "format": "date-time",
          "type": "string"
        },
        "permissions": {
          "$ref": "#/$defs/DiscussionMessagePermissions"
        },
        "posted_by": {
          "allOf": [
            {
              "$ref": "#/$defs/UserReference"
            }
          ],
          "description": "The message author"
        },
        "posted_by_organization": {
          "allOf": [
            {
              "$ref": "#/$defs/OrganizationReference"
            }
          ],
          "description": "The organization to show to users"
        },
        "posted_on": {
          "description": "The message posting date",
          "format": "date-time",
          "type": "string"
        }
      },
      "type": "object"
    },
    "DiscussionMessagePermissions": {
      "properties": {
        "delete": {
          "type": "boolean"
        },
        "edit": {
          "type": "boolean"
        }
      },
      "type": "object"
    },
    "DiscussionPermissions": {
      "properties": {
        "close": {
          "type": "boolean"
        },
        "delete": {
          "type": "boolean"
        },
        "edit": {
          "type": "boolean"
        }
      },
      "type": "object"
    },
    "ModelReference": {
      "properties": {
        "class": {
          "description": "The model class",
          "type": "string"
        },
        "id": {
          "description": "The object identifier",
          "type": "string"
        }
      },
      "required": [
        "class",
        "id"
      ],
      "type": "object"
    },
    "OrganizationPermissions": {
      "properties": {
        "delete": {
          "type": "boolean"
        },
        "edit": {
          "type": "boolean"
        },
        "harvest": {
          "type": "boolean"
        },
        "members": {
          "type": "boolean"
        },
        "private": {
          "type": "boolean"
        }
      },
      "type": "object"
    },
    "OrganizationReference": {
      "allOf": [
        {
          "$ref": "#/$defs/BaseReference"
        },
        {
          "properties": {
            "acronym": {
              "description": "The organization acronym",
              "type": "string"
            },
            "badges": {
              "description": "The organization badges",
              "items": {
                "$ref": "#/$defs/Badge__read"
              },
              "readOnly": true,
              "type": "array"
            },
            "logo": {
              "description": "The organization logo URL",
              "type": "string"
            },
            "logo_thumbnail": {
              "description": "The organization logo thumbnail URL. This is the square (100x100) and cropped version.",
              "type": "string"
            },
            "name": {
              "description": "The organization name",
              "readOnly": true,
              "type": "string"
            },
            "page": {
              "description": "The organization web page URL",
              "readOnly": true,
              "type": "string"
            },
            "permissions": {
              "allOf": [
                {
                  "$ref": "#/$defs/OrganizationPermissions"
                }
              ],
              "readOnly": true
            },
            "slug": {
              "description": "The organization string used as permalink",
              "readOnly": true,
              "type": "string"
            },
            "uri": {
              "description": "The API URI for this organization",
              "readOnly": true,
              "type": "string"
            }
          },
          "type": "object"
        }
      ]
    },
    "UserReference": {
      "allOf": [
        {
          "$ref": "#/$defs/BaseReference"
        },
        {
          "properties": {
            "avatar": {
              "description": "The user avatar URL",
              "type": "string"
            },
            "avatar_thumbnail": {
              "description": "The user avatar thumbnail URL. This is the square (500x500) and cropped version.",
              "type": "string"
            },
            "first_name": {
              "description": "The user first name",
              "readOnly": true,
              "type": "string"
            },
            "last_name": {
              "description": "The user larst name",
              "readOnly": true,
              "type": "string"
            },
            "page": {
              "description": "The user web page URL",
              "readOnly": true,
              "type": "string"
            },
            "slug": {
              "description": "The user permalink string",
              "readOnly": true,
              "type": "string"
            },
            "uri": {
              "description": "The API URI for this user",
              "readOnly": true,
              "type": "string"
            }
          },
          "type": "object"
        }
      ]
    }
  }
}