Skip to main content

no-schemes-sub-paths-in-host

Overview

This rule belongs to the swagger-v2-standards-validation ruleset and states that:

In Swagger 2.0, the host field is intended to represent the hostname (and optionally the port number) where the API is hosted. This violation occurs when the host field includes the scheme (such as http:// or https://) or sub-paths (additional path segments) that are not supported according to the Swagger 2.0 specification.

PropertyValue
EnabledYes
Maximum SeverityError
MessageScheme or sub-paths found in the host which is not supported.
CodeSWAGGER20STANDARDS_V005
TypeValidation
Rule SystemSemantic
Broad CategorySwagger Root Information
Products ImpactedAPI Transformer, Code Generation, Developer Experience Portal
Tagsswagger2 swagger standards semantic validation host

Suggested Fixes

  • If the host includes a schema, remove the scheme from the host: The host field should only include the hostname and port number (if applicable), without the scheme. For example, instead of https://api.example.com, use api.example.com as the value of the host field.
  • If the host includes any sub-paths, remove sub-paths from the host: The host field should only represent the hostname and port number, without any additional path segments. Ensure that the host field contains the root domain or subdomain where your API is hosted, but not any sub-paths or additional path segments.

For More Information