openapi: 3.0.4
info:
  title: CrowdProj
  description: An experimental project with high modularity
  contact:
    name: Sergey Okatov
    email: sokatov@gmail.com
  license:
    name: Apache 2.0
    url: 'https://www.apache.org/licenses/LICENSE-2.0.html'
  version: 1.0.0

paths: {}

components:
  schemas:

    RequestId:
      type: string
      description: A unique request identificator for for the request trace purposes

    UserId:
      type: string
      description: A user unique identificator

    CpRequestDebug:
      type: object
      description: Debug property for request description
      properties:
        debug:
          $ref: '#/components/schemas/CpBaseDebug'

    CpBaseDebug:
      type: object
      description: A basic structure describing debug settings
      properties:
        mode:
          $ref: '#/components/schemas/CpRequestDebugMode'
        stub:
          $ref: '#/components/schemas/CpRequestDebugStubs'

    CpRequestDebugMode:
      type: string
      description: 'Debug modes: prod - production functioning, test - a test (in-memory) database usage, stub - fixed stubs response'
      enum:
        - prod
        - test
        - stub

    CpRequestDebugStubs:
      type: string
      description: List here all stubs available to clients
      enum:
        - success
        - notFound
        - badId

    Error:
      type: object
      description: Common description of an error
      properties:
        code:
          type: string
          description: "Some specific code to identify an error for programming handling purposes"
        group:
          type: string
          description: "An optional group id to segment different errors"
        field:
          type: string
          description: "An optional field the error relates to"
        title:
          type: string
          description: A short explanation of the error to show as a tooltip or hint, for example
        description:
          type: string
          description: A full description of the error with a complete information

    ResponseResult:
      type: string
      description: 'Response statuses. Has two options: success and error'
      enum:
        - success
        - error

    IRequest:
      type: object
      description: Basic interface for all requests
      properties:
        requestType:
          type: string
          description: Discriminator for all requests
          example: create
      discriminator:
        propertyName: requestType

    IResponse:
      type: object
      description: Basic interface for all responses
      properties:
        responseType:
          type: string
          description: Discriminator for all responses
          example: create
        requestId:
          $ref: '#/components/schemas/RequestId'
        result:
          $ref: '#/components/schemas/ResponseResult'
        errors:
          type: array
          items:
            $ref: '#/components/schemas/Error'
