OpenAPI / Swagger Validator
DataValidate an OpenAPI 3.x or Swagger 2.0 specification for required fields and structural correctness. Paste JSON or YAML. Free, client-side, no data uploaded.
What is a OpenAPI?
The OpenAPI / Swagger Validator checks whether an API specification document contains all required structural fields and correctly identifies its version โ OpenAPI 3.x or Swagger 2.0. Paste your spec in JSON or YAML format and the tool reports: the detected spec version, total endpoint count, and the specific required fields that are missing, if any.
OpenAPI (formerly Swagger) is the de-facto standard for describing REST APIs. A valid spec is the foundation of every downstream tool in the API lifecycle โ documentation generators like Redoc and Swagger UI, mock servers, API gateway configurations, SDK generators, and contract testing frameworks all parse the spec before doing anything else. An invalid spec โ missing info.title, no paths, or an unrecognised root key โ breaks these tools silently or with cryptic errors far removed from the actual problem in the spec file.
This validator performs a structural check: it confirms the required root-level fields are present and reports the endpoint count. It does not resolve $ref pointers, validate individual schema definitions, or check whether response body shapes match declared schemas. For full semantic linting, the scope disclaimer is explicit: use Redocly CLI or the Swagger Editor for production-ready spec validation. For pure syntax validation of YAML specs, the YAML Validator is the complementary tool.
Validation runs entirely in your browser. Your spec content is never transmitted to a server or stored anywhere โ safe for pre-release or internal API definitions.
How to use this OpenAPI calculator
- Paste your OpenAPI 3.x or Swagger 2.0 specification into the spec input area. The default example shows a minimal valid OpenAPI 3.0.3 document in YAML format โ you can paste JSON or YAML.
- The tool processes your input automatically. No submit button is needed.
- Check the Valid or Invalid badge at the top of the result panel.
- If Valid: read the details โ confirm the detected spec version is correct and review the endpoint count to ensure all paths are being read as expected.
- If Invalid: read the details list of missing fields. Each missing field is listed by its full dotted path (e.g.,
info.version) so you can locate it directly in your spec. - Fix the reported fields in your spec, paste the corrected version back, and re-validate until the Valid badge appears.
- Once the structural check passes, run a full linter (Redocly CLI or Swagger Editor) for deeper schema and reference validation before publishing or importing the spec.
Formula & Methodology
### Version Auto-Detection The tool reads the root of the parsed document for two keys: -openapikey present โ classified as OpenAPI 3.x. The value (e.g.,"3.0.3","3.1.0") is reported as the spec version. -swaggerkey present โ classified as Swagger 2.0. The value (e.g.,"2.0") is reported as the spec version. - Neither key present โ reported as unrecognised format. ### Required Fields by Spec Version OpenAPI 3.x required fields: | Field | Location | Rule | |---|---|---| |openapi| Root | Must be present; value must start with3.| |info.title|infoobject | Non-empty string | |info.version|infoobject | Non-empty string | |paths| Root | Must be present and contain at least one path with at least one HTTP method operation | Swagger 2.0 required fields: | Field | Location | Rule | |---|---|---| |swagger| Root | Must equal"2.0"| |info.title|infoobject | Non-empty string | |info.version|infoobject | Non-empty string | |paths| Root | Must be present and contain at least one path with at least one HTTP method operation | ### JSON vs YAML Handling JSON input: the spec is fully parsed usingJSON.parse(). All required field lookups traverse the parsed object tree precisely. YAML input: the tool performs structural key extraction using heuristic pattern matching on the raw YAML text. Top-level keys (e.g.,openapi:,info:,paths:) and first-level nested keys underinfo:(e.g.,title:,version:) are identified by scanning for key patterns at the expected indentation levels. This approach correctly handles standard YAML formatting. Deeply nested$refpointers, custom anchors, and non-standard indentation may not be fully resolved โ use the YAML Validator first if your spec has unusual formatting. ### Endpoint Count Calculation The tool counts HTTP method operations by looking for the standard HTTP method keys (get,post,put,patch,delete,head,options,trace) under each path item inpaths. Each method key found under a path counts as one endpoint. This matches how Postman, Stoplight, and Redocly count API operations. Valid minimal OpenAPI 3.x example (JSON):json { "openapi": "3.0.3", "info": { "title": "My API", "version": "1.0.0" }, "paths": { "/users": { "get": { "summary": "List users", "responses": { "200": { "description": "OK" } } } } } }Result: Valid โ OpenAPI 3.0.3 โ 1 endpoint detected. Invalid example (missinginfo.version):yaml openapi: "3.0.3" info: title: My API paths: /users: get: summary: List users responses: "200": description: OKResult: Invalid โ missing field:info.version.
Frequently Asked Questions