Validating OpenAPI documents usually requires server-side tools. I built one that runs purely in the browser.
Try it: https://devnestio.pages.dev/openapi-validator/
Supports
- OpenAPI 3.0 / 3.1 (JSON or YAML)
- Swagger 2.0 (JSON or YAML)
What it checks
- Required root fields (
openapi/swagger,info,paths) -
info.titleandinfo.versionpresent - All paths start with
/ - Every operation has a
responsesblock - Duplicate
operationIdvalues - Valid HTTP status codes
- Server entries have
url - Schema definitions have a
typeor composition keyword
function validateV3(doc) {
required(doc, ["openapi", "info", "paths"], "#");
const operationIds = new Set();
for (const [path, item] of Object.entries(doc.paths || {})) {
for (const method of ["get","post","put","delete","patch"]) {
const op = item[method];
if (!op) continue;
if (!op.responses) addIssue("error", path+"/"+method, "Missing responses", "");
if (op.operationId) {
if (operationIds.has(op.operationId)) addIssue("error", path, "Duplicate operationId", op.operationId);
else operationIds.add(op.operationId);
}
}
}
}
DevNestio — browser-only developer tools.
Top comments (0)