{
  "openapi": "3.1.0",
  "info": {
    "title": "VeriGrade patch-gap API",
    "version": "1.0.0",
    "summary": "How long has an app been sitting on security fixes it never applied?",
    "description": "For each npm package you send, returns its known advisories (OSV.dev), the version that fixes each one, when that version was released (deps.dev), days exposed, whether the flaw is on CISA's Known Exploited Vulnerabilities list, and its EPSS score. Free, no key needed, nothing you send is stored. Results are evidence, not a verdict: whether a flaw matters depends on whether the app reaches the affected code.",
    "contact": {
      "name": "Holdfast",
      "url": "https://holdfastapps.com/tools/patch-gap",
      "email": "rob@holdfastapps.com"
    },
    "license": {
      "name": "MIT (the checking code)",
      "identifier": "MIT"
    }
  },
  "servers": [
    {
      "url": "https://holdfastapps.com"
    }
  ],
  "paths": {
    "/api/v1/patch-gap": {
      "get": {
        "summary": "Usage and limits",
        "responses": {
          "200": {
            "description": "Usage, example and limits"
          }
        }
      },
      "post": {
        "summary": "Check packages or a lockfile",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "object",
                    "required": [
                      "packages"
                    ],
                    "properties": {
                      "packages": {
                        "type": "array",
                        "maxItems": 300,
                        "items": {
                          "type": "object",
                          "required": [
                            "name",
                            "version"
                          ],
                          "properties": {
                            "name": {
                              "type": "string",
                              "example": "next"
                            },
                            "version": {
                              "type": "string",
                              "example": "14.2.3"
                            }
                          }
                        }
                      }
                    }
                  },
                  {
                    "type": "object",
                    "required": [
                      "lockfile"
                    ],
                    "properties": {
                      "lockfile": {
                        "type": "string",
                        "description": "Contents of package-lock.json, pnpm-lock.yaml or yarn.lock. Parsed in memory and discarded."
                      },
                      "filename": {
                        "type": "string",
                        "example": "pnpm-lock.yaml"
                      },
                      "package_json": {
                        "type": "string",
                        "description": "Contents of package.json. Needed for yarn.lock only."
                      },
                      "scope": {
                        "type": "string",
                        "enum": [
                          "direct",
                          "all"
                        ],
                        "default": "direct"
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "today": {
                      "type": "string",
                      "format": "date"
                    },
                    "packages_checked": {
                      "type": "integer"
                    },
                    "packages_vulnerable_not_analysed": {
                      "type": "integer",
                      "description": "Vulnerable packages beyond the per-request limit of 20. Split the request to analyse them."
                    },
                    "summary": {
                      "type": "object",
                      "properties": {
                        "advisories": {
                          "type": "integer"
                        },
                        "with_fix": {
                          "type": "integer"
                        },
                        "no_fix_yet": {
                          "type": "integer"
                        },
                        "worst_days": {
                          "type": [
                            "integer",
                            "null"
                          ]
                        },
                        "median_days": {
                          "type": [
                            "integer",
                            "null"
                          ]
                        },
                        "kev": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "upgrade_to": {
                          "type": "object",
                          "additionalProperties": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "advisories": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "package": {
                            "type": "string"
                          },
                          "version": {
                            "type": "string"
                          },
                          "id": {
                            "type": "string"
                          },
                          "cves": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "fixed_in": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "fix_date": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "format": "date"
                          },
                          "days_exposed": {
                            "type": [
                              "integer",
                              "null"
                            ]
                          },
                          "kev": {
                            "type": "boolean"
                          },
                          "epss": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "url": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          },
          "413": {
            "description": "Body over 512 KB"
          },
          "502": {
            "description": "An upstream data source failed; try again"
          },
          "429": {
            "description": "Too many requests (30 a minute per IP). See the Retry-After header.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
