imports:
  commons: ../../commons.yml
  problem: ../../problem.yml

types:
  TestCaseTemplateId: string
  TestCaseId: string
  ParameterId: string
  ProblemInfoV2:
    properties:
      problemId: commons.ProblemId
      problemDescription: problem.ProblemDescription
      problemName: string
      problemVersion: integer
      supportedLanguages: set<commons.Language>
      customFiles: CustomFiles
      generatedFiles: GeneratedFiles
      customTestCaseTemplates: list<TestCaseTemplate>
      testcases: list<TestCaseV2>
      isPublic: boolean
  LightweightProblemInfoV2:
    properties:
      problemId: commons.ProblemId
      problemName: string
      problemVersion: integer
      variableTypes: set<commons.VariableType>
  CreateProblemRequestV2:
    properties:
      problemName: string
      problemDescription: problem.ProblemDescription
      customFiles: CustomFiles
      customTestCaseTemplates: list<TestCaseTemplate>
      testcases: list<TestCaseV2>
      supportedLanguages: set<commons.Language>
      isPublic: boolean
  TestCaseV2:
    properties:
      metadata: TestCaseMetadata
      implementation: TestCaseImplementationReference
      arguments: map<ParameterId, commons.VariableValue>
      expects: optional<TestCaseExpects>
  TestCaseExpects:
    properties:
      expectedStdout: optional<string>
  TestCaseImplementationReference:
    union:
      templateId: TestCaseTemplateId
      implementation: TestCaseImplementation
  BasicTestCaseTemplate:
    properties:
      templateId: TestCaseTemplateId
      name: string
      description: TestCaseImplementationDescription
      expectedValueParameterId: ParameterId
  TestCaseTemplate:
    properties:
      templateId: TestCaseTemplateId
      name: string
      implementation: TestCaseImplementation
  TestCaseImplementation:
    properties:
      description: TestCaseImplementationDescription
      function: TestCaseFunction
  TestCaseFunction:
    union:
      withActualResult: TestCaseWithActualResultImplementation
      custom: VoidFunctionDefinition
  TestCaseWithActualResultImplementation:
    properties:
      getActualResult: NonVoidFunctionDefinition
      assertCorrectnessCheck: AssertCorrectnessCheck
  VoidFunctionDefinition:
    properties:
      parameters: list<Parameter>
      code: FunctionImplementationForMultipleLanguages
  Parameter:
    properties:
      parameterId: ParameterId
      name: string
      variableType: commons.VariableType
  NonVoidFunctionDefinition:
    properties:
      signature: NonVoidFunctionSignature
      code: FunctionImplementationForMultipleLanguages
  VoidFunctionSignature:
    properties:
      parameters: list<Parameter>
  NonVoidFunctionSignature:
    properties:
      parameters: list<Parameter>
      returnType: commons.VariableType
  VoidFunctionSignatureThatTakesActualResult:
    properties:
      parameters: list<Parameter>
      actualResultType: commons.VariableType
  AssertCorrectnessCheck:
    union:
      deepEquality: DeepEqualityCorrectnessCheck
      custom: VoidFunctionDefinitionThatTakesActualResult
  DeepEqualityCorrectnessCheck:
    properties:
      expectedValueParameterId: ParameterId
  VoidFunctionDefinitionThatTakesActualResult:
    docs: The generated signature will include an additional param, actualResult
    properties:
      additionalParameters: list<Parameter>
      code: FunctionImplementationForMultipleLanguages
  TestCaseImplementationDescription:
    properties:
      boards: list<TestCaseImplementationDescriptionBoard>
  TestCaseImplementationDescriptionBoard:
    union:
      html: string
      paramId: ParameterId
  TestCaseMetadata:
    properties:
      id: TestCaseId
      name: string
      hidden: boolean
  FunctionImplementationForMultipleLanguages:
    properties:
      codeByLanguage: map<commons.Language, FunctionImplementation>
  FunctionImplementation:
    properties:
      impl: string
      imports: optional<string>
  GeneratedFiles:
    properties:
      generatedTestCaseFiles: map<commons.Language, Files>
      generatedTemplateFiles: map<commons.Language, Files>
      other: map<commons.Language, Files>
  CustomFiles:
    union:
      basic: BasicCustomFiles
      custom: map<commons.Language, Files>
  BasicCustomFiles:
    properties:
      methodName: string
      signature: NonVoidFunctionSignature
      additionalFiles: map<commons.Language, Files>
      basicTestCaseTemplate: BasicTestCaseTemplate
  Files:
    properties:
      files: list<FileInfoV2>
  FileInfoV2:
    properties:
      filename: string
      directory: string
      contents: string
      editable: boolean
  DefaultProvidedFile:
    properties:
      file: FileInfoV2
      relatedTypes: list<commons.VariableType>
  FunctionSignature:
    union:
      void: VoidFunctionSignature
      nonVoid: NonVoidFunctionSignature
      voidThatTakesActualResult:
        type: VoidFunctionSignatureThatTakesActualResult
        docs: Useful when specifying custom grading for a testcase where actualResult is
          defined.
  GetFunctionSignatureRequest:
    properties:
      functionSignature: FunctionSignature
  GetFunctionSignatureResponse:
    properties:
      functionByLanguage: map<commons.Language, string>

  GetBasicSolutionFileRequest:
    properties:
      methodName: string
      signature: NonVoidFunctionSignature
  GetBasicSolutionFileResponse:
    properties:
      solutionFileByLanguage: map<commons.Language, FileInfoV2>

  GetGeneratedTestCaseFileRequest:
    properties:
      template: optional<TestCaseTemplate>
      testCase: TestCaseV2

  GetGeneratedTestCaseTemplateFileRequest:
    properties:
      template: TestCaseTemplate

service:
  base-path: /problems-v2
  auth: false
  endpoints:
    getLightweightProblems:
      docs: Returns lightweight versions of all problems
      method: GET
      path: /lightweight-problem-info
      response: list<LightweightProblemInfoV2>

    getProblems:
      docs: Returns latest versions of all problems
      method: GET
      path: /problem-info
      response: list<ProblemInfoV2>

    getLatestProblem:
      docs: Returns latest version of a problem
      method: GET
      path: /problem-info/{problemId}
      path-parameters:
        problemId: commons.ProblemId
      response: ProblemInfoV2

    getProblemVersion:
      docs: Returns requested version of a problem
      method: GET
      path: /problem-info/{problemId}/version/{problemVersion}
      path-parameters:
        problemId: commons.ProblemId
        problemVersion: integer
      response: ProblemInfoV2
