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

requestBody examples do not respect media-type #6475

Closed
mathis-m opened this issue Oct 6, 2020 · 2 comments · Fixed by #6739
Closed

requestBody examples do not respect media-type #6475

mathis-m opened this issue Oct 6, 2020 · 2 comments · Fixed by #6739

Comments

@mathis-m
Copy link
Contributor

mathis-m commented Oct 6, 2020

Q&A (please complete the following information)

OS: [e.g. macOS] Windows 10 Pro
Browser: [e.g. chrome, safari] chrome
Version: [e.g. 22] Version 85.0.4183.102 (Official Build) (64-bit)
Method of installation: [e.g. npm, dist assets] raw code
Swagger-UI version: [e.g. 3.10.0] master
Swagger/OpenAPI version: [e.g. Swagger 2.0, OpenAPI 3.0] 3.0.1

Content & configuration

Example Swagger/OpenAPI definition:

openapi: 3.0.1
info:
 title: Example Swagger
 version: '1.0'
servers:
 - url: /api/v1
paths:
 /xmlTest:
   post:
     summary: sample issues
     operationId: registerSubscription
     parameters: []
     requestBody:
       description: Simple Test
       content:
           application/xml:
              schema:
               $ref: "#/components/schemas/Test"
              example: 
                x: should be xml
     responses:
       '200':
         description: Simple example
         content: {}
components:
 schemas:
   Test:
     type: object
     xml:
       name: root
     properties:
       x:
         type: string
       other:
         type: string
         format: email
     example: 
       x: what the f

Describe the bug you're encountering

When providing examples via examples or example keyword for requestBody content it will not be rendered according to content-type.

To reproduce...

Open yaml at editor and try to view xml requestBody sample. You can delete the example part and it will render it in xml.

Expected behavior

Examples provided via examples or example for requestBody definition should be rendered respecting the content-type.
With example requestBody:
image
Without:
image

Additional context or thoughts

Same as for Responses #6442

@scholzi100
Copy link

Are there updates to this? Looks like handling for response does work as of the latest release.

@mathis-m
Copy link
Contributor Author

@scholzi100 Unfortunately I didn't have time to create a PR, but it shouldn't be a big problem. I will probably manage to create a pr next week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants