{
  "openapi": "3.0.1",
  "info": {
    "title": "Sverigesstarkaste API",
    "description": "Publika API:er för tävlingar, viktklasser och gym.",
    "version": "v1"
  },
  "paths": {
    "/api/public/weightclasses": {
      "get": {
        "tags": [
          "Public API"
        ],
        "summary": "Hämtar alla viktklasser",
        "description": "Returnerar en publik lista med alla viktklasser och deras namn.",
        "operationId": "GetPublicWeightClasses",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/PublicWeightClassDto"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/public/ranking": {
      "get": {
        "tags": [
          "Public API"
        ],
        "summary": "Hämtar senaste mästerskapsresultaten för alla viktklasser",
        "description": "Returnerar den senaste registrerade mästerskapstävlingen för varje viktklass, inklusive år, mästerskap och placeringar.",
        "operationId": "GetPublicWeightClassRanking",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/PublicWeightClassChampionshipDto"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/public/weightclasses/{id}/championships/{year}": {
      "get": {
        "tags": [
          "Public API"
        ],
        "summary": "Hämtar mästerskapsresultat för en viktklass och ett år",
        "description": "Returnerar alla mästerskap som finns registrerade för en viss viktklass under ett visst år, inklusive placeringar och namn på deltagare.",
        "operationId": "GetPublicWeightClassChampionships",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Viktklassens id.",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "example": 1
          },
          {
            "name": "year",
            "in": "path",
            "description": "Året som mästerskapsresultaten ska hämtas för.",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "example": 2026
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/PublicWeightClassChampionshipDto"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not Found"
          }
        }
      }
    },
    "/api/public/competitors/championships": {
      "get": {
        "tags": [
          "Public API"
        ],
        "summary": "Hämtar en tävlandes placeringar i mästerskap",
        "description": "Sök på namn och returnera alla registrerade mästerskapsplaceringar för den tävlande, inklusive mästerskap, år och viktklass. Matchningen ignorerar stora och små bokstäver.",
        "operationId": "GetPublicCompetitorChampionships",
        "parameters": [
          {
            "name": "name",
            "in": "query",
            "description": "Den tävlandes namn. Sökningen matchar registrerat namn utan hänsyn till stora och små bokstäver.",
            "schema": {
              "type": "string"
            },
            "example": "Christian Andersson"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicCompetitorChampionshipResultDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicApiErrorDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicApiErrorDto"
                }
              }
            }
          }
        }
      }
    },
    "/api/public/competitions": {
      "get": {
        "tags": [
          "Public API"
        ],
        "summary": "Hämtar publika tävlingar inom ett datumintervall",
        "description": "Returnerar tävlingar inom valt datumintervall. Om inget intervall anges returneras alla publika tävlingar i databasen.",
        "operationId": "GetPublicCompetitions",
        "parameters": [
          {
            "name": "from",
            "in": "query",
            "description": "Startdatum för filtrering i formatet YYYY-MM-DD. Valfri.",
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "example": "2026-01-01"
          },
          {
            "name": "to",
            "in": "query",
            "description": "Slutdatum för filtrering i formatet YYYY-MM-DD. Valfri.",
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "example": "2026-12-31"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/PublicCompetitionDto"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicApiErrorDto"
                }
              }
            }
          }
        }
      }
    },
    "/api/public/gyms": {
      "get": {
        "tags": [
          "Public API"
        ],
        "summary": "Hämtar alla gym",
        "description": "Returnerar en publik lista med gym, kontaktuppgifter, öppettider och utrustning. Bilder och logotyper ingår inte.",
        "operationId": "GetPublicGyms",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/PublicGymDto"
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "PublicApiErrorDto": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "PublicChampionshipPlacementDto": {
        "type": "object",
        "properties": {
          "placement": {
            "type": "integer",
            "format": "int32"
          },
          "competitorName": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "PublicCompetitionDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32"
          },
          "name": {
            "type": "string",
            "nullable": true
          },
          "date": {
            "type": "string",
            "format": "date-time"
          },
          "location": {
            "type": "string",
            "nullable": true
          },
          "city": {
            "type": "string",
            "nullable": true
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "latitude": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "longitude": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "allowOnlineRegistration": {
            "type": "boolean"
          },
          "showSwishQrCode": {
            "type": "boolean"
          },
          "showPosterAndQrCode": {
            "type": "boolean"
          },
          "streamUrl": {
            "type": "string",
            "nullable": true
          },
          "resultsUrl": {
            "type": "string",
            "nullable": true
          },
          "facebookUrl": {
            "type": "string",
            "nullable": true
          },
          "instagramUrl": {
            "type": "string",
            "nullable": true
          },
          "websiteUrl": {
            "type": "string",
            "nullable": true
          },
          "contactInfo": {
            "type": "string",
            "nullable": true
          },
          "registrationDeadline": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "registrationFee": {
            "type": "string",
            "nullable": true
          },
          "maxParticipants": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "swishNumber": {
            "type": "string",
            "nullable": true
          },
          "swishMessage": {
            "type": "string",
            "nullable": true
          },
          "weightClasses": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true
          },
          "events": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PublicCompetitionEventDto"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "PublicCompetitionEventDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32"
          },
          "name": {
            "type": "string",
            "nullable": true
          },
          "type": {
            "type": "string",
            "nullable": true
          },
          "weight": {
            "type": "string",
            "nullable": true
          },
          "orderIndex": {
            "type": "integer",
            "format": "int32"
          }
        },
        "additionalProperties": false
      },
      "PublicCompetitorChampionshipPlacementDto": {
        "type": "object",
        "properties": {
          "championshipName": {
            "type": "string",
            "nullable": true
          },
          "year": {
            "type": "integer",
            "format": "int32"
          },
          "placement": {
            "type": "integer",
            "format": "int32"
          },
          "weightClassId": {
            "type": "integer",
            "format": "int32"
          },
          "weightClassName": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "PublicCompetitorChampionshipResultDto": {
        "type": "object",
        "properties": {
          "competitorName": {
            "type": "string",
            "nullable": true
          },
          "placings": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PublicCompetitorChampionshipPlacementDto"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "PublicGymDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32"
          },
          "name": {
            "type": "string",
            "nullable": true
          },
          "latitude": {
            "type": "number",
            "format": "double"
          },
          "longitude": {
            "type": "number",
            "format": "double"
          },
          "address": {
            "type": "string",
            "nullable": true
          },
          "website": {
            "type": "string",
            "nullable": true
          },
          "email": {
            "type": "string",
            "nullable": true
          },
          "phoneNumber": {
            "type": "string",
            "nullable": true
          },
          "instagramUrl": {
            "type": "string",
            "nullable": true
          },
          "facebookUrl": {
            "type": "string",
            "nullable": true
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "city": {
            "type": "string",
            "nullable": true
          },
          "openingHours": {
            "$ref": "#/components/schemas/PublicGymOpeningHoursDto"
          },
          "equipments": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "PublicGymOpeningHoursDto": {
        "type": "object",
        "properties": {
          "mannedMondayHours": {
            "type": "string",
            "nullable": true
          },
          "mannedTuesdayHours": {
            "type": "string",
            "nullable": true
          },
          "mannedWednesdayHours": {
            "type": "string",
            "nullable": true
          },
          "mannedThursdayHours": {
            "type": "string",
            "nullable": true
          },
          "mannedFridayHours": {
            "type": "string",
            "nullable": true
          },
          "mannedSaturdayHours": {
            "type": "string",
            "nullable": true
          },
          "mannedSundayHours": {
            "type": "string",
            "nullable": true
          },
          "unmannedMondayHours": {
            "type": "string",
            "nullable": true
          },
          "unmannedTuesdayHours": {
            "type": "string",
            "nullable": true
          },
          "unmannedWednesdayHours": {
            "type": "string",
            "nullable": true
          },
          "unmannedThursdayHours": {
            "type": "string",
            "nullable": true
          },
          "unmannedFridayHours": {
            "type": "string",
            "nullable": true
          },
          "unmannedSaturdayHours": {
            "type": "string",
            "nullable": true
          },
          "unmannedSundayHours": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "PublicWeightClassChampionshipDto": {
        "type": "object",
        "properties": {
          "championshipName": {
            "type": "string",
            "nullable": true
          },
          "year": {
            "type": "integer",
            "format": "int32"
          },
          "weightClassId": {
            "type": "integer",
            "format": "int32"
          },
          "weightClassName": {
            "type": "string",
            "nullable": true
          },
          "results": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PublicChampionshipPlacementDto"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "PublicWeightClassDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32"
          },
          "name": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      }
    }
  }
}