openapi: 3.0.1
info:
  description: >-
    The “Solver” functionality provides a powerful way to determine what
    parameter changes are needed to achieve a specific target goal. The Solver
    API is designed to "solve" for a goal by adjusting a single entity (a
    parameter) to meet a user-defined target achievability.
     <br/>The process involves two main API calls:<ol><li>
     <a href="/scenarios/solve-scenario">Solve</a> a Scenario Goal</li>
     <li><a href="/solver/get">Get</a> the Solution</li></ol>
  title: Solver
  version: '1.0'
servers:
  - url: https://api.envizage.me
paths:
  /results/{scenarioId}/sovler/{solutionId}:
    get:
      description: >-
        Get the solution and the new achievability from the scenario's <a
        href='/scenarios/solve-scenario'>solve</a> API call.
      operationId: get
      parameters:
        - description: The solution id from the the scenario's solve API call.
          in: path
          name: solutionId
          required: true
          schema:
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SolutionDto'
          description: OK
        '500':
          description: Internal Server Error
      security:
        - authentication:
            - scenarios:full
            - scenarios:read
      summary: Solver results
      tags:
        - Get solution
components:
  schemas:
    resultData:
      type: object
      properties:
        goalId:
          type: string
        data:
          type: object
          properties:
            metadata:
              type: object
              properties:
                numberOfLives:
                  type: integer
              additionalProperties:
                type: number
                description: \*property name can be anything
            goalName:
              type: string
            totalAchieved:
              type: integer
            eitherAlive:
              type: integer
    goalData:
      type: object
      properties:
        goalId:
          type: string
        data:
          type: object
          properties:
            eitherAlive:
              type: integer
    ObjectA:
      type: object
      properties:
        name:
          type: string
        results:
          type: array
          items:
            $ref: '#/components/schemas/resultData'
    ObjectB:
      type: object
      properties:
        name:
          type: string
        results:
          type: array
          items:
            $ref: '#/components/schemas/goalData'
    solutionResults:
      type: object
      properties:
        - $ref: '#/components/schemas/ObjectA'
        - $ref: '#/components/schemas/ObjectB'
    SolutionDto:
      type: object
      properties:
        id:
          type: string
        scenarioId:
          type: string
        simulationId:
          type: string
        clientId:
          type: string
        username:
          type: string
        results:
          type: array
          items:
            $ref: '#/components/schemas/solutionResults'
        goalId:
          type: string
        diagnosticType:
          type: string
        solutionId:
          type: string
      required:
        - id
        - scenarioId
        - simulationId
        - clientId
        - username
        - goalId
        - diagnosticType
  securitySchemes:
    authentication:
      bearerFormat: JWT
      openIdConnectUrl: https://id.envizage.me/realms/:realmId/protocol/openid-connect
      scheme: Bearer
      type: openIdConnect
