Define & Validate APIsValidation RulesetsOpenAPI Rulesets

Swagger v2 Syntax Validation

Validation checks performed on provided Swagger v2 file to check its conformance to Swagger 2.n syntax rules.

PropertyValue
Ruleset IDswagger-v2-syntax-validation
Code prefixSWAGGER20SYNTAX_V
TypeValidation
Default severityError
Rule systemSyntax
Rules11

API Server

CodeRuleSeverityWhat it checks
SWAGGER20SYNTAX_V001no-host-path-templatingErrorIn Swagger 2.0, the host field is used to specify the hostname (and optionally the port number) where the API is hosted. The violation occurs when path templating, which is the use of variables within the host field, is detected. Path templating is not supported in the host field according to the Swagger 2.0 specification.
SWAGGER20SYNTAX_V002base-path-starts-with-leading-slashErrorIn Swagger 2.0, the basePath field is used to specify the common path prefix for all API endpoints. The violation occurs when the basePath value does not begin with a leading slash (/), which is required according to the Swagger 2.0 specification.
SWAGGER20SYNTAX_V003no-base-path-templatingErrorIn Swagger 2.0, the basePath field is used to specify the common path prefix for all API endpoints. This violation occurs when path templating, which involves using variables within the basePath field, is detected. Path templating is not supported in the basePath field according to the Swagger 2.0 specification.

Paths

CodeRuleSeverityWhat it checks
SWAGGER20SYNTAX_V020path-name-begin-with-forward-slashErrorIn Swagger 2.0, each path within the paths section should start with a leading slash (/). This violation occurs when a path name is defined without the required leading slash, which is mandatory according to the Swagger 2.0 specification.

Responses

CodeRuleSeverityWhat it checks
SWAGGER20SYNTAX_V040valid-response-http-status-codeErrorThe Responses Object key must be a valid HTTP status code or set to 'default'. The key must be enclosed in quotation marks for compatibility between JSON and YAML. If the key is an explicit status code, then it must be valid according to RFC7231 and possibly listed in the registered status codes in the IANA Status Code Registry.

References

CodeRuleSeverityWhat it checks
SWAGGER20SYNTAX_V060valid-dollar-ref-pathErrorThe '$ref' values must be RFC3986-compliant percent-encoded URIs.

Specification Extensions

CodeRuleSeverityWhat it checks
SWAGGER20SYNTAX_V080specification-extension-name-being-with-x-dashErrorIf any additional property needs to be added in the Swagger specification that is otherwise not part of the actual standard, specification extension can be used for this purpose at certain points. The extension name must begin with x- (e.g. x-internal-id).

Miscellaneous

CodeRuleSeverityWhat it checks
SWAGGER20SYNTAX_V100valid-mime-typeErrorThe mime type definitions should be in compliance with RFC6838.
SWAGGER20SYNTAX_V101valid-url-formatErrorString value should be in the format of a proper URL. The URL path can be relative only if a server URL exists in the API document to help resolve the URL path into an absolute path.
SWAGGER20SYNTAX_V102valid-email-addressErrorString value must be in the format of an email.
SWAGGER20SYNTAX_V103valid-property-value-typeErrorValue of a Swagger standard property must be in accordance with the type set by the standard for that property.

Learn more

On this page