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

Add example/s as "Operation Request" child #1673

Open
chatelao opened this issue Aug 22, 2018 · 5 comments
Open

Add example/s as "Operation Request" child #1673

chatelao opened this issue Aug 22, 2018 · 5 comments
Labels
example obj/keywords Issues with the Example Object or exampel(s) keywords param serialization Issues related to parameter and/or header serialization

Comments

@chatelao
Copy link

To define valid parameter combination examples, it would be nice to define consistent examples for an operation and not only on JSON / single-parameter base.

The alternative to use the same Id on every example is less intuitive, especially when reusing type definitions of parameters

@MikeRalphson
Copy link
Member

Could you show an example of what you'd like to be able to do to clarify your question?

@hkosova
Copy link
Contributor

hkosova commented Feb 25, 2021

I think the OP is asking for the ability to provide examples for different combinations of parameters. Maybe even a combination of parameters + request body.

Consider an item search operation that supports pagination and sorting:

paths:
  /items:
    get:
      parameters:
        - in: query
          name: offset
          schema:
            type: integer
            default: 0
            minimum: 0
        - in: query
          name: limit
          schema:
            type: integer
            minimum: 0
            maximum: 50
            default: 20
        - in: query
          name: sort
          schema:
            type: string
            enum: [asc, desc]
            default: asc
        - in: query
          name: sort_by
          schema:
            type: string
            enum: [name, created]
            default: name

As a technical writer, I would like to provide examples for:

  • get the first 50 items: ?limit=50
  • get items 20-29: ?offset=19&limit=10
  • get the last created item: ?sort=desc&sort_by=created&limit=1

As a user of an interactive API console, I would like to use these examples to fill in the corresponding values for multiple parameters at once.


The current workaround is to add such examples to the operation description.

@a-akimov
Copy link
Contributor

a-akimov commented Mar 5, 2021

We experience the same problem. We've started added more and more examples to the OpenAPI files themselves (e.g. see https://github.com/Adyen/adyen-openapi/blob/master/json/CheckoutService-v67.json#L8178-L8936), but not clear how to give examples for GET.

Of course, there shouldn't be request body for GET but we still want to show examples of GET URLs (and possible responses for these comibations of query parameters).

@judielaine
Copy link

@handrews handrews added the examples requests for more or better examples in the specification label Jan 28, 2024
@handrews handrews added 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 May 30, 2024
@handrews
Copy link
Member

This is another issue that would be solved by #1502.

@handrews handrews added the param serialization Issues related to parameter and/or header serialization label May 30, 2024
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 param serialization Issues related to parameter and/or header serialization
Projects
None yet
Development

No branches or pull requests

6 participants