swagger-api / swagger-api/swagger-ui

YAML request body rendered as JSON

Open
#4,642 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

cat: try-it-out type: enhancement
Dominant language
JavaScript
Stars
29k
Forks
9.3k
Avg merge
2d 23h
Merged PRs (30d)
25

Description

Q&A (please complete the following information)
  • OS: macOS 10.13.6
  • Browser: Chrome
  • Version: 69.0.3451.0
  • Method of installation: docker image
  • Swagger-UI version: 3.17.0
  • Swagger/OpenAPI version: OpenAPI 3.0
Content & configuration

Swagger/OpenAPI definition:

openapi: 3.0.0
info:
  title: Yet Another REST API
servers:
  - url: 'https://example.com/api'
components:
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic
  schemas:
    Pool:
      type: string
      example: dev
    ServiceType:
      type: string
    StackName:
      type: string
      pattern: '^[a-zA-Z0-9-]+$'
      example: jd-stack
    StackNew:
      type: object
      properties:
        owner:
          $ref: '#/components/schemas/UserID'
        stackname:
          $ref: '#/components/schemas/StackName'
        version:
          $ref: '#/components/schemas/StackVersion'
        services:
          type: array
          items:
            type: object
            properties:
              type:
                $ref: '#/components/schemas/ServiceType'
              servers:
                type: integer
                minimum: 1
                example: 1
        poolname:
          $ref: '#/components/schema/Pool'
    StackVersion:
      type: integer
      example: 6
    UserID:
      type: string
      format: email
      example: john.doe@example.com
security:
  - basicAuth: []
paths:
  /stacks:
    post:
      description: Creates new stack
      tags:
        - Stacks
      requestBody:
        required: true
        content:
          application/yaml:
            schema:
              $ref: '#/components/schemas/StackNew'
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                type: object
                properties:
                  stackname:
                    $ref: '#/components/schemas/StackName'

Swagger-UI configuration options:
Defaults on docker image

Screenshots

image

How can we help?

Not sure if this is the expected behaviour, but I'd expect a request body of media type application/yaml to be rendered as yaml instead of json. Any help/advice on this would be much appreciated!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the supplied OpenAPI 3.0 definition in Swagger UI 3.17.0, focusing on the /stacks POST request body with application/yaml content. Trace how the request-body media type is rendered and verify that the completed behavior displays YAML rather than JSON.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, openapi
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.