{
  "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": "/v2"
    }
  ],
  "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"
                }
              }
            }
          }
        }
      }
    },
    "/users": {
      "get": {
        "tags": [
          "Users"
        ],
        "summary": "Retrieve users",
        "operationId": "getUsers",
        "responses": {
          "200": {
            "description": "List of users",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/User"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/users/{userId}": {
      "get": {
        "tags": [
          "Users"
        ],
        "summary": "Get user by ID",
        "operationId": "getUserById",
        "parameters": [
          {
            "name": "userId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "User details",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/User"
                }
              }
            }
          },
          "404": {
            "description": "User does not exist.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/users/{userId}/favorite-quotes": {
      "get": {
        "tags": [
          "UserFavoriteQuotes"
        ],
        "summary": "Retrieve favorite quotes for a user",
        "operationId": "getUserFavoriteQuotes",
        "parameters": [
          {
            "name": "userId",
            "in": "path",
            "required": true,
            "description": "The unique identifier of the user whose favorite quotes should be retrieved.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "List of favorite quotes for the specified user.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/UserFavoriteQuote"
                  }
                }
              }
            }
          },
          "404": {
            "description": "User not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/users/{userId}/favorite-quotes/{quoteId}": {
      "get": {
        "tags": [
          "UserFavoriteQuotes"
        ],
        "summary": "Retrieve a specific favorite quote for a user",
        "operationId": "getFavoriteQuoteByUser",
        "parameters": [
          {
            "name": "userId",
            "in": "path",
            "required": true,
            "description": "The unique identifier of the user who has this favorite quote.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "quoteId",
            "in": "path",
            "required": true,
            "description": "The unique identifier of the favorite quote.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Favorite quote details for the specified user.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UserFavoriteQuote"
                }
              }
            }
          },
          "404": {
            "description": "Favorite quote or user not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "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",
        "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 responses.",
        "enum": [
          "generalError",
          "userNotFound",
          "quoteNotFound"
        ]
      },
      "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",
        "additionalProperties": false,
        "properties": {
          "database": {
            "$ref": "#/components/schemas/Database"
          }
        }
      },
      "Database": {
        "type": "object",
        "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": "3.23:05:21"
          },
          "version": {
            "type": "string",
            "readOnly": true,
            "description": "The version of the database.",
            "nullable": true
          },
          "providerName": {
            "type": "string",
            "readOnly": true,
            "description": "The provider 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"
          }
        }
      },
      "User": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string",
            "description": "Unique identifier for the user.",
            "example": "abc-123"
          },
          "firstName": {
            "type": "string",
            "description": "User's first name.",
            "example": "John"
          },
          "lastName": {
            "type": "string",
            "description": "User's last name.",
            "example": "Doe"
          },
          "dateOfBirth": {
            "type": "string",
            "description": "Date of birth of the user.",
            "format": "date",
            "example": "1990-05-15"
          },
          "created": {
            "type": "string",
            "description": "Timestamp indicating when the user account was created.",
            "format": "date-time",
            "example": "2024-01-20T12:45:30Z"
          },
          "_links": {
            "$ref": "#/components/schemas/UserLinks"
          }
        }
      },
      "UserFavoriteQuote": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string",
            "description": "Unique identifier for the favorite quote.",
            "example": "abc-123"
          },
          "text": {
            "type": "string",
            "description": "The actual quote text.",
            "example": "Success is not final; failure is not fatal: It is the courage to continue that counts."
          },
          "_links": {
            "$ref": "#/components/schemas/UserFavoriteQuoteLinks"
          }
        }
      },
      "UserFavoriteQuoteLinks": {
        "type": "object",
        "description": "Hypermedia links for related resources.",
        "additionalProperties": false,
        "properties": {
          "self": {
            "type": "string",
            "description": "URL to this quote resource.",
            "example": "/users/abc-123/favorite-quotes/abc-456"
          },
          "user": {
            "type": "string",
            "description": "URL to the user having this quote.",
            "example": "/users/abc-123"
          },
          "userFavoriteQuotes": {
            "type": "string",
            "description": "URL to other favorite quotes from the same user.",
            "example": "/users/abc-123/favorite-quotes"
          }
        }
      },
      "UserLinks": {
        "type": "object",
        "description": "Hypermedia links for related resources.",
        "additionalProperties": false,
        "properties": {
          "self": {
            "type": "string",
            "description": "URL to this resource.",
            "example": "/users/abc-123"
          },
          "userFavoriteQuotes": {
            "type": "string",
            "description": "URL to retrieve this user's favorite quotes.",
            "example": "/users/abc-123/favorite-quotes"
          }
        }
      }
    }
  },
  "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"
    }
  ]
}