Dear Swaggers,
i need to have a jaxrs service accepting POST in JSON or XML and returning
corresponding type (JSON for JSON, XML for XML).
For this reason I've implemented a yaml with the following sections both in
the header side of the yaml and also in the paths section.
consumes:
- "application/json"
- "application/xml"
produces:
- "application/json"
- "text/xml"
codegen generate produces corresponding code in
io.swagger.api.mymethod.java
@Path("/mymethod")
@Consumes({ "application/json","application/xml" })
@Produces({ "application/json","text/xml" })
and also inside the class
@POST
@Consumes({ "application/json","application/xml" })
@Produces({ "application/json","text/xml" })
Compilation proceeds fine, and calling with application/json content type
works fine.
However when I curl with application/xml or text/xml then I get 415.
curl -X POST --header 'Content-Type: application/xml' --header 'Accept:
text/xml' -d '<?xml version="1.0"?><cas:Sofa xmi:id="1" sofaNum="1"
text="Aspirin"/>' http://localhost:8080/my/api/v2/doit/mymethod
<!doctype html><html lang="en"><head><title>HTTP Status 415 – Unsupported
Media Type</title><style type="text/css">h1
{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;}
h2
{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;}
h3
{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;}
body
{font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} b
{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;}
p
{font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}
a {color:black;} a.name {color:black;} .line
{height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP
Status 415 – Unsupported Media Type</h1><hr class="line" /><p><b>Type</b>
Status Report</p><p><b>Message</b> Unsupported Media
Type</p><p><b>Description</b> The origin server is refusing to service the
request because the payload is in a format not supported by this method on
the target resource.</p><hr class="line" /><h3>Apache
Tomcat/8.5.16</h3></body></html>
any advice is appreciated.
Thankyou
--
You received this message because you are subscribed to the Google Groups
"Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.