-
Notifications
You must be signed in to change notification settings - Fork 9.2k
Description
The swagger spec defines the host property with format uri, then proceeds with a pattern to disallow schemes. This is not a valid uri.
{
"host": {
"type": "string",
"format": "uri",
"pattern": "^[^{}/ :\\\\]+(?::\\d+)?$",
"description": "The fully qualified URI to the host of the API."
}
}The json schema spec is a bit unclear on relative references and whether or not they are allowed. However the URI (RFC 3986) is very clear about the fact that a relative reference not starting with // is a relative path not a hostname. This is contradictory to the pattern because it doesn't allow for / or :
The usage of the word URI is confusing because an uri surely should allow a scheme.
I think the intended definition of the host property is this:
{
"host": {
"type": "string",
"format": "hostname",
"description": "The fully qualified hostname for the API."
}
}I am considering the jsonschema test suite as the source of truth of what a uri format means, because that's what the implementations use. And so if we want consistency we should not diverge from what is in that test suite.
Extra info:
relative reference uri spec: https://tools.ietf.org/html/rfc3986#section-4.2
https://groups.google.com/d/msg/json-schema/91Xk-ebRw3o/MsKUkFYQRkEJ
hostname: http://json-schema.org/latest/json-schema-validation.html#anchor114
uri: http://json-schema.org/latest/json-schema-validation.html#anchor123
zaggino/z-schema#18
json-schema-org/JSON-Schema-Test-Suite#58