Closed ricardo-de-andrade closed 8 years ago
+1 using this tool within a CI/command line environment would be great
Hi, you mean like this?
curl -X POST -H "accept:application/json" -d @petstore.json http://online.swagger.io/validator/debug
Something like that would be handy, yeah. Then the json doesn't need to be publicly accessible.
OK got it. Then you're in luck! The validator supports this already. See here:
and per my last comment, it's supported in the online codegen. Please close if this covers your concerns...
That's great for my purposes, thanks! It would be great if it was documented in the README. I will endeavour to submit a PR.
What is the content type for a yaml file? I'v tried
url -X POST -H "accept:text/x-yaml" -d @abc.yaml http://online.swagger.io/validator/debug
But get
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Error 406 Not Acceptable</title>
</head>
<body><h2>HTTP ERROR 406</h2>
<p>Problem accessing /validator/debug. Reason:
<pre> Not Acceptable</pre></p><hr><i><small>Powered by Jetty://</small></i><hr/>
</body>
</html>
Maybe I have the incorrect media type? not sure what to use for yaml
application/yaml
Thanks,
OK. I tried
url -X POST -H "accept:application/yaml" -d @abc.yaml http://online.swagger.io/validator/debug
And still get the 406 response code.
I tried it from postman and it seems to work. Any other suggestions?
It's not the accept
header you need to send, it's the content-type
.
OK.
I used the example from above to start with. However, I tried Content-Type as well.
curl -v -X POST -H "Accept:application/yaml" -H "Content-Type:application/yaml" --data @abc.yaml "http://online.swagger.io/validator/debug"
I still get a 406. When I send just the content-type
I get 500.
Here is the verbose output.
* Trying 52.3.245.229...
* Connected to online.swagger.io (52.3.245.229) port 80 (#0)
> POST /validator/debug HTTP/1.1
> Host: online.swagger.io
> User-Agent: curl/7.43.0
> Accept:application/yaml
> Content-Type:application/yaml
> Content-Length: 3574
> Expect: 100-continue
>
< HTTP/1.1 100 Continue
* We are completely uploaded and fine
< HTTP/1.1 406 Not Acceptable
< Date: Fri, 11 Mar 2016 21:05:06 GMT
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Methods: GET, POST, DELETE, PUT
< Access-Control-Allow-Headers: Content-Type
< Content-Type: text/html; charset=ISO-8859-1
< Cache-Control: must-revalidate,no-cache,no-store
< Content-Length: 309
< Connection: close
< Server: Jetty(9.2.9.v20150224)
<
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Error 406 Not Acceptable</title>
</head>
<body><h2>HTTP ERROR 406</h2>
<p>Problem accessing /validator/debug. Reason:
<pre> Not Acceptable</pre></p><hr><i><small>Powered by Jetty://</small></i><hr/>
</body>
</html>
* Closing connection 0
The following works for me, can you try that?
curl -X POST -H "content-type:application/yaml" --data-binary @swagger.yaml "http://online.swagger.io/validator/debug"
That works. looks like the key is --data-binary
instead on --data
Thanks
It would be nice if the tool would allow the user to invoke the validator tool and pass the contents of the yaml/json (even if only the /debug).
For example (some other method of achieving it would be just as good): curl -X POST /validator/debug --data-binary @{fileName}
This would simplify the integration of the tool in to build automation processes for example, where the API definition may not be available online.
Today a workaround would be to start the tool locally, and then start a local webserver just for the validation, which is a bit heavy.