Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uri format for the host should be hostname #249

Closed
casualjim opened this issue Jan 24, 2015 · 3 comments
Closed

uri format for the host should be hostname #249

casualjim opened this issue Jan 24, 2015 · 3 comments
Labels

Comments

@casualjim
Copy link
Contributor

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

@webron
Copy link
Member

webron commented Jan 28, 2015

Since the "hostname" format doesn't allow ports, it's not going to be the proper solution.

What we'll do is remove the format altogether, and keep the regex as a very basic validation.

Eventually, it's the user's responsibility to provide a proper value as described by the spec.

@hornc
Copy link
Contributor

hornc commented Jul 22, 2015

PR that hopefully addresses this: #420

My interpretation is that host is NOT a json-schema hostname because it can include a port number, and therefore isn't a rcf1034 section 3.1 hostname

The field has t be a custom pattern match. format: uri is incorrect, as is the 'fully qualified URI' description.

@webron
Copy link
Member

webron commented Jul 30, 2015

This is now fixed.

@webron webron closed this as completed Jul 30, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants