appirio-tech/lc1-challenge-service

View on GitHub
api/swagger/swagger.yaml

Summary

Maintainability
Test Coverage
swagger: '2.0'
info:
  version: "0.2.1"
  title: Serenity Challenge API
  description: "API to host challenge, requirements, scorecard and results"
# during dev, should point to your local machine
# This will update based upon env variable SWAGGER_HOST
host: lc1-challenge-service.herokuapp.com
# basePath prefixes all resource paths
# basePath: /
#
schemes:
  # tip: remove http to make production-grade
  - http
  - https
# format of bodies a client can send (Content-Type)
consumes:
  - application/json
# format of the responses to the client (Accepts)
produces:
  - application/json
x-volos-resources: {}
paths:
  /challenges:
    get:
      tags:
        - challenges
      x-swagger-router-controller: challenges
      summary: Get all the challenges
      description: get all the challenges
      # used as the method name of the controller
      operationId: getAll
      parameters:
        - name: filter
          in: query
          type: string
          description: "{fieldName1}={fieldValue1}&...{fieldNameN}>{fieldValueN}. String value needs to be surrounded by single quotation(‘). fieldValue can contain multiple values using in() format {fieldName}=in({fieldValue1},{fieldValue1}). Operations can be =, > or <.  < and > operations are only for number, integers and dates"
        - name: limit
          in: query
          type: integer
          format: int32
          description: maximum number of records to return
        - name: offset
          in: query
          type: integer
          format: int32
          description: id to start return values
        - name: orderBy
          in: query
          type: string
          description: field name to sort {asc [nulls {first | last} ] | desc  [nulls {first | last} }
        - name: fields
          in: query
          type: string
          description: partial fields that need to be response. Support (1) comma-separated field list and (2) a/b nested selection.
      responses:
        "200":
          description: Returns a list of all challenge resources
          schema:
            $ref: '#/definitions/ChallengesResponse'
        default:
          description: Error
          schema:
            $ref: '#/definitions/ErrorResponse'
    post:
      tags:
        - challenges
      x-swagger-router-controller: challenges
      description: Create a new challenge
      summary: Create a new challenge
      operationId: create
      parameters:
        - name: body
          in: body
          required: true
          schema:
            $ref: '#/definitions/ChallengeResource'
      responses:
        "200":
          description: Success
          schema:
            $ref: '#/definitions/ActionResponse'
        default:
          description: Error
          schema:
            $ref: '#/definitions/ErrorResponse'
  /challenges/{challengeId}:
    get:
      tags:
        - challenges
      x-swagger-router-controller: challenges
      operationId: getByChallengeId
      description: Get a challenge
      summary: Get a challenge
      parameters:
        - name: challengeId
          in: path
          required: true
          type: integer
          format: int64
        - name: fields
          in: query
          type: string
          description: partial fields that need to be response. Support (1) comma-separated field list and (2) a/b nested selection.
      responses:
        "200":
          description: A full challenge resource
          schema:
            $ref: '#/definitions/ChallengeResponse'
        default:
          description: Error
          schema:
            $ref: '#/definitions/ErrorResponse'
    put:
      tags:
        - challenges
      x-swagger-router-controller: challenges
      description: Update a challenge
      summary: Update a challenge
      operationId: update
      parameters:
        - name: challengeId
          in: path
          required: true
          type: integer
          format: int64
        - name: body
          in: body
          required: true
          schema:
            $ref: '#/definitions/ChallengeResource'
      responses:
        "200":
          description: Success
          schema:
            $ref: '#/definitions/ActionResponse'
        default:
          description: Error
          schema:
            $ref: '#/definitions/ErrorResponse'
    delete:
      tags:
        - challenges
      x-swagger-router-controller: challenges
      description: Delete a challenge. Only DRAFT challenges can be deleted.
      summary: Delete a challenge
      operationId: delete
      parameters:
        - name: challengeId
          in: path
          required: true
          type: integer
          format: int64
      responses:
        "200":
          description: Challenge was deleted
          schema:
            $ref: '#/definitions/ActionResponse'
        default:
          description: Error
          schema:
            $ref: '#/definitions/ErrorResponse'
  /challenges/{challengeId}/register:
    get:
      tags:
        - challenges
      x-swagger-router-controller: challenges
      description: Register for a challenge
      summary: Register for a challenge
      operationId: register
      parameters:
        - name: challengeId
          in: path
          description: the id of the challenge
          type: integer
          format: int64
          required: true
      responses:
        "200":
          description: Success
          schema:
            $ref: '#/definitions/ActionResponse'
        default:
          description: Error
          schema:
            $ref: '#/definitions/ErrorResponse'
  /challenges/{challengeId}/files:
    post:
      tags:
        - challenges
        - files
      description: Add a new file to the challenge
      summary: Add a new file to the challenge
      x-swagger-router-controller: challenges
      operationId: addChallengeFile
      parameters:
        - name: challengeId
          in: path
          description: the id of the challenge
          type: integer
          format: int64
          required: true
        - name: body
          in: body
          description:  body of post
          required: true
          schema:
            $ref: '#/definitions/FileResource'
      responses:
        "200":
          description: Success
          schema:
            $ref: '#/definitions/ActionResponse'
        default:
          description: Error
          schema:
            $ref: '#/definitions/ErrorResponse'
    get:
      tags:
        - challenges
        - files
      description: Get files associated to a challenge
      summary: Get files assocaited to a challenge
      x-swagger-router-controller: challenges
      operationId: getChallengeFiles
      parameters:
        - name: challengeId
          in: path
          description: the id for the challenge to add the participant to
          type: integer
          format: int64
          required: true
        - name: fields
          in: query
          type: string
          description: partial fields that need to be response. Support (1) comma-separated field list and (2) a/b nested selection.
      responses:
        "200":
          description: Success
          schema:
            $ref: '#/definitions/FilesResponse'
        default:
          description: Error
          schema:
            $ref: '#/definitions/ErrorResponse'
  /challenges/{challengeId}/files/{fileId}:
    get:
      tags:
        - challenges
        - files
      x-swagger-router-controller: challenges
      description: Get the metadata information for a file
      summary: Get the metadata information for a file
      operationId: getChallengeFile
      parameters:
        - name: challengeId
          in: path
          description: The Challenge Id
          type: integer
          format: int64
          required: true
        - name: fileId
          in: path
          type: integer
          format: int64
          required: true
          description: The Id of the file
        - name: fields
          in: query
          type: string
          description: partial fields that need to be response. Support (1) comma-separated field list and (2) a/b nested selection.
      responses:
        "200":
          description: Returns a file resource
          schema:
            $ref: '#/definitions/FileResponse'
        default:
          description: Error
          schema:
            $ref: '#/definitions/ErrorResponse'
    put:
      tags:
        - challenges
        - files
      x-swagger-router-controller: challenges
      description: Update a file
      summary: Update a file
      operationId: updateChallengeFile
      parameters:
        - name: challengeId
          in: path
          description: The Challenge Id
          type: integer
          format: int64
          required: true
        - name: fileId
          in: path
          type: integer
          format: int64
          required: true
          description: The Id of the file
        - name: body
          in: body
          required: true
          schema:
            $ref: '#/definitions/FileResource'
      responses:
        "200":
          description: Success
          schema:
            $ref: '#/definitions/ActionResponse'
        default:
          description: Error
          schema:
            $ref: '#/definitions/ErrorResponse'
    delete:
      tags:
        - challenges
        - files
      x-swagger-router-controller: challenges
      description: Delete a file
      summary: Delete a file
      operationId: deleteChallengeFile
      parameters:
        - name: challengeId
          in: path
          description: The Challenge Id
          type: integer
          format: int64
          required: true
        - name: fileId
          in: path
          type: integer
          format: int64
          required: true
          description: The Id of the file
      responses:
        "200":
          description: Success
          schema:
            $ref: '#/definitions/ActionResponse'
        default:
          description: Error
          schema:
            $ref: '#/definitions/ErrorResponse'
  /challenges/{challengeId}/participants:
    post:
      tags:
        - challenges
        - participants
      description: Add a new participant to a challenge
      summary: Add a new participant to a challenge
      x-swagger-router-controller: challenges
      operationId: addParticipant
      parameters:
        - name: challengeId
          in: path
          description: the id for the challenge to add the participant to
          type: integer
          format: int64
          required: true
        - name: body
          in: body
          description:  body of post
          required: true
          schema:
            $ref: '#/definitions/ParticipantResource'
      responses:
        "200":
          description: Success
          schema:
            $ref: '#/definitions/ActionResponse'
        default:
          description: Error
          schema:
            $ref: '#/definitions/ErrorResponse'
    get:
      tags:
        - challenges
        - participants
      description: Get all participants for a challenge
      summary: Get all participants for a challenge
      x-swagger-router-controller: challenges
      operationId: getAllParticipants
      parameters:
        - name: challengeId
          in: path
          description: the id for the challenge to add the participant to
          type: integer
          format: int64
          required: true
        - name: role
          in: query
          description: The role to filter the results by
          type: string
        - name: fields
          in: query
          type: string
          description: partial fields that need to be response. Support (1) comma-separated field list and (2) a/b nested selection.
      responses:
        "200":
          description: Success
          schema:
            $ref: '#/definitions/ChallengeParticipantsResponse'
        default:
          description: Error
          schema:
            $ref: '#/definitions/ErrorResponse'
  /challenges/{challengeId}/participants/{participantId}:
    get:
      tags:
        - challenges
        - participants
      x-swagger-router-controller: challenges
      description: Get the metadata information for a participant
      summary: Get the metadata information for a participant
      operationId: getParticipant
      parameters:
        - name: challengeId
          in: path
          description: The Challenge Id
          type: integer
          format: int64
          required: true
        - name: participantId
          in: path
          type: integer
          format: int64
          required: true
          description: The Id of the participant
        - name: fields
          in: query
          type: string
          description: partial fields that need to be response. Support (1) comma-separated field list and (2) a/b nested selection.
      responses:
        "200":
          description: Returns a participant resource
          schema:
            $ref: '#/definitions/ChallengeParticipantResponse'
        default:
          description: Error
          schema:
            $ref: '#/definitions/ErrorResponse'
    put:
      tags:
        - challenges
        - participants
      description: Update the relationship from a user to a challenge
      summary: Update the relationship from a user to a challenge
      x-swagger-router-controller: challenges
      operationId: updateParticipant
      parameters:
        - name: challengeId
          in: path
          required: true
          type: integer
          format: int64
        - name: participantId
          in: path
          required: true
          type: integer
          format: int64
        - name: body
          in: body
          required: true
          schema:
            $ref: '#/definitions/ParticipantResource'
      responses:
        "200":
          description: Success
          schema:
            $ref: '#/definitions/ActionResponse'
        default:
          description: Error
          schema:
            $ref: '#/definitions/ErrorResponse'
    delete:
      tags:
        - challenges
        - participants
      description: Remove a participant from a challenge
      summary: Remove a participant from a challenge
      x-swagger-router-controller: challenges
      operationId: removeParticipant
      parameters:
        - name: challengeId
          in: path
          required: true
          type: integer
          format: int64
        - name: participantId
          in: path
          required: true
          type: integer
          format: int64
      responses:
        "200":
          description: Success
          schema:
            $ref: '#/definitions/ActionResponse'
        default:
          description: Error
          schema:
            $ref: '#/definitions/ErrorResponse'
  /challenges/{challengeId}/submissions:
    post:
      tags:
        - challenges
        - submissions
      description: Submit to a challenge
      summary: Submit to a challenge
      x-swagger-router-controller: challenges
      operationId: createSubmission
      parameters:
        - name: challengeId
          in: path
          description: the id for the challenge to create a scorecard for
          type: integer
          format: int64
          required: true
        - name: body
          in: body
          description:  body of post
          required: true
          schema:
            $ref: '#/definitions/SubmissionResource'
      responses:
        "200":
          description: Success
          schema:
            $ref: '#/definitions/ActionResponse'
        default:
          description: Error
          schema:
            $ref: '#/definitions/ErrorResponse'
    get:
      tags:
        - challenges
        - submissions
      description: Get the submissions for a challenge
      summary: Get the submissions for a challenge
      x-swagger-router-controller: challenges
      operationId: getSubmissions
      parameters:
        - name: challengeId
          in: path
          description: the id for the challenge to add the participant to
          type: integer
          format: int64
          required: true
        - name: fields
          in: query
          type: string
          description: partial fields that need to be response. Support (1) comma-separated field list and (2) a/b nested selection.
      responses:
        "200":
          description: Success
          schema:
            $ref: '#/definitions/ChallengeSubmissionsResponse'
        default:
          description: Error
          schema:
            $ref: '#/definitions/ErrorResponse'
  /challenges/{challengeId}/submissions/{submissionId}:
    get:
      tags:
        - challenges
        - submissions
      x-swagger-router-controller: challenges
      description: Get the metadata information for a submission
      summary: Get the metadata information for a submission
      operationId: getSubmission
      parameters:
        - name: challengeId
          in: path
          description: The Challenge Id
          type: integer
          format: int64
          required: true
        - name: submissionId
          in: path
          type: integer
          format: int64
          required: true
          description: The Id of the submission
        - name: fields
          in: query
          type: string
          description: partial fields that need to be response. Support (1) comma-separated field list and (2) a/b nested selection.
      responses:
        "200":
          description: Returns a submission resource
          schema:
            $ref: '#/definitions/ChallengeSubmissionResponse'
        default:
          description: Error
          schema:
            $ref: '#/definitions/ErrorResponse'
    put:
      tags:
        - challenges
        - submissions
      description: Update the submission
      summary: Update the submission
      x-swagger-router-controller: challenges
      operationId: updateSubmission
      parameters:
        - name: challengeId
          in: path
          required: true
          type: integer
          format: int64
        - name: submissionId
          in: path
          required: true
          type: integer
          format: int64
        - name: body
          in: body
          required: true
          schema:
            $ref: '#/definitions/SubmissionResource'
      responses:
        "200":
          description: Success
          schema:
            $ref: '#/definitions/ActionResponse'
        default:
          description: Error
          schema:
            $ref: '#/definitions/ErrorResponse'
    delete:
      tags:
        - challenges
        - submissions
      description: Remove a submission from a challenge
      summary: Remove a submission from a challenge
      x-swagger-router-controller: challenges
      operationId: removeSubmission
      parameters:
        - name: challengeId
          in: path
          required: true
          type: integer
          format: int64
        - name: submissionId
          in: path
          required: true
          type: integer
          format: int64
      responses:
        "200":
          description: Success
          schema:
            $ref: '#/definitions/ActionResponse'
        default:
          description: Error
          schema:
            $ref: '#/definitions/ErrorResponse'
  /challenges/{challengeId}/submissions/{submissionId}/files:
    post:
      tags:
        - challenges
        - submissions
        - files
      description: Add a new file to the challenge
      summary: Add a new file to the challenge
      x-swagger-router-controller: files
      operationId: addFile
      parameters:
        - name: challengeId
          in: path
          description: the id of the challenge
          type: integer
          format: int64
          required: true
        - name: submissionId
          in: path
          description: the id of the challenge
          type: integer
          format: int64
          required: true
        - name: body
          in: body
          description:  body of post
          required: true
          schema:
            $ref: '#/definitions/FileResource'
      responses:
        "200":
          description: Success
          schema:
            $ref: '#/definitions/ActionResponse'
        default:
          description: Error
          schema:
            $ref: '#/definitions/ErrorResponse'
    get:
      tags:
        - challenges
        - submissions
        - files
      description: Get files associated to a submission
      summary: Get files associated to a submission
      x-swagger-router-controller: files
      operationId: getFiles
      parameters:
        - name: challengeId
          in: path
          description: the id for the challenge to add the participant to
          type: integer
          format: int64
          required: true
        - name: submissionId
          in: path
          description: the id of the challenge
          type: integer
          format: int64
          required: true
        - name: fields
          in: query
          type: string
          description: partial fields that need to be response. Support (1) comma-separated field list and (2) a/b nested selection.
      responses:
        "200":
          description: Success
          schema:
            $ref: '#/definitions/FilesResponse'
        default:
          description: Error
          schema:
            $ref: '#/definitions/ErrorResponse'
  /challenges/{challengeId}/submissions/{submissionId}/files/{fileId}:
    get:
      tags:
        - challenges
        - files
        - submissions
      x-swagger-router-controller: files
      description: Get the metadata information for a file
      summary: Get the metadata information for a file
      operationId: getFile
      parameters:
        - name: challengeId
          in: path
          description: The Challenge Id
          type: integer
          format: int64
          required: true
        - name: submissionId
          in: path
          description: the id of the challenge
          type: integer
          format: int64
          required: true
        - name: fileId
          in: path
          type: integer
          format: int64
          required: true
          description: The Id of the file
        - name: fields
          in: query
          type: string
          description: partial fields that need to be response. Support (1) comma-separated field list and (2) a/b nested selection.
      responses:
        "200":
          description: Returns a file resource
          schema:
            $ref: '#/definitions/FileResponse'
        default:
          description: Error
          schema:
            $ref: '#/definitions/ErrorResponse'
    put:
      tags:
        - challenges
        - submissions
        - files
      x-swagger-router-controller: files
      description: Update a file
      summary: Update a file
      operationId: updateFile
      parameters:
        - name: challengeId
          in: path
          description: The Challenge Id
          type: integer
          format: int64
          required: true
        - name: submissionId
          in: path
          description: the id of the challenge
          type: integer
          format: int64
          required: true
        - name: fileId
          in: path
          type: integer
          format: int64
          required: true
          description: The Id of the file
        - name: body
          in: body
          required: true
          schema:
            $ref: '#/definitions/FileResource'
      responses:
        "200":
          description: Success
          schema:
            $ref: '#/definitions/ActionResponse'
        default:
          description: Error
          schema:
            $ref: '#/definitions/ErrorResponse'
    delete:
      tags:
        - challenges
        - submissions
        - files
      x-swagger-router-controller: files
      description: Delete a file
      summary: Delete a file
      operationId: deleteFile
      parameters:
        - name: challengeId
          in: path
          description: The Challenge Id
          type: integer
          format: int64
          required: true
        - name: submissionId
          in: path
          description: the id of the challenge
          type: integer
          format: int64
          required: true
        - name: fileId
          in: path
          type: integer
          format: int64
          required: true
          description: The Id of the file
      responses:
        "200":
          description: Success
          schema:
            $ref: '#/definitions/ActionResponse'
        default:
          description: Error
          schema:
            $ref: '#/definitions/ErrorResponse'
  /challenges/{challengeId}/requirements:
    post:
      tags:
        - challenges
        - requirements
      description: Create a new requirement on a challenge
      summary: Create a new requirement
      x-swagger-router-controller: requirements
      operationId: createRequirement
      parameters:
        - name: challengeId
          in: path
          description: the id for the challenge to create a scorecard for
          type: integer
          format: int64
          required: true
        - name: body
          in: body
          description:  body of post
          required: true
          schema:
            $ref: '#/definitions/RequirementResource'
      responses:
        "200":
          description: Success
          schema:
            $ref: '#/definitions/ActionResponse'
        default:
          description: Error
          schema:
            $ref: '#/definitions/ErrorResponse'
    get:
      tags:
        - challenges
        - requirements
      description: Get all the requirements for a particular challenge
      summary: Get all the requirements for a particular challenge
      x-swagger-router-controller: requirements
      operationId: getAllRequirementsByChallengeId
      parameters:
        - name: challengeId
          in: path
          required: true
          type: integer
          format: int64
        - name: fields
          in: query
          type: string
          description: partial fields that need to be response. Support (1) comma-separated field list and (2) a/b nested selection.
      responses:
        "200":
          description: Array of requirement resources
          schema:
            $ref: '#/definitions/RequirementsResponse'
        default:
          description: Error
          schema:
            $ref: '#/definitions/ErrorResponse'
  /challenges/{challengeId}/requirements/{requirementId}:
    get:
      tags:
        - challenges
        - requirements
      x-swagger-router-controller: requirements
      description: Get the requirements details
      summary: Get the requirements details
      operationId: getRequirements
      parameters:
        - name: challengeId
          in: path
          description: The Challenge Id
          type: integer
          format: int64
          required: true
        - name: requirementId
          in: path
          type: integer
          format: int64
          required: true
          description: The Id of the requirement
        - name: fields
          in: query
          type: string
          description: partial fields that need to be response. Support (1) comma-separated field list and (2) a/b nested selection.
      responses:
        "200":
          description: Returns a requirements resource
          schema:
            $ref: '#/definitions/RequirementResponse'
        default:
          description: Error
          schema:
            $ref: '#/definitions/ErrorResponse'
    put:
      tags:
        - challenges
        - requirements
      x-swagger-router-controller: requirements
      description: Update a requirement
      summary: Update a requirement
      operationId: updateRequirement
      parameters:
        - name: challengeId
          in: path
          description: The Challenge Id
          type: integer
          format: int64
          required: true
        - name: requirementId
          in: path
          type: integer
          format: int64
          required: true
          description: The Id of the requirement
        - name: body
          in: body
          required: true
          schema:
            $ref: '#/definitions/RequirementResource'
      responses:
        "200":
          description: Success
          schema:
            $ref: '#/definitions/ActionResponse'
        default:
          description: Error
          schema:
            $ref: '#/definitions/ErrorResponse'
    delete:
      tags:
        - challenges
        - requirements
      x-swagger-router-controller: requirements
      description: Delete a requirement
      summary: Delete a requirement
      operationId: deleteRequirements
      parameters:
        - name: challengeId
          in: path
          description: The Challenge Id
          type: integer
          format: int64
          required: true
        - name: requirementId
          in: path
          type: integer
          format: int64
          required: true
          description: The Id of the requirement
      responses:
        "200":
          description: Success
          schema:
            $ref: '#/definitions/ActionResponse'
        default:
          description: Error
          schema:
            $ref: '#/definitions/ErrorResponse'
  /challenges/{challengeId}/scorecards:
    post:
      tags:
        - challenges
        - scorecards
      description: Creates a new scorecard
      summary: Creates a new scorecard
      x-swagger-router-controller: scorecards
      operationId: createScorecard
      parameters:
        - name: challengeId
          in: path
          description: the id for the challenge to create a scorecard for
          type: integer
          format: int64
          required: true
        - name: body
          in: body
          description:  body of post
          required: true
          schema:
            $ref: '#/definitions/ScorecardResource'
      responses:
        "200":
          description: Success
          schema:
            $ref: '#/definitions/ActionResponse'
        default:
          description: Error
          schema:
            $ref: '#/definitions/ErrorResponse'
    get:
      tags:
        - challenges
        - scorecards
      description: Get all the scorecards for a particular challenge
      summary: Get all the scorecards for a particular challenge
      x-swagger-router-controller: scorecards
      operationId: getAllScorecardsByChallengeId
      parameters:
        - name: challengeId
          in: path
          required: true
          type: integer
          format: int64
        - name: fields
          in: query
          type: string
          description: partial fields that need to be response. Support (1) comma-separated field list and (2) a/b nested selection.
        - name: filter
          in: query
          type: string
          description: "{fieldName1}={fieldValue1}&...{fieldNameN}>{fieldValueN}. String value needs to be surrounded by single quotation(‘). fieldValue can contain multiple values using in() format {fieldName}=in({fieldValue1},{fieldValue1}). Operations can be =, > or <.  < and > operations are only for number, integers and dates"
      responses:
        "200":
          description: Array of scorecard resources
          schema:
            $ref: '#/definitions/ScoreCardsResponse'
        default:
          description: Error
          schema:
            $ref: '#/definitions/ErrorResponse'
  /challenges/{challengeId}/scorecards/{scorecardId}:
    get:
      tags:
        - challenges
        - scorecards
      x-swagger-router-controller: scorecards
      description: Get a scorecard
      summary: Get a scorecard
      operationId: getScorecardbyId
      parameters:
        - name: challengeId
          in: path
          required: true
          type: integer
          format: int64
        - name: scorecardId
          type: integer
          format: int64
          in: path
          required: true
        - name: fields
          in: query
          type: string
          description: partial fields that need to be response. Support (1) comma-separated field list and (2) a/b nested selection.
      responses:
        "200":
          description: A scorecard
          schema:
            $ref: '#/definitions/ScorecardResponse'
        default:
          description: Error
          schema:
            $ref: '#/definitions/ErrorResponse'
    delete:
      tags:
        - challenges
        - scorecards
      x-swagger-router-controller: scorecards
      description: Delete a scorecard
      summary: Delete a scorecard
      operationId: deleteScorecard
      parameters:
        - name: challengeId
          in: path
          required: true
          type: integer
          format: int64
        - name: scorecardId
          type: integer
          format: int64
          in: path
          required: true
      responses:
        "200":
          description: Success, Id of scorecard delete
          schema:
            $ref: '#/definitions/ActionResponse'
        default:
          description: Error
          schema:
            $ref: '#/definitions/ErrorResponse'
    put:
      tags:
        - challenges
        - scorecards
      x-swagger-router-controller: scorecards
      description: Update a scorecard
      summary: Update a scorecard
      operationId: updateScorecard
      parameters:
        - name: challengeId
          in: path
          required: true
          type: integer
          format: int64
        - name: scorecardId
          type: integer
          format: int64
          in: path
          required: true
        - name: body
          in: body
          required: true
          schema:
            $ref: '#/definitions/ScorecardResource'
      responses:
        "200":
          description: "Success, Id of scorecard updated"
          schema:
            $ref: '#/definitions/ActionResponse'
        default:
          description: Error
          schema:
            $ref: '#/definitions/ErrorResponse'

  /challenges/{challengeId}/scorecards/{scorecardId}/scorecardItems:
    get:
      tags:
        - challenges
        - scorecards
      x-swagger-router-controller: scorecardItems
      description: Retrieve all scorecard items for a scorecard
      summary: Retrieve all scorecard items for a scorecard
      operationId: getScoreCardItemsByScorecard
      parameters:
        - name: challengeId
          in: path
          required: true
          type: integer
          format: int64
        - name: scorecardId
          in: path
          required: true
          type: integer
          format: int64
        - name: fields
          in: query
          type: string
          description: partial fields that need to be response. Support (1) comma-separated field list and (2) a/b nested selection.
      responses:
        "200":
          description: Array of ScorecardItem resources
          schema:
            $ref: '#/definitions/ScorecardItemsResponse'
        default:
          description: Error
          schema:
            $ref: '#/definitions/ErrorResponse'
    post:
      tags:
        - challenges
        - scorecards
      x-swagger-router-controller: scorecardItems
      description: Generates a scorecard item for each requirement of a challenge
      summary: Generates a scorecard item for each requirement of a challenge
      operationId: createScorecardItem
      parameters:
        - name: challengeId
          in: path
          required: true
          type: integer
          format: int64
        - name: scorecardId
          type: integer
          format: int64
          in: path
          required: true
        - name: body
          in: body
          required: true
          schema:
            $ref: '#/definitions/ScorecardItemResource'
      responses:
        "200":
          description: Success
          schema:
            $ref: '#/definitions/ActionResponse'
        default:
          description: Error
          schema:
            $ref: '#/definitions/ErrorResponse'
  /challenges/{challengeId}/scorecards/{scorecardId}/scorecardItems/{scorecardItemId}:
    get:
      tags:
        - challenges
        - scorecards
      x-swagger-router-controller: scorecardItems
      description: Get a scorecard item
      summary: Get a scorecard item
      operationId: getScorecardItem
      parameters:
        - name: challengeId
          type: integer
          format: int64
          description: "id of challenge"
          in: path
          required: true
        - name: scorecardId
          type: integer
          format: int64
          description: "id of scorecard"
          in: path
          required: true
        - name: scorecardItemId
          type: integer
          format: int64
          description: "id of scorecardItem"
          in: path
          required: true
        - name: fields
          in: query
          type: string
          description: partial fields that need to be response. Support (1) comma-separated field list and (2) a/b nested selection.
      responses:
        "200":
          description: "Success"
          schema:
            $ref: '#/definitions/ScorecardItemResponse'
        default:
          description: Error
          schema:
            $ref: '#/definitions/ErrorResponse'
    put:
      tags:
        - challenges
        - scorecards
      x-swagger-router-controller: scorecardItems
      description: Update a scorecard item
      summary: Update a scorecard item
      operationId: updateScorecardItem
      parameters:
        - name: challengeId
          type: integer
          format: int64
          description: "id of challenge"
          in: path
          required: true
        - name: scorecardId
          type: integer
          format: int64
          description: "id of scorecard"
          in: path
          required: true
        - name: scorecardItemId
          in: path
          required: true
          type: integer
          format: int64
        - name: body
          in: body
          required: true
          schema:
            $ref: '#/definitions/ScorecardItemResource'
      responses:
        "200":
          description: "Success, scorecard item update id"
          schema:
            $ref: '#/definitions/ActionResponse'
        default:
          description: Error
          schema:
            $ref: '#/definitions/ErrorResponse'
    delete:
      tags:
        - challenges
        - scorecards
      x-swagger-router-controller: scorecardItems
      description: Delete a scorecard item deleted
      summary: Delete a scorecard item deleted
      operationId: deleteScorecardItem
      parameters:
        - name: challengeId
          type: integer
          format: int64
          description: "id of challenge"
          in: path
          required: true
        - name: scorecardId
          type: integer
          format: int64
          description: "id of scorecard"
          in: path
          required: true
        - name: scorecardItemId
          type: integer
          format: int64
          in: path
          required: true
      responses:
        "200":
          description: "Success, Id of scorecard item"
          schema:
            $ref: '#/definitions/ActionResponse'
        default:
          description: Error
          schema:
            $ref: '#/definitions/ErrorResponse'
  /challenges/{challengeId}/files/{fileId}/download:
    get:
      tags:
        - challenges
        - files
      x-swagger-router-controller: storage
      description: Get the download URL for a challenge file
      summary: Get challenge file download URL
      operationId: getChallengeFileDownloadURL
      parameters:
        - name: challengeId
          type: integer
          format: int64
          description: "id of challenge"
          in: path
          required: true
        - name: fileId
          type: integer
          format: int64
          description: "id of file"
          in: path
          required: true
      responses:
        "200":
          description: "Success"
          schema:
            $ref: '#/definitions/FileActionResponse'
        default:
          description: Error
          schema:
            $ref: '#/definitions/ErrorResponse'
  /challenges/{challengeId}/files/{fileId}/upload:
    get:
      tags:
        - challenges
        - files
      x-swagger-router-controller: storage
      description: Get the upload URL to  upload a file for a challenge
      summary: Get challenge file upload URL
      operationId: getChallengeFileUploadURL
      parameters:
        - name: challengeId
          type: integer
          format: int64
          description: "id of challenge"
          in: path
          required: true
        - name: fileId
          type: integer
          format: int64
          description: "id of file"
          in: path
          required: true
      responses:
        "200":
          description: "Success"
          schema:
            $ref: '#/definitions/FileActionResponse'
        default:
          description: Error
          schema:
            $ref: '#/definitions/ErrorResponse'
  /challenges/{challengeId}/submissions/{submissionId}/files/{fileId}/download:
    get:
      tags:
        - challenges
        - submissions
        - files
      x-swagger-router-controller: storage
      description: Get the download URL for a submitted file
      summary: Get submitted file download URL
      operationId: getSubmissionFileDownloadURL
      parameters:
        - name: challengeId
          type: integer
          format: int64
          description: "id of challenge"
          in: path
          required: true
        - name: submissionId
          type: integer
          format: int64
          description: "id of submission"
          in: path
          required: true
        - name: fileId
          type: integer
          format: int64
          description: "id of file"
          in: path
          required: true
      responses:
        "200":
          description: "Success"
          schema:
            $ref: '#/definitions/FileActionResponse'
        default:
          description: Error
          schema:
            $ref: '#/definitions/ErrorResponse'
  /challenges/{challengeId}/submissions/{submissionId}/files/{fileId}/upload:
    get:
      tags:
        - challenges
        - submissions
        - files
      x-swagger-router-controller: storage
      description: Get the upload URL to  upload a file for a submission
      summary: Get submission file upload URL
      operationId: getSubmissionFileUploadURL
      parameters:
        - name: challengeId
          type: integer
          format: int64
          description: "id of challenge"
          in: path
          required: true
        - name: submissionId
          type: integer
          format: int64
          description: "id of submission"
          in: path
          required: true
        - name: fileId
          type: integer
          format: int64
          description: "id of file"
          in: path
          required: true
      responses:
        "200":
          description: "Success"
          schema:
            $ref: '#/definitions/FileActionResponse'
        default:
          description: Error
          schema:
            $ref: '#/definitions/ErrorResponse'
# Custom Responses
definitions:
  ChallengeResource:
    required:
      - title
      - status
      - projectSource
    properties:
      id:
        type: integer
        format: int64
        description: postgres primary key
      regStartAt:
        type: string
        format: date-time
        description: the start Date of the challenge
      subEndAt:
        type: string
        format: date-time
        description: last time a member can submit.
      completedAt:
        type: string
        format: date-time
        description: The closing date of the challenge.
      title:
        type: string
        description: Title of the challenge.
        default: Untitled Challenge
        minLength: 1
      overview:
        type: string
        description: 140 Char overview
        maxLength: 140
      description:
        type: string
        description: the body of the challenge
      tags:
        type: array
        items:
          type: string
      status:
        type: string
        description: The current status of the challenge
        enum:
          - DRAFT
          - SUBMISSION
          - REVIEW
          - COMPLETE
      prizes:
        description: The prizes to be awarded for this challenge.
        type: array
        items:
          type: number
      source:
        type: string
        description: Used for integraiton with remote system
      sourceId:
        type: string
        description: Used for integratino with remote systems
      creatorHandle:
        type: string
        description: challenge creator's handle
      creatorId:
        type: number
        description: challenge creator's id
      createdAt:
        type: string
        format: date-time
      updatedAt:
        type: string
        format: date-time
      createdBy:
        type: number
        description: The id of the user who created the row
      updatedBy:
        type: number
        description: The id of the user last updated the row
      projectId:
        type: string
        description: The id of the project.
        maxLength: 255
      projectSource:
        type: string
        description: Source of the project
        enum:
          - TOPCODER

  ResultResource:
    required:
      - scorecardId
    properties:
      id:
        type: integer
        format: int64
      scorecardId:
        type: integer
        format: int64
      pay:
        type: boolean
        description: "determines if scorecard merits awarding place and cash prize"
      place:
        type: integer
        format: int32
        minimum: 1
        maximum: 6
        description: "TODO: results instead? awarded place, 1 for 1st, 2 for second ..."
      prize:
        type: number
        format: double
        description: "cash payout"
      createdAt:
        type: string
        format: date-time
      updatedAt:
        type: string
        format: date-time
      createdBy:
        type: number
        description: The id of the user who created the row
      updatedBy:
        type: number
        description: The id of the user last updated the row
  ScorecardResource:
    required:
      - reviewerId
      - submissionId
      - status
    properties:
      id:
        type: integer
        format: int64
      reviewerId:
        type: integer
        format: int64
        description: "the user id of the reviewer"
      reviewerHandle:
        type: string
        description: "the user handle of the reviewer"
      submissionId:
        type: integer
        format: int64
        description: "id of the submission"
      scoreSum:
        type: integer
        description: "This is a derived value and may only be a placeholder -TBD-. Sum of all the scorecard items scorecard"
      scorePercent:
        type: number
        format: float
        description: "This is a derived value and may only be a placeholder -TBD-. ScoreSum / ScoreMax from scorecard items"
      scoreMax:
        type: number
        format: float
        description: "This is a derived value and may only be a placeholder -TBD-. Sum of highest possible score from scorecard items"
      status:
        type: string
        enum:
          - NEW
          - SAVED
          - SUBMITTED
        description: "show if this scorecard is valid ENUM:NEW,SAVED,SUBMITTED"
      # TODO: should next three be here or should we do a result object
      pay:
        type: boolean
        description: "determines if scorecard merits awarding place and cash prize"
      place:
        type: integer
        description: "TODO: results instead? awarded place, 1 for 1st, 2 for second ..."
      prize:
        type: number
        format: float
        description: "cash payout"
      createdAt:
        type: string
        format: date-time
      updatedAt:
        type: string
        format: date-time
      createdBy:
        type: number
        description: The id of the user
      updatedBy:
        type: number
        description: The id of the user
  ScorecardItemResource:
    required:
      - requirementId
    properties:
      id:
        type: integer
        format: int64
        description: postgres primary key
      requirementId:
        type: integer
        format: int64
        description: The requirement id
      score:
        type: number
        format: float
        description: "stores the reviewers assigned score for this req"
      comment:
        type: string
        description: "text from reviewer to submitter"
      createdAt:
        type: string
        format: date-time
      updateAt:
        type: string
        format: date-time
      createdBy:
        type: number
        description: The id of the user
      updatedBy:
        type: number
        description: The id of the user
  FileResource:
    properties:
      id:
        type: integer
        format: int64
        description: postgres primary key
      title:
        description:  The display value for the file
        type: string
      filePath:
        description:  Where the file is stored
        type: string
      size:
        description: Size of the file
        type: integer
        format: int64
      fileName:
        description: The name of the file
        type: string
      storageLocation:
        description: How the file is stored.  How the app loads the file.
        type: string
      fileUrl:
        description: Url of file.
        type: string
      createdAt:
        type: string
        format: date-time
      updatedAt:
        type: string
        format: date-time
      createdBy:
        type: number
        description: The id of the user who created the row
      updatedBy:
        type: number
        description: The id of the user last updated the row
    required:
      - fileUrl
      - size
      - storageLocation
  FileActionResource:
    properties:
      url:
        type: string
        description: The URL to preform the action against
    required:
      - url
  ParticipantResource:
    properties:
      id:
        type: integer
        format: int64
        description: postgres primary key
      userId:
        type: integer
        format: int64
        description: The user id.
      userHandle:
        type: string
        description: The user handle.
      role:
        type: string
        description: The role the participant has on the challenge
        enum:
          - OWNER
          - SUBMITTER
          - WATCHER
          - REVIEWER
      createdAt:
        type: string
        format: date-time
      updatedAt:
        type: string
        format: date-time
      createdBy:
        type: number
        description: The id of the user who created the row
      updatedBy:
        type: number
        description: The id of the user last updated the row
    required:
      - userId
      - role
  SubmissionResource:
    required:
      - submitterId
      - status
    properties:
      id:
        type: integer
        format: int64
        description: postgres primary key
      submitterId:
        type: integer
        format: int64
        description: The user_id of the submitter
      submitterHandle:
        type: string
        description: "the user handle of the submitter"
      status:
        type: string
        description: The current status of the submission
        enum:
          - VALID
          - INVALID
          - LATE
      createdAt:
        type: string
        format: date-time
      updatedAt:
        type: string
        format: date-time
      createdBy:
        type: number
        description: The id of the user who created the row
      updatedBy:
        type: number
        description: The id of the user last updated the row
  RequirementResource:
    properties:
      Id:
        type: integer
        format: int64
        description: postgres primary key
      requirementText:
        type: string
        description: The requirement
  ChallengesResponse:
    required:
      - success
      - status
      - content
    properties:
      success:
        type: boolean
        description: Was the request a success
      status:
        type: integer
        format: int32
        description: The http status code
      metadata:
        $ref: '#/definitions/MetadataListResponse'
      content:
        type: array
        items:
          $ref: '#/definitions/ChallengeResource'
          minItems: 0
          uniqueItems: true
  ChallengeResponse:
    required:
      - success
      - status
      - content
    properties:
      success:
        type: boolean
        description: Was the request a success
      status:
        type: integer
        format: int32
        description: The http status code
      metadata:
        $ref: '#/definitions/MetadataListResponse'
      content:
        $ref: '#/definitions/ChallengeResource'
  FileActionResponse:
    required:
      - success
      - status
      - content
    properties:
      success:
        type: boolean
        description: Was the request a success
      status:
        type: integer
        format: int32
        description: The http status code
      metadata:
        $ref: '#/definitions/MetadataListResponse'
      content:
        $ref: '#/definitions/FileActionResource'
  FileResponse:
    required:
      - success
      - status
      - content
    properties:
      success:
        type: boolean
        description: Was the request a success
      status:
        type: integer
        format: int32
        description: The http status code
      metadata:
        $ref: '#/definitions/MetadataListResponse'
      content:
        $ref: '#/definitions/FileResource'
  FilesResponse:
    required:
      - success
      - status
      - content
    properties:
      success:
        type: boolean
        description: Was the request a success
      status:
        type: integer
        format: int32
        description: The http status code
      metadata:
        $ref: '#/definitions/MetadataListResponse'
      content:
        type: array
        items:
          $ref: '#/definitions/FileResource'
          minItems: 0
          uniqueItems: true
  ChallengeParticipantsResponse:
    required:
      - success
      - status
      - content
    properties:
      success:
        type: boolean
        description: Was the request a success
      status:
        type: integer
        format: int32
        description: The http status code
      metadata:
        $ref: '#/definitions/MetadataListResponse'
      content:
        type: array
        items:
          $ref: '#/definitions/ParticipantResource'
          minItems: 0
          uniqueItems: true
  ChallengeParticipantResponse:
    required:
      - success
      - status
      - content
    properties:
      success:
        type: boolean
        description: Was the request a success
      status:
        type: integer
        format: int32
        description: The http status code
      metadata:
        $ref: '#/definitions/MetadataListResponse'
      content:
          $ref: '#/definitions/ParticipantResource'
  ChallengeSubmissionsResponse:
    required:
      - success
      - status
      - content
    properties:
      success:
        type: boolean
        description: Was the request a success
      status:
        type: integer
        format: int32
        description: The http status code
      metadata:
        $ref: '#/definitions/MetadataListResponse'
      content:
        type: array
        items:
          $ref: '#/definitions/SubmissionResource'
          minItems: 0
          uniqueItems: true
  ChallengeSubmissionResponse:
    required:
      - success
      - status
      - content
    properties:
      success:
        type: boolean
        description: Was the request a success
      status:
        type: integer
        format: int32
        description: The http status code
      metadata:
        $ref: '#/definitions/MetadataListResponse'
      content:
          $ref: '#/definitions/SubmissionResource'
  ScoreCardsResponse:
    required:
      - success
      - status
      - content
    properties:
      success:
        type: boolean
        description: Was the request a success
      status:
        type: integer
        format: int32
        description: The http status code
      metadata:
        $ref: '#/definitions/MetadataListResponse'
      content:
        type: array
        items:
          $ref: '#/definitions/ScorecardResource'
          minItems: 0
          uniqueItems: true
  ScorecardResponse:
    required:
      - success
      - status
      - content
    properties:
      success:
        type: boolean
        description: Was the request a success
      status:
        type: integer
        format: int32
        description: The http status code
      metadata:
        $ref: '#/definitions/MetadataListResponse'
      content:
        $ref: '#/definitions/ScorecardResource'
  ScorecardItemsResponse:
    required:
      - success
      - status
      - content
    properties:
      success:
        type: boolean
        description: Was the request a success
      status:
        type: integer
        format: int32
        description: The http status code
      metadata:
        $ref: '#/definitions/MetadataListResponse'
      content:
        type: array
        items:
          $ref: '#/definitions/ScorecardItemResource'
          minItems: 0
          uniqueItems: true
  ScorecardItemResponse:
    required:
      - success
      - status
      - content
    properties:
      success:
        type: boolean
        description: Was the request a success
      status:
        type: integer
        format: int32
        description: The http status code
      metadata:
        $ref: '#/definitions/MetadataListResponse'
      content:
        $ref: '#/definitions/ScorecardItemResource'
  ResultsResponse:
    properties:
      success:
        type: boolean
        description: Was the request a success
      status:
        type: integer
        format: int32
        description: The http status code
      metadata:
        $ref: '#/definitions/MetadataListResponse'
      content:
        type: array
        items:
          $ref: '#/definitions/ResultResource'
          minItems: 0
          uniqueItems: true
  RequirementResponse:
    required:
      - success
      - status
      - content
    properties:
      success:
        type: boolean
        description: Was the request a success
      status:
        type: integer
        format: int32
        description: The http status code
      metadata:
        $ref: '#/definitions/MetadataListResponse'
      content:
        $ref: '#/definitions/RequirementResource'
  RequirementsResponse:
    required:
      - success
      - status
      - content
    properties:
      success:
        type: boolean
        description: Was the request a success
      status:
        type: integer
        format: int32
        description: The http status code
      metadata:
        $ref: '#/definitions/MetadataListResponse'
      content:
        type: array
        items:
          $ref: '#/definitions/RequirementResource'
          minItems: 0
          uniqueItems: true
  ActionResponse:
    required:
      - id
    properties:
      id:
        type: integer
        format: int64
        description:  The ID that was created for a new object.  Otherwise the id of the affected object
      result:
        properties:
          success:
            type: boolean
            description: Was the request a success
          status:
            type: integer
            format: int32
            description: The http status code
  MetadataListResponse:
    properties:
      totalCount:
        type: integer
        format: int32
  ErrorResponse:
    properties:
      result:
        properties:
          success:
            type: boolean
            description: Was the request a success.  Should be false
          status:
            type: integer
            format: int32
            description: The http status code
      content:
        type: string
        description: The error message