imports:
  commons: commons.yml

types:
  ProblemInfo:
    properties:
      problemId: commons.ProblemId
      problemDescription: ProblemDescription
      problemName: string
      problemVersion: integer
      files: map<commons.Language, ProblemFiles>
      inputParams: list<VariableTypeAndName>
      outputType: commons.VariableType
      testcases: list<commons.TestCaseWithExpectedResult>
      methodName: string
      supportsCustomTestCases: boolean
  ProblemDescription:
    properties:
      boards: list<ProblemDescriptionBoard>
  ProblemDescriptionBoard:
    union:
      html: string
      variable: commons.VariableValue
      testCaseId: string
  ProblemFiles:
    properties:
      solutionFile: commons.FileInfo
      readOnlyFiles: list<commons.FileInfo>
  VariableTypeAndName:
    properties:
      variableType: commons.VariableType
      name: string
  CreateProblemRequest:
    properties:
      problemName: string
      problemDescription: ProblemDescription
      files: map<commons.Language, ProblemFiles>
      inputParams: list<VariableTypeAndName>
      outputType: commons.VariableType
      testcases: list<commons.TestCaseWithExpectedResult>
      methodName: string
  CreateProblemResponse:
    union:
      success: commons.ProblemId
      error: CreateProblemError

  UpdateProblemResponse:
    properties:
      problemVersion: integer

  CreateProblemError:
    discriminant:
      value: _type
      name: errorType
    union:
      generic: GenericCreateProblemError
  GenericCreateProblemError:
    properties:
      message: string
      type: string
      stacktrace: string

  GetDefaultStarterFilesResponse:
    properties:
      files: map<commons.Language, ProblemFiles>

service:
  base-path: /problem-crud
  auth: false
  endpoints:
    createProblem:
      docs: Creates a problem
      method: POST
      path: /create
      request: CreateProblemRequest
      response: CreateProblemResponse

    updateProblem:
      docs: Updates a problem
      method: POST
      path: /update/{problemId}
      path-parameters:
        problemId: commons.ProblemId
      request:
        body:
          type: CreateProblemRequest
      response: UpdateProblemResponse

    deleteProblem:
      docs: Soft deletes a problem
      method: DELETE
      path: /delete/{problemId}
      path-parameters:
        problemId: commons.ProblemId

    getDefaultStarterFiles:
      docs: Returns default starter files for problem
      method: POST
      path: /default-starter-files
      request:
        name: GetDefaultStarterFilesRequest
        body:
          properties:
            inputParams: list<VariableTypeAndName>
            outputType: commons.VariableType
            methodName:
              type: string
              docs: |
                The name of the `method` that the student has to complete.
                The method name cannot include the following characters:
                  - Greater Than `>`
                  - Less Than `<``
                  - Equals `=`
                  - Period `.`
      response: GetDefaultStarterFilesResponse
