redoc icon indicating copy to clipboard operation
redoc copied to clipboard

Plaintext examples are ignored

Open mpbzh opened this issue 4 years ago • 3 comments

The following example is a reduced version of my (afaik) valid OpenApi 3 file defining a request body with both application/json and text/plain mimetypes:

openapi: 3.0.3
info:
  title: 'Test API'
  version: 1.0.0
paths:
  /users:
    post:
      summary: 'Missing CSV examples'
      description: 'This demonstrates missing csv examples'
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                records:
                  type: array
                  items:
                    $ref: '#/components/schemas/person'
          text/plain:
            schema:
              type: string
              example: "This is a Test"
        required: true
      responses:
        '200':
          description: 'Placeholder response'
components:
  schemas:
    person:
      required:
        - person_id
        - name
      type: object
      properties:
        person_id:
          type: integer
          description: 'Person identifier in source system'
        name:
          type: string
          description: 'Person name'
      example:
        person_id: 1
        name: 'Hello World'

The official Swagger Editor accepts the plaintext example: swagger-editor

When I generate a standalone HTML file using redoc-cli (Version 0.11.4), the example is ignored: nosample

Also, but probably due to the same bug, when I remove the application/json

This issue might be related to #371.

mpbzh avatar Jun 01 '21 07:06 mpbzh

Is there any update on this issue? how can we show example for text/plain type?

rishagit avatar Sep 08 '21 20:09 rishagit

@RomanHotsiy - Do you have an update on the comment you made in #371

ReDoc 2.0 will support all the mime samples correctly so I am not going to fix it properly for ReDoc 1.x

edno avatar Dec 10 '21 11:12 edno

Is there any update on this issue? I'm not able to show the examples of text/plain. @rishagit did you got any solution for this?

aman2457 avatar Feb 04 '22 08:02 aman2457

This should be updated in Redoc >=2.0, so I'll close this issue - but please let us know if you're still seeing something that doesn't look right?

lornajane avatar Nov 23 '23 16:11 lornajane