Skip to content

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

Open

Description

@amarzavery

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.

Activity

  1. amarzavery commented on Dec 23, 2016

    @amarzavery
    Author
  2. darrelmiller commented on Jan 6, 2017

    @darrelmiller
    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.

  3. ckriley commented on Jan 26, 2017

    @ckriley
    Contributor

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

  4. added
    examplesrequests for more or better examples in the specification
    example obj/keywordsIssues with the Example Object or exampel(s) keywords
    and removed
    examplesrequests for more or better examples in the specification
    on Jan 29, 2024
  5. chatelao commented on Jun 14, 2024

    @chatelao

    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.

  6. added this to the v3.2.0 milestone on Sep 13, 2024
  7. apiarya commented on Sep 13, 2024

    @apiarya

    👀 on it

  8. removed this from the v3.2.0 milestone on May 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    example obj/keywordsIssues with the Example Object or exampel(s) keywords

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions