Show schema objects as XML if content type is XML
Using latest master swaggerui code with swagger 2. If the content type is only XML then it looks odd for schema objects to be shown as JSON in swaggerUI. I haven't yet experimented with the Example object, will that help show the examples as XML instead of JSON? Its hard to tell when there aren't any examples in the swagger 2 spec yet. It would be good if the model schema representation changed as the content type changed, that way users could more easily cut and paste into the body field to test the api.
The UI displays two separate things - The Model and the Model Schema.
Disregarding the naming, the Model should remain the same and the Model Schema could change based on the mime type.
The tricky part would be to change it dynamically when more than one content-type is allowed.
Since the example is a free-form object, it can be anything, and we'll probably just paste it as is. It would still need to be a valid JSON object as the whole spec is in JSON. You could, however, add additional processing and extract the any form of example and manipulate it as needed in the UI.
Some JS hanging off the content type drop down that changed the model schema format as the content type changed? With swagger 2 it should be able to know what the XML is supposed to look like, I know that was an issue with 1.2. The model schema there is very handy if using JSON as you can cut and paste from it into the body field, edit as necessary and then test the api. The same capability isn't there for XML. I know JSON is by far the more common but it would be nice to have the same capabilities regardless of format.
+1 for XML support
Fwiw I hacked together a non-elegant solution for an API I'm trying to understand at the moment (I'm documenting using Swagger as I go because the official aren't entirely accurate): http://trademonster.glenngillen.com
Like I said it's not terribly elegant, but solves my current issue (the API is always in XML). Code to make it happen is entirely in JS on the in question in case someone wanted to use it as a stating point.
Are you able to share your changes or outline the approach?
I'm hoping I can add this back upstream, but I'm a bit time constrained atm so it'll likely be a few weeks away. In the interim here's what I did:
- Grabbed the JXON library from Mozilla which handles converting between JSON and XML objects.
- Updated
onCompletecallback to iterate over all JSON definitions and change them to XML
As I mentioned this isn't an ideal implementation by any stretch. It needs to be updated to switch based on the Response and Parameter types rather than hard-coded assuming it's always XML instead of always JSON.
Would like to add XML support for default models in 2.1.0-M2
That would be great, any idea when 2.1.0-M2 will be? I'm happy to give it a test if that would help?
Once the API from client is ready to get the raw schema we can render the schema in both JSON and XML formats.
https://github.com/swagger-api/swagger-js/issues/311 is opened to provide that API
Can you tell in which period the xml support will be available?
Hi, it was targeted to the latest release (2.1.0-M2) but this feature didn't make it. Will be by 2.1 proper.
When do you think that 2.1 proper will be ready, the XML feature would be very useful.
@foufee - we aim for 2-3 weeks but can't guarantee.
+1 for XML support
Hi. When this feature will be done? I have a Rest API that works only with XML, it would be very useful for me. thanks.
:+1:
:+1:
:+1:
:+1:
:+1: