Kong / insomnia

The open-source, cross-platform API client for GraphQL, REST, WebSockets, SSE and gRPC. With Cloud, Local and Git storage.
https://insomnia.rest
Apache License 2.0
33.71k stars 1.88k forks source link

[Feature request] Auto-Generate XML Request Bodies from OpenAPI spec and prevent deletion of manually edited ones #3038

Open waciii-ra opened 3 years ago

waciii-ra commented 3 years ago

Question

  1. How does one get Insomnia to auto-generate XML Request Bodies?
  2. How does one get Insomnia to not delete manually created XML Request Bodies if auto-generate doesn't work or isn't desired?

In contrast to requestBody.content.application/json (which does auto-generate Request Body), when using requestBody.content.application/xml Insomnia Designer is NOT auto-generating a Request Body as implied in documentation here. And it's deleting any manually created Request Body after navigating to the Design tab.

It appears that some code or plugin to auto-generate XML is missing and that the refresh / re-generate request body logic operates without awareness that there is nothing that is going to auto-generate a new Request Body for XML.

Context I'm trying to create test cases for XML APIs. I find that I can do that only by manually creating a Request Body. However once doing so, Insomnia will delete the manually created Request Body after the Design Tab is clicked. This makes Insomnia almost usuable for testing.

The sequence to see the XML Request Body deleted is strange (has a couple extra steps) because Insomnia has a wider issue (also occurs after a Git Update) with not automatically refreshing screens immediately when a change happens.

To recreate:

  1. Click Design. Create or access OpenAPI Spec with requestBody.content.application/xml
  2. Click Debug. Select XML. See nothing auto-generated
  3. Enter XML Request Body. Optionally Send. Optionally Generate Tests and Execute. Optionally click back and forth between Debug and Test. Optionally restart Insomnia. See XML Request Body saved in all cases.
  4. Click Design. Make no changes. Click Debug. Click Design or Test. Click Debug. See XML Request Body deleted.
waciii-ra commented 3 years ago

NOTE: Recreate requires navigating back and forth to the Debug tab more than once due to an "Out-of-synch Refresh" problem. (ie: you must do Step 4 above)

System Environment: recreate_00_SystemEnvironment-About.txt

Example OpenAPI Spec: recreate_01_openAPI-Spec.txt

application/json rendering in Live Preview: recreate_02_JSONpreview-render

application/json Auto-Generating Request Body: recreate_03_JSONrequestBody_AutoGen

application/xml rendering in Live Preview: recreate_04_XMLpreview-render

application/xml Failing to Auto-Generate Request Body: recreate_05_XMLrequestBody_No-AutoGen

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

filfreire commented 1 year ago

Hi @waciii-ra thanks for reporting this!

I've gone ahead and marked this as a feature request/improvement, and internally added it to our list of improvements. We'll update you here if there's any changes.

Also giving a heads up to @wdawson - we may want to revisit if this is something we want to do regardless of JSON/XML or other body types, and fetch the information (if available) that is in the specs and put it as suggested request body always.

In the meantime @waciii-ra feel free to report any other issues you come across!

RavenLiquid commented 1 year ago

It took me a lot of headscratching and searching to find this. It should be documented somewhere or visible in the UI that XML generation does not work.

For me the experience was that importing just stopped working, only later releasing that the difference was XML instead of JSON.

It is in no way obvious why it doesn't work as the preview indeed shows the correct example message, and the linting does not show any warnings either.

If it is not supported, it should be obvious and documented.