apicurito icon indicating copy to clipboard operation
apicurito copied to clipboard

Data type examples are not readable by Swagger UI

Open Cediddi opened this issue 7 years ago • 4 comments

Hi, great application. My issue is very simple;

When I define a example json for a datatype and export the data, I see a string representation in both source tab as well as in swagger UI. It would be nice if I could define a data type for the example input and apicurito would keep it that way. Currently if I write the example in source tab, design tab will show me [Object object] as representation.

Many thanks in advance, this app is marvelous and writing swagger is fun now.

Cediddi avatar Nov 27 '18 14:11 Cediddi

Thanks for the feedback! Can you provide an example of what you're talking about as OpenAPI yaml and/or json? In other words, what did you type in the design tab? :)

I'm pretty sure I understand what you're asking for, I just want to make sure we're on the same page.

EricWittmann avatar Nov 27 '18 16:11 EricWittmann

Okay, I took some screenshots to explain my workflow.

1- I create a data type with an example json object and select Rest Resource. 2- I check the data type in design window and it looks fine. 3- I check the source window and it looks like an escaped string, not json or yaml. 4- I export my yaml file to Swagger UI and check the main url for that data type, example value shows like an array of escaped string. 5- I edit the data type in source window to be a valid object (json or yaml, doesn't matter) 6- I check the design window and it says [Object object] because it's not an escaped string anymore. 7- I export my yaml file to Swagger UI and check the main url for that data type, example value shows like an array of valid objects.

I hope I explained the situation properly.

Cediddi avatar Nov 28 '18 11:11 Cediddi

Great explanation, thanks!

The OpenAPI v3 specification allows examples to be either in string or object format. Perhaps the v2 spec does not allow this (you are using v2 in your use-case). I'll need to have a look. Either way, the Apicurio editor should do a better job understanding the example when it is an object rather than a string!

EricWittmann avatar Nov 28 '18 14:11 EricWittmann

I believe this has been addressed in Apicurio Studio (and the fix will flow into Apicurito on the next release). Stay tuned. :)

EricWittmann avatar Mar 13 '19 13:03 EricWittmann