OAS 3.0: Support for media type examples (aka request/response body examples)
See original GitHub issueVersion: 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:
- Created 6 years ago
- Reactions:29
- Comments:20 (5 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

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.
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!