Do not force "" for http status code
See original GitHub issueIn JSON the key which is a number must be wrapped into ""
. This is not the case of yaml format. Different formats, different requirements. It does not make sense to force json requirements into yaml and this makes it really annoying to have to use "400": ...
in YAML
Please also note that https://editor.swagger.io does not wrap status codes into “”, which is correct, but contradictory to this spec:
I propose to remove the requirement of providing status codes as strings in YAML and only keep it for JSON, leaving the alignment for the transformation tool between two formats.
I already created #2147, which got rejected, so now I am opening this issue as the proposal for the next version of the spec.
Issue Analytics
- State:
- Created 4 years ago
- Comments:22 (12 by maintainers)
Top Results From Across the Web
A Complete Guide and List of HTTP Status Codes
A complete list of HTTP status codes with explaination of what they are, why they occur and what you can do to fix...
Read more >List of HTTP status codes - Wikipedia
This is a list of Hypertext Transfer Protocol (HTTP) response status codes. Status codes are issued by a server in response to a...
Read more >A Guide to HTTP Status Codes - Siteimprove Support
What are HTTP status codes? HTTP Response Codes indicate whether specific HTTP requests have been successfully completed.
Read more >304 Not Modified - HTTP - MDN Web Docs
The HTTP 304 Not Modified client redirection response code indicates that there is no need to retransmit the requested resources.
Read more >Understanding HTTPS Status Codes + a Complete List
The server sends this HTTP status code to redirect the client to the target resource on another URI. Since it is temporary, the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think this would not be an improvement to OpenAPI. in terms of general principles, OpenAPI exists to aid interoperability. changes that add ambiguity to how an API can be represented in OpenAPI are counter to that. every tool would now have to look for numeric keys in addition to string keys. it opens up the possibility for collisions if both integer 200 and string “200” are present. it brings in issues of comparing numbers (is
200
equal to200.0
? in some languages all numbers are parsed to floats).having a single, consistent way to represent an http status obviates all these problems. I appreciate that the aesthetics of having to quote these, when you don’t normally have to quote object keys in YAML, is suboptimal. but it is best for keys to remain as strings.
it’s unfortunate that the swagger editor uses integer keys. they shouldn’t. it looks like these are implicitly converted to strings by their YAML parser (which is not usual and seems plainly incorrect according to the YAML spec - but that’s far afield). I will open an issue to correct their examples (unless, of course, the consensus on this issue goes the other way).
I’ve worked with a lot of http libraries, the string/integer decision seems like a coin toss sometimes. arguably an integer is more appropriate, but it doesn’t really matter. OpenAPI documents are JSON (even when they are YAML), and in JSON, object keys are strings, not integers.