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.
Property | Value |
---|---|
Enabled | Yes |
Maximum Severity | Error |
Message | Scheme or sub-paths found in the host which is not supported. |
Code | SWAGGER20STANDARDS_V005 |
Type | Validation |
Rule System | Semantic |
Broad Category | Swagger Root Information |
Products Impacted | API Transformer, Code Generation, Developer Experience Portal |
Tags | swagger2 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 ofhttps://api.example.com
, useapi.example.com
as the value of thehost
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 thehost
field contains the root domain or subdomain where your API is hosted, but not any sub-paths or additional path segments.