{
  "openapi": "3.1.0",
  "info": {
    "title": "SuperȘcoala API",
    "version": "1.0.0",
    "description": "Catalog de materii, clase, capitole și lecții video pentru clasele I-XII, plus pachetele de abonament. Citirile publice sunt anonime și pot fi păstrate în cache 5 minute. Limitare: 200 cereri / 5 minute per IP, apoi întârziere progresivă.",
    "termsOfService": "https://scoala.ro/terms",
    "contact": {
      "name": "SuperȘcoala",
      "url": "https://scoala.ro/contact"
    }
  },
  "servers": [
    {
      "url": "https://scoala.ro/api"
    }
  ],
  "paths": {
    "/public/subjects": {
      "get": {
        "operationId": "listSubjects",
        "summary": "Lista materiilor active, fără duplicate de titlu.",
        "security": [
          {},
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Materiile disponibile.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Subject"
                  }
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/public/grouped-subjects": {
      "get": {
        "operationId": "listGroupedSubjects",
        "summary": "Materiile cu clasele lor, pentru meniul de navigare.",
        "security": [
          {},
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Materii cu subcategorii.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "allOf": [
                      {
                        "$ref": "#/components/schemas/SubjectSummary"
                      },
                      {
                        "type": "object",
                        "properties": {
                          "subcategories": {
                            "type": "array",
                            "items": {
                              "$ref": "#/components/schemas/SubjectSummary"
                            }
                          }
                        }
                      }
                    ]
                  }
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/public/courses": {
      "get": {
        "operationId": "listCourses",
        "summary": "Clasele (cursurile) unei materii.",
        "parameters": [
          {
            "name": "subjectId",
            "in": "query",
            "required": true,
            "description": "Id-ul materiei părinte.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Clasele materiei cerute.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Course"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/public/packages": {
      "get": {
        "operationId": "listPackages",
        "summary": "Pachetele de abonament active și countdown-ul de ofertă.",
        "responses": {
          "200": {
            "description": "Pachete și setările countdown-ului.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "packages": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Package"
                      }
                    },
                    "offersCountdown": {
                      "type": "object",
                      "properties": {
                        "OffersCountdownText": {
                          "type": "string"
                        },
                        "OffersCountdownTextVisible": {
                          "type": "boolean"
                        },
                        "OffersCountdownVisible": {
                          "type": "boolean"
                        },
                        "OffersCountdownExpiresAt": {
                          "type": ["string", "null"],
                          "format": "date-time"
                        }
                      }
                    }
                  },
                  "required": ["packages", "offersCountdown"]
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/public/packages/{parameter}": {
      "get": {
        "operationId": "viewPackage",
        "summary": "Detaliile unui pachet după parametrul lui public.",
        "parameters": [
          {
            "name": "parameter",
            "in": "path",
            "required": true,
            "description": "Parametrul public al pachetului.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Pachetul cerut, cu beneficii și cuponul aplicat.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Package"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "description": {
                          "type": ["string", "null"]
                        },
                        "months": {
                          "type": ["integer", "null"]
                        },
                        "categoryId": {
                          "type": ["integer", "null"]
                        },
                        "categoryType": {
                          "type": ["string", "null"]
                        },
                        "couponDiscountPercent": {
                          "type": ["number", "null"]
                        },
                        "couponDiscountValue": {
                          "type": ["number", "null"]
                        },
                        "coupon": {
                          "type": "object",
                          "properties": {
                            "duration": {
                              "type": "string"
                            },
                            "durationInMonths": {
                              "type": ["integer", "null"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/public/autocomplete-lessons": {
      "get": {
        "operationId": "autocompleteLessons",
        "summary": "Sugestii de titluri de lecții pentru căutarea rapidă.",
        "parameters": [
          {
            "name": "searchTerm",
            "in": "query",
            "required": true,
            "description": "Termenul căutat, minimum 3 caractere.",
            "schema": {
              "type": "string",
              "minLength": 3
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Cel mult 14 titluri normalizate.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/public/sitemap-paths": {
      "get": {
        "operationId": "listSitemapPaths",
        "summary": "Toate URL-urile publice ale platformei, pentru sitemap.",
        "responses": {
          "200": {
            "description": "Intrările de sitemap.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "loc": {
                        "type": "string",
                        "format": "uri"
                      },
                      "priority": {
                        "type": "number"
                      },
                      "changefreq": {
                        "type": "string"
                      }
                    },
                    "required": ["loc", "priority", "changefreq"]
                  }
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/public/button-settings": {
      "get": {
        "operationId": "getButtonSettings",
        "summary": "Textele butoanelor de înregistrare configurate în admin.",
        "responses": {
          "200": {
            "description": "Textele curente.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "RegistrationButtonText": {
                      "type": "string"
                    },
                    "FreeRegistrationButtonText": {
                      "type": "string"
                    }
                  },
                  "required": ["RegistrationButtonText", "FreeRegistrationButtonText"]
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/public/breadcrumbs": {
      "post": {
        "operationId": "getBreadcrumbs",
        "summary": "Traduce slug-urile din URL în etichete de breadcrumb.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "query": {
                    "type": "object",
                    "properties": {
                      "subjectSlug": {
                        "type": "string"
                      },
                      "categorySlug": {
                        "type": "string"
                      },
                      "chapterSlug": {
                        "type": "string"
                      }
                    },
                    "required": ["subjectSlug"]
                  }
                },
                "required": ["query"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Breadcrumb-urile, de la materie spre capitol.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "label": {
                        "type": "string"
                      },
                      "href": {
                        "type": "string"
                      }
                    },
                    "required": ["label", "href"]
                  }
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/client/subjects/{id}": {
      "get": {
        "operationId": "viewSubject",
        "summary": "O materie după id.",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdPath"
          }
        ],
        "responses": {
          "200": {
            "description": "Materia cerută.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Subject"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/client/lessons": {
      "get": {
        "operationId": "listLessons",
        "summary": "Capitolele unei clase, fiecare cu lecțiile lui.",
        "parameters": [
          {
            "name": "courseId",
            "in": "query",
            "required": true,
            "description": "Id-ul clasei (cursului).",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Capitolele clasei cu lecțiile lor.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "Id": {
                        "type": "integer"
                      },
                      "CategoryId": {
                        "type": "integer"
                      },
                      "Title": {
                        "type": "string"
                      },
                      "OrderNo": {
                        "type": "integer"
                      },
                      "IsActive": {
                        "type": "boolean"
                      },
                      "IsDeleted": {
                        "type": "boolean"
                      },
                      "IsFree": {
                        "type": "boolean"
                      },
                      "MetaTitle": {
                        "type": ["string", "null"]
                      },
                      "MetaDescription": {
                        "type": ["string", "null"]
                      },
                      "Chapters": {
                        "type": "array",
                        "items": {
                          "$ref": "#/components/schemas/Lesson"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/client/lessons/{id}": {
      "get": {
        "operationId": "viewLesson",
        "summary": "O lecție după id, cu contextul ei și lecțiile următoare.",
        "security": [
          {},
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/IdPath"
          }
        ],
        "responses": {
          "200": {
            "description": "Lecția cerută.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Lesson"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "ChapterId": {
                          "type": "integer"
                        },
                        "ChapterTitle": {
                          "type": "string"
                        },
                        "CategoryId": {
                          "type": "integer"
                        },
                        "CategoryTitle": {
                          "type": "string"
                        },
                        "SubjectId": {
                          "type": "integer"
                        },
                        "SubjectTitle": {
                          "type": "string"
                        },
                        "DiplomaEnabled": {
                          "type": "boolean"
                        },
                        "HasExercise": {
                          "type": "boolean"
                        },
                        "Slug": {
                          "type": "string"
                        },
                        "UploadDate": {
                          "type": ["string", "null"]
                        },
                        "NextLessons": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/Lesson"
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/client/search-lessons": {
      "get": {
        "operationId": "searchLessons",
        "summary": "Căutare în lecții, grupată pe materie și clasă.",
        "parameters": [
          {
            "name": "searchTerm",
            "in": "query",
            "required": true,
            "description": "Termenul căutat; sub 3 caractere întoarce o listă goală.",
            "schema": {
              "type": "string",
              "minLength": 3
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Grupuri de rezultate.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "SubjectId": {
                        "type": "integer"
                      },
                      "SubjectTitle": {
                        "type": "string"
                      },
                      "CourseId": {
                        "type": "integer"
                      },
                      "CourseTitle": {
                        "type": "string"
                      },
                      "CourseOrder": {
                        "type": "integer"
                      },
                      "Videos": {
                        "type": "array",
                        "items": {
                          "$ref": "#/components/schemas/Lesson"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "description": "Opțional. Fără token răspunsurile conțin doar conținutul public."
      }
    },
    "parameters": {
      "IdPath": {
        "name": "id",
        "in": "path",
        "required": true,
        "description": "Identificator numeric.",
        "schema": {
          "type": "integer"
        }
      }
    },
    "responses": {
      "BadRequest": {
        "description": "Parametri lipsă sau invalizi.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "NotFound": {
        "description": "Resursa nu există.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "ServerError": {
        "description": "Eroare internă.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "description": "Formatul unic de eroare al API-ului.",
        "properties": {
          "name": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        },
        "required": ["name", "message"]
      },
      "Badge": {
        "type": "object",
        "properties": {
          "IconName": {
            "type": "string"
          },
          "BadgeTitle": {
            "type": "string"
          }
        }
      },
      "SubjectSummary": {
        "type": "object",
        "description": "Materie sau clasă, doar câmpurile de navigare și SEO.",
        "properties": {
          "Id": {
            "type": "integer"
          },
          "Title": {
            "type": "string"
          },
          "ParentCategoryId": {
            "type": ["integer", "null"]
          },
          "OrderNo": {
            "type": "integer"
          },
          "MetaTitle": {
            "type": ["string", "null"]
          },
          "MetaDescription": {
            "type": ["string", "null"]
          }
        }
      },
      "Subject": {
        "type": "object",
        "description": "Materie de studiu (categorie rădăcină).",
        "properties": {
          "Id": {
            "type": "integer"
          },
          "Title": {
            "type": "string"
          },
          "Description1": {
            "type": ["string", "null"]
          },
          "Description2": {
            "type": ["string", "null"]
          },
          "Description3": {
            "type": ["string", "null"]
          },
          "Image1Url": {
            "type": ["string", "null"]
          },
          "Image2Url": {
            "type": ["string", "null"]
          },
          "Image3Url": {
            "type": ["string", "null"]
          },
          "IsActive": {
            "type": "boolean"
          },
          "IsDeleted": {
            "type": "boolean"
          },
          "OrderNo": {
            "type": "integer"
          },
          "ParentCategoryId": {
            "type": ["integer", "null"]
          },
          "MetaTitle": {
            "type": ["string", "null"]
          },
          "MetaDescription": {
            "type": ["string", "null"]
          },
          "Badges": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Badge"
            }
          }
        }
      },
      "Course": {
        "$ref": "#/components/schemas/Subject",
        "description": "Clasă dintr-o materie; aceeași formă ca Subject, cu ParentCategoryId setat."
      },
      "Lesson": {
        "type": "object",
        "description": "Lecție video; câmpurile de conținut lipsesc când AccessType este restricționat.",
        "properties": {
          "Id": {
            "type": "integer"
          },
          "SubcategoryId": {
            "type": "integer"
          },
          "SubcategoryTitle": {
            "type": ["string", "null"]
          },
          "Title": {
            "type": "string"
          },
          "Description1": {
            "type": ["string", "null"]
          },
          "Description2": {
            "type": ["string", "null"]
          },
          "Image1Url": {
            "type": ["string", "null"]
          },
          "Image2Url": {
            "type": ["string", "null"]
          },
          "VideoUrl": {
            "type": ["string", "null"]
          },
          "ShortVideoUrl": {
            "type": ["string", "null"]
          },
          "PreviewUrl": {
            "type": ["string", "null"]
          },
          "TextScriptUrl": {
            "type": ["string", "null"]
          },
          "TranscriptUrl": {
            "type": ["string", "null"]
          },
          "LessonHtmlContent": {
            "type": ["string", "null"]
          },
          "TestEmbeddedCode": {
            "type": ["string", "null"]
          },
          "TestId": {
            "type": ["integer", "null"]
          },
          "QuizId": {
            "type": ["integer", "null"]
          },
          "ExerciseId": {
            "type": ["integer", "null"]
          },
          "IsFree": {
            "type": "boolean"
          },
          "IsFreeForRegistered": {
            "type": "boolean"
          },
          "IsDeleted": {
            "type": "boolean"
          },
          "HasCC": {
            "type": "boolean"
          },
          "OrderNo": {
            "type": "integer"
          },
          "MetaTitle": {
            "type": ["string", "null"]
          },
          "MetaDescription": {
            "type": ["string", "null"]
          },
          "MetaImage": {
            "type": ["string", "null"]
          },
          "LessonKeywords": {
            "type": ["string", "null"]
          },
          "Type": {
            "type": ["string", "null"]
          },
          "Status": {
            "type": ["string", "null"]
          },
          "AccessType": {
            "type": "string"
          },
          "Badges": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Badge"
            }
          }
        }
      },
      "Package": {
        "type": "object",
        "description": "Pachet de abonament.",
        "properties": {
          "id": {
            "type": "integer"
          },
          "parameter": {
            "type": "string"
          },
          "shortTitle": {
            "type": "string"
          },
          "longTitle": {
            "type": "string"
          },
          "currency": {
            "type": "string"
          },
          "price": {
            "type": "number"
          },
          "listPrice": {
            "type": ["number", "null"]
          },
          "discountedPrice": {
            "type": "number"
          },
          "firstMonthPrice": {
            "type": ["number", "null"]
          },
          "firstMonthAfterTrialPrice": {
            "type": ["number", "null"]
          },
          "trialDays": {
            "type": ["integer", "null"]
          },
          "couponDiscountMonths": {
            "type": ["integer", "null"]
          },
          "badgeContent": {
            "type": ["string", "null"]
          },
          "priceNote": {
            "type": ["string", "null"]
          },
          "secondPriceNote": {
            "type": ["string", "null"]
          },
          "period": {
            "type": ["string", "null"]
          },
          "benefits": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "Id": {
                  "type": "integer"
                },
                "BenefitText": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    }
  }
}
