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

Proposal: Having an example for an entire operation in one place (request + response) #859

Open
amarzavery opened this issue Dec 23, 2016 · 5 comments
Labels
example obj/keywords Issues with the Example Object or exampel(s) keywords
Milestone

Comments

@amarzavery
Copy link

The current mechanism to provide examples for artifacts in a swagger spec is fragmented. It does not give the consumer an overview (or a bird's eye view) of an example to complete that operation successfully.

If the example object is opened up and can be provided per operation then this solves the problem. People can provide multiple examples (variations) for that operation. It can be very easily used for documenting and (live/mock) testing the API.

Please read the detailed proposal over here. Currently we have implemented an extension named "x-ms-examples" for our specs. The schema for this extension can be found here.

It would be nice to see what the community thinks about it and if it is possible to get this approach formally in the open api specification.

@amarzavery
Copy link
Author

/cc @darrelmiller

@darrelmiller
Copy link
Member

The V3 spec does provide the ability to specify multiple examples for request/response bodies using an array. However, there currently isn't a mechanism to provide a description for that example.

When it comes to providing a more holistic example, I'm not sure that inventing a new JSON structure for an example instance would be the way I would go. I think I would be more tempted to stick to the natural message/http text format.

I do agree that being able to present a more complete request/response example would be beneficial.

@ckriley
Copy link
Contributor

ckriley commented Jan 26, 2017

Examples is definitely an area that needs improvement and developers we work with would prefer wire format per @darrelmiller.

@handrews handrews added examples requests for more or better examples in the specification example obj/keywords Issues with the Example Object or exampel(s) keywords and removed examples requests for more or better examples in the specification labels Jan 29, 2024
@chatelao
Copy link

The "HTTP ARchive (HAR)" is somehow the "instance brother" of OpenAPI.

https://w3c.github.io/web-performance/specs/HAR/Overview.html

Maybe reusing part for the example data structures could be an idea?

HAR can be captured directly in Webbrowsers "F12 is your friend". And there are libraries générating OpenAPI from HAR.

n.b.: HAR is well known in forensics to and "trial proved" for digital evidence.

@handrews handrews added this to the v3.2.0 milestone Sep 13, 2024
@apiarya
Copy link

apiarya commented Sep 13, 2024

👀 on it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
example obj/keywords Issues with the Example Object or exampel(s) keywords
Projects
None yet
Development

No branches or pull requests

6 participants