Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show schema objects as XML if content type is XML #744

Closed
chrisdudley opened this issue Nov 24, 2014 · 24 comments
Closed

Show schema objects as XML if content type is XML #744

chrisdudley opened this issue Nov 24, 2014 · 24 comments

Comments

@chrisdudley
Copy link

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.

@webron
Copy link
Contributor

webron commented Nov 24, 2014

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.

@chrisdudley
Copy link
Author

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.

@jugglingcats
Copy link

+1 for XML support

@glenngillen
Copy link

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.

@jugglingcats
Copy link

Are you able to share your changes or outline the approach?

@glenngillen
Copy link

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 onComplete callback 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.

@fehguy fehguy added this to the v2.1.0-M2 milestone Dec 29, 2014
@fehguy
Copy link
Contributor

fehguy commented Dec 29, 2014

Would like to add XML support for default models in 2.1.0-M2

@chrisdudley
Copy link
Author

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?

@mohsen1
Copy link
Contributor

mohsen1 commented Mar 23, 2015

Once the API from client is ready to get the raw schema we can render the schema in both JSON and XML formats.

swagger-api/swagger-js#311 is opened to provide that API

@fehguy fehguy modified the milestones: v2.1-M2, v2.1 Mar 26, 2015
@magictucura
Copy link

Can you tell in which period the xml support will be available?

@fehguy
Copy link
Contributor

fehguy commented Mar 27, 2015

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.

@foufee
Copy link

foufee commented Apr 15, 2015

When do you think that 2.1 proper will be ready, the XML feature would be very useful.

@webron
Copy link
Contributor

webron commented Apr 15, 2015

@foufee - we aim for 2-3 weeks but can't guarantee.

@webron webron added the P3 label May 4, 2015
@webron webron modified the milestones: v2.1, v2.1.1 Jun 8, 2015
@acazsouza
Copy link

+1 for XML support

@webron webron removed the P3 label Jul 21, 2015
@webron webron modified the milestones: v2.1.2, v2.1.1 Jul 21, 2015
@webron webron removed this from the v2.1.2 milestone Jul 31, 2015
@webron webron modified the milestones: v2.1.3, v2.1.2 Jul 31, 2015
@webron webron modified the milestones: v2.1.3, v2.1.4 Sep 2, 2015
@andrecastro
Copy link

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.

@firefoxNX
Copy link

👍

6 similar comments
@litti
Copy link

litti commented Oct 17, 2015

👍

@m-jedynak
Copy link

👍

@chreble
Copy link

chreble commented Nov 9, 2015

👍

@jnupponen
Copy link

👍

@seoj
Copy link

seoj commented Dec 1, 2015

👍

@foxsmart
Copy link

foxsmart commented Dec 1, 2015

👍

@xurde
Copy link

xurde commented Dec 1, 2015

This would be great. 👍
Can we help somehow?

@fehguy
Copy link
Contributor

fehguy commented Dec 7, 2015

please track meta issue #1248

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests