{
  "openapi": "3.0.0",
  "info": {
    "title": "Gmd CsCommon Example API",
    "description": "Demonstrates features and coding structure for the Gmd.CsCommon libraries.",
    "version": "0.0.1"
  },
  "servers": [
    {
      "url": "/v1"
    }
  ],
  "paths": {
    "/health": {
      "head": {
        "tags": [
          "Health"
        ],
        "summary": "Check accessibility of the endpoint",
        "operationId": "headHealth",
        "responses": {
          "204": {
            "description": "Endpoint is accessible."
          }
        }
      },
      "get": {
        "tags": [
          "Health"
        ],
        "summary": "Retrieve health status",
        "operationId": "getHealth",
        "responses": {
          "200": {
            "description": "Health status response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Health"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Health": {
        "type": "object",
        "description": "Overall health status of the application",
        "additionalProperties": false,
        "properties": {
          "status": {
            "type": "string",
            "description": "Overall health status of the application",
            "example": "healthy",
            "enum": [
              "healthy",
              "degraded",
              "unhealthy"
            ]
          },
          "general": {
            "type": "object",
            "description": "General application information",
            "properties": {
              "appVersion": {
                "type": "string",
                "description": "Application version in semver2 format",
                "pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(-(0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(\\.(0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*)?(\\+[0-9a-zA-Z-]+(\\.[0-9a-zA-Z-]+)*)?$",
                "example": "1.0.0"
              },
              "uptime": {
                "type": "string",
                "description": "Uptime in C# time-span format",
                "format": "time-span",
                "pattern": "^\\d+\\.\\d\\d:\\d\\d:\\d\\d$",
                "example": "1.00:00:00"
              },
              "appStartTime": {
                "type": "string",
                "description": "The time the API application was started",
                "format": "date-time",
                "nullable": true
              }
            }
          },
          "services": {
            "description": "Health status of all services and dependencies",
            "$ref": "#/components/schemas/Services"
          }
        }
      },
      "Services": {
        "type": "object",
        "description": "Health status of all services and dependencies",
        "additionalProperties": false,
        "properties": {
          "database": {
            "type": "object",
            "description": "Database connection and health information",
            "properties": {
              "status": {
                "type": "string",
                "description": "Database connection status",
                "example": "online",
                "enum": [
                  "online",
                  "offline"
                ]
              },
              "responseTime": {
                "type": "string",
                "readOnly": true,
                "description": "The current response time from the database in a valid .net `[TimeSpan]` format.",
                "format": "time-span",
                "pattern": "^\\d+\\.\\d\\d:\\d\\d:\\d\\d$",
                "nullable": true,
                "example": "0.00:00:03"
              },
              "version": {
                "type": "string",
                "readOnly": true,
                "description": "The version of the database",
                "nullable": true
              },
              "providerName": {
                "type": "string",
                "readOnly": true,
                "description": "The provider/type of the database",
                "nullable": true
              },
              "lastQueried": {
                "type": "string",
                "description": "The last time a query was executed on the database",
                "format": "date-time",
                "example": "2022-01-01T00:00:00Z"
              }
            }
          }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "description": "Detailed information about an API error, including an error code, message, and validation errors.",
        "required": [
          "errorCode",
          "message"
        ],
        "properties": {
          "errorCode": {
            "$ref": "#/components/schemas/ErrorCode"
          },
          "message": {
            "type": "string",
            "description": "A human-readable message describing the error.",
            "example": "There are validation errors in your request."
          },
          "modelErrors": {
            "type": "array",
            "description": "A collection of validation errors, where each entry identifies a field and its associated errors.",
            "items": {
              "$ref": "#/components/schemas/ErrorResponseModelError"
            }
          }
        }
      },
      "ErrorResponseModelError": {
        "type": "object",
        "description": "Details of a validation error for a specific field in the request model.",
        "properties": {
          "field": {
            "type": "string",
            "description": "The name of the field that has validation errors.",
            "example": "email"
          },
          "errors": {
            "type": "array",
            "description": "A list of validation error messages related to the field.",
            "example": [
              "Invalid email format.",
              "Email domain is not allowed.",
              "Email cannot be empty."
            ],
            "items": {
              "type": "string"
            }
          }
        }
      },
      "ErrorCode": {
        "type": "string",
        "description": "Enum for error codes used across API responses to categorize and identify specific error conditions.",
        "enum": [
          "generalError"
        ]
      }
    }
  },
  "tags": [
    {
      "name": "Health",
      "description": "Health check for the web api",
      "externalDocs": {
        "description": "Find out more",
        "url": "https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/health-checks?view=aspnetcore-8.0"
      }
    },
    {
      "name": "Users",
      "description": "Operations related to users"
    },
    {
      "name": "UserFavoriteQuotes",
      "description": "Operations related to user favorite quotes"
    }
  ]
}