question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

OAS 3.0: Support for media type examples (aka request/response body examples)

See original GitHub issue

Version: ft/oas3 branch, as of commit a1ce0e7

OpenAPI 3.0 has requestBody.content.<media-type>.example(s) and responses.<code>.content.<media-type>.example(s). UI currently does not use these examples, but it would be great if it did. They are supposed to override schema-level examples if any.

Spec:

openapi: 3.0.0
info:
  version: 0.0.0
  title: test

paths:
  /something:
    post:
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Message'
            example:
              message: request body example
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Message'
              example:
                message: response body example

components:
  schemas:
    Message:
      type: object
      properties:
        message:
          type: string
          example: property-level example

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:29
  • Comments:20 (5 by maintainers)

github_iconTop GitHub Comments

30reactions
ghostcommented, Dec 16, 2017

The docs state that this functionality exists: https://swagger.io/docs/specification/adding-examples/

@shockey Would it be possible to write in the documentation that this functionality is currently defective? It was pretty frustrating sitting their for an hour trying to get it working only to eventually find this issue.

21reactions
niklasnorincommented, Mar 16, 2018

This issue is incredibly annoying. We’re using the same Schema object in request and response, except that there are some subtle differences in how you should use it. It would have been perfect to be able to distinguish this with separate examples for the same schema object.

Also showing multiple examples in requests will be awesome.

Can’t wait for this to be fixed!

Read more comments on GitHub >

github_iconTop Results From Across the Web

OpenAPI Specification - Version 3.0.3 - Swagger
Some examples of possible media type definitions: ... Tooling which supports OAS 3.0 SHOULD be compatible with all OAS 3.0.* versions.
Read more >
OpenAPI Specification v3.1.0 | Introduction, Definitions, & More
The OpenAPI Specification (OAS) defines a standard, ... 4.8.13 Request Body Object ... Some examples of possible media type definitions:
Read more >
OpenAPI Examples Need Help
The OpenAPI v3.0 Specification is rather brief on information about how ... There are examples in Schema Objects, Parameters, and Media Type ......
Read more >
REST Guidelines - Belgif
A notable exception to this rule is the swagger/OpenAPI file (see doc resource). Instead, look at how to express Media Types using HTTP...
Read more >
API Docs with OpenAPI 3.0 - SlideShare
Media types • Media type declarations go within the content object • They have a schema and can have several examples • Vendor-specific...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found