Hello, I am trying to make my Swagger api specification to work for both types of responses: json and xml. Attached is my swagger spec. I use 'xml' swagger field to control xml serialization behavior. Swagger Editor and Swagger Client Generator (Java) work as expected with json response.
However when I send a request to xml endpoint "GET /xml/search", the java
code generated by Swagger Client Generator throws
io.swagger.client.ApiException: Content type
"application/xml;charset=utf-8" is not supported for type: class
io.swagger.client.model.Body
at io.swagger.client.ApiClient.deserialize(ApiClient.java:845)
at io.swagger.client.ApiClient.handleResponse(ApiClient.java:1036)
at io.swagger.client.ApiClient.execute(ApiClient.java:970)
at
io.swagger.client.api.DefaultApi.xmlSearchGetWithHttpInfo(DefaultApi.java:465)
at io.swagger.client.api.DefaultApi.xmlSearchGet(DefaultApi.java:446)
at
io.swagger.client.api.DefaultApiTest.xmlSearchGetTest(DefaultApiTest.java:138)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at
org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
I have the following declaration in the spec for this endpoint
produces:
- application/xml
My questions are:
1) Does Swagger Editor supports xml type as a response? What I see now
when "trying this operation" on "GET /xml/search" is 'Raw' tab contains
response with expected xml but there are no parsed objects on the
'Rendered' tab? Is this a limitation of Swagger Editor?
2) Does Swagger Client Generator supports xml format as a response? If yes
could you please suggest why the generated code for "GET /xml/search"
operation throws "Content type not supported" exception?
Thank you and best regards
--
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.
swagger(17).yaml
Description: Binary data
