{
  "swagger": "2.0",
  "info": {
    "title": "Gmd CsCommon Example API",
    "description": "Demonstrates features and coding structure for the Gmd.CsCommon libraries.",
    "version": "0.0.1"
  },
  "host": "",
  "basePath": "/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.",
            "schema": {
              "$ref": "#/definitions/Health"
            }
          }
        }
      }
    },
    "/users": {
      "get": {
        "tags": [
          "Users"
        ],
        "summary": "Retrieve users",
        "operationId": "getUsers",
        "responses": {
          "200": {
            "description": "List of users",
            "schema": {
              "type": "array",
              "items": {
                "$ref": "#/definitions/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",
            "schema": {
              "$ref": "#/definitions/User"
            }
          },
          "404": {
            "description": "User does not exist.",
            "schema": {
              "$ref": "#/definitions/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.",
            "schema": {
              "type": "array",
              "items": {
                "$ref": "#/definitions/UserFavoriteQuote"
              }
            }
          },
          "404": {
            "description": "User not found.",
            "schema": {
              "$ref": "#/definitions/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.",
            "schema": {
              "$ref": "#/definitions/UserFavoriteQuote"
            }
          },
          "404": {
            "description": "Favorite quote or user not found.",
            "schema": {
              "$ref": "#/definitions/ErrorResponse"
            }
          }
        }
      }
    }
  },
  "definitions": {
    "ErrorResponse": {
      "type": "object",
      "description": "Detailed information about an API error, including an error code, message, and validation errors.",
      "additionalProperties": {},
      "required": [
        "errorCode",
        "message"
      ],
      "properties": {
        "errorCode": {
          "$ref": "#/definitions/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": "#/definitions/ErrorResponseModelError"
          }
        }
      }
    },
    "ErrorResponseModelError": {
      "type": "object",
      "additionalProperties": {},
      "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",
      "properties": {
        "status": {
          "type": "string",
          "description": "Overall health status of the application",
          "example": "healthy",
          "enum": [
            "healthy",
            "degraded",
            "unhealthy"
          ]
        },
        "general": {
          "type": "object",
          "description": "General application information",
          "additionalProperties": {},
          "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",
              "x-nullable": true
            }
          }
        },
        "services": {
          "description": "Health status of all services and dependencies",
          "$ref": "#/definitions/Services"
        }
      }
    },
    "Services": {
      "type": "object",
      "properties": {
        "database": {
          "$ref": "#/definitions/Database"
        }
      }
    },
    "Database": {
      "type": "object",
      "additionalProperties": {},
      "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",
          "x-nullable": true,
          "example": "3.23:05:21"
        },
        "version": {
          "type": "string",
          "readOnly": true,
          "description": "The version of the database.",
          "x-nullable": true
        },
        "providerName": {
          "type": "string",
          "readOnly": true,
          "description": "The provider of the database.",
          "x-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",
      "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": "#/definitions/UserLinks"
        }
      }
    },
    "UserFavoriteQuote": {
      "type": "object",
      "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": "#/definitions/UserFavoriteQuoteLinks"
        }
      }
    },
    "UserFavoriteQuoteLinks": {
      "type": "object",
      "description": "Hypermedia links for related resources.",
      "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.",
      "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"
    }
  ]
}