181 lines
5.1 KiB
JSON
181 lines
5.1 KiB
JSON
{
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"$id": "sykkelaksjon-api",
|
|
"title": "Sykkelaksjon",
|
|
"description": "Server message for users of the Sykkelaksjon web site",
|
|
"type": "object",
|
|
"properties": {
|
|
"name": {
|
|
"type": "string",
|
|
"description": "The full name of the connected user"
|
|
},
|
|
"isAdmin": {
|
|
"type": "boolean",
|
|
"description": "Whether the connected user is an administrator"
|
|
},
|
|
"activityTypes": {
|
|
"type": "array",
|
|
"description": "Available types of activities",
|
|
"items": {
|
|
"$ref": "#/$defs/activityType"
|
|
}
|
|
},
|
|
"unitConversionNecessary" : {
|
|
"type": "boolean",
|
|
"description": "Whether there exists activity types that don't have a conversion factor of 1"
|
|
},
|
|
"activityTemplates": {
|
|
"type": "array",
|
|
"description": "Templates that the user might apply to quickly add a new activity",
|
|
"items": {
|
|
"$ref": "#/$defs/activityTemplate"
|
|
}
|
|
},
|
|
"activities": {
|
|
"type": "array",
|
|
"description": "The activities the user has performed",
|
|
"items": {
|
|
"$ref": "#/$defs/activity"
|
|
}
|
|
},
|
|
"otherUsers": {
|
|
"type": "array",
|
|
"description": "Other users of the web site to create a leaderboard, and more detailed information for administrators",
|
|
"items": {
|
|
"type": "object",
|
|
"description": "Information about other users in the system",
|
|
"properties": {
|
|
"name": {
|
|
"type": "string",
|
|
"description": "The display name of the user"
|
|
},
|
|
"earliestActivity": {
|
|
"$ref": "#/$defs/date",
|
|
"description": "The earliest date the user has performed an activity on"
|
|
},
|
|
"latestActivity": {
|
|
"$ref": "#/$defs/date",
|
|
"description": "The latest date the user has performed an activity on"
|
|
},
|
|
"totalKilometers": {
|
|
"type": "number",
|
|
"description": "The total amount of kilometers (including converted activities) the user has covered"
|
|
},
|
|
"userId": {
|
|
"type": "integer",
|
|
"description": "Administrator info: ther user id of the user"
|
|
},
|
|
"userName": {
|
|
"type": "string",
|
|
"description": "Administrator info: the username of the user"
|
|
},
|
|
"isActive": {
|
|
"type": "boolean",
|
|
"description": "Administrator info: whether the user listed is still active"
|
|
},
|
|
"isAdmin": {
|
|
"type": "boolean",
|
|
"description": "Administrator info: whether the user listed is an administrator"
|
|
},
|
|
"activityTemplates": {
|
|
"type": "array",
|
|
"description": "Administrator info: the activity templates this user has defined",
|
|
"items": {
|
|
"$ref": "#/$defs/activityTemplate"
|
|
}
|
|
},
|
|
"activities": {
|
|
"type": "array",
|
|
"description": "Administrator info: a detailed list of activities the user has performed",
|
|
"items": {
|
|
"$ref": "#/$defs/activity"
|
|
}
|
|
}
|
|
|
|
},
|
|
"required": ["name"]
|
|
}
|
|
}
|
|
},
|
|
"required": ["name", "isAdmin", "activityTypes", "unitConversionNecessary", "activityTemplates", "activities", "otherUsers"],
|
|
|
|
"$defs": {
|
|
"date": {
|
|
"type": "string",
|
|
"description": "A date in local time",
|
|
"pattern": "[0-9]{4}-[0-9]{2}-[0-9]{4}"
|
|
},
|
|
"activityType": {
|
|
"type": "object",
|
|
"description": "An available activity the user may log",
|
|
"properties": {
|
|
"id": {
|
|
"type": "integer",
|
|
"description": "The database ID of the activity type"
|
|
},
|
|
"name": {
|
|
"type": "string",
|
|
"description": "The name of the activity type"
|
|
},
|
|
"unit": {
|
|
"type": "string",
|
|
"description": "The unit this activity type is measured in"
|
|
},
|
|
"conversionFactor": {
|
|
"type": "number",
|
|
"description": "The conversion factor from the unit the activity is measured in into kilometers"
|
|
}
|
|
},
|
|
"required": ["name", "unit", "conversionFactor"]
|
|
},
|
|
"activityTemplate": {
|
|
"type": "object",
|
|
"description": "Templates that the user has stored in order to quickly add common activities",
|
|
"properties": {
|
|
"id": {
|
|
"type": "integer",
|
|
"description": "The database ID of the activity template"
|
|
},
|
|
"activityType": {
|
|
"$ref": "#/$defs/activityType"
|
|
},
|
|
"name": {
|
|
"type": "string",
|
|
"description": "The name the user has given to this activity"
|
|
},
|
|
"numberOfUnits": {
|
|
"type": "number",
|
|
"description": "The length of the activity (in units defined in the activity type)"
|
|
}
|
|
},
|
|
"required": ["activityType", "name", "numberOfUnits"]
|
|
},
|
|
"activity": {
|
|
"type": "object",
|
|
"description": "An activity a user has performed at some date",
|
|
"properties": {
|
|
"id": {
|
|
"type": "integer",
|
|
"description": "The database ID of the activity"
|
|
},
|
|
"activityType": {
|
|
"$ref": "#/$defs/activityType"
|
|
},
|
|
"numberOfUnits": {
|
|
"type": "number",
|
|
"description": "The length of the activity (in units defined in the activity type)"
|
|
},
|
|
"description": {
|
|
"type": "string",
|
|
"description": "The user's description of the activity"
|
|
},
|
|
"date": {
|
|
"$ref": "#/$defs/date",
|
|
"description": "The date the user performed the activity"
|
|
}
|
|
},
|
|
"required": ["activityType", "numberOfUnits", "description", "date"]
|
|
}
|
|
}
|
|
}
|