Skip to content

Discrepancy found on swagger schema 2.0 and swagger schema description in spec #329

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

Closed
pegasusess opened this issue Apr 16, 2015 · 5 comments
Assignees

Comments

@pegasusess
Copy link

According to swagger schema spec (which can be found on https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md), the field "host" should be as following:

The host (name or ip) serving the API. This MUST be the host only and does not include the scheme nor sub-paths. It MAY include a port. If the host is not included, the host serving the documentation is to be used (including the port). The host does not support path templating.

According to this definition, ip_address:port_number should make a valid 'host' field. However when I tried to validate my swagger json doc against swagger json schema (which can be found on http://swagger.io/v2/schema.json), 'host' field has to follow the following format:

"host": {
  "type": "string",
  "format": "uri",
  "pattern": "^[^{}/ :\\\\]+(?::\\d+)?$",
  "description": "The fully qualified URI to the host of the API."
}

ip_address:port_number failed on this validation check. Only when I changed it to domain_address:port_number,, this validation check is passed successfully.

this has caused confusion. Please make the description in spec match with the schema

@webron
Copy link
Member

webron commented Apr 16, 2015

It's the other way around @pegasusess - the problem is with the schema, not the spec. We caught this issue yesterday and I'm a bit baffled by it. This an issue with the escaping in the regex which shouldn't occur, but I'll investigate more tomorrow.

@mattcanty
Copy link

This has left me scratching my head for a while. The example PetStore swagger file does not validate against the schema.

I'm adding on a port for now - "host": "api.uber.com:80"

@ndhar-1
Copy link

ndhar-1 commented Jun 18, 2015

+1
ip_address:port_number fails validation .....

@hornc
Copy link
Contributor

hornc commented Jul 22, 2015

Hi, I just found this issue after raising a PR that I think fixes this. I ran into a similar confusion around validating using a range of tools, some passed and some failed, here's my PR with my explanation of what I believe is the problem: #420

I think the regex is fine, it just conflicts with the format: uri, and how different validators deal with the conflict is undefined.

@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
None yet
Projects
None yet
Development

No branches or pull requests

5 participants