Swagger-ui: Query string parameter not rendered when using 'content' property

Created on 13 Nov 2018  路  4Comments  路  Source: swagger-api/swagger-ui

Q&A (please complete the following information)

Content & configuration

Example Swagger/OpenAPI definition:

openapi: 3.0.1
info:
  title: API Docs
  version: '1.0'
  description: 'Docs'
paths:
  /api/v1/tools/lnft:
    get:
      summary: Calculate LNFT
      tags:
        - Tools
      description: 'description'
      operationId: LNFT
      parameters:
        - in: query
          name: filter
          content:
            application/json:  # <---- media type indicates how to serialize / deserialize the parameter content
              schema:
                type: object
                properties:
                  type:
                    type: string
                  color:
                    type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CalculateLNFT'
            application/xml:
              schema:
                $ref: '#/components/schemas/CalculateLNFT'
                xml:
                  name: data
        '400':
          description: Bad Request -- Validation failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
            application/xml:
              schema:
                $ref: '#/components/schemas/Error'
                xml:
                  name: data
        '401':
          description: Authorization Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
            application/xml:
              schema:
                $ref: '#/components/schemas/Error'
                xml:
                  name: data
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
            application/xml:
              schema:
                $ref: '#/components/schemas/Error'
                xml:
                  name: data
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
  schemas:
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: integer
              description: HTTP Code
            message:
              type: string
              description: Error Description
    CalculateLNFT:
      type: object
      properties:
        data:
          type: object
          properties:
            results:
              type: object
              properties:
                LNFT:
                  type: float
                  descritpion: Linear feet value
                  example: 7.08
                Trucks:
                  type: integer
                  description: Number of Trucks necessary for load
                  example: 2
                Remarks:
                  type: string
                  description: Remarks
                  example: string
            message:
              type: string
              description: Extra Info
security:
  - bearerAuth: []
servers:
  - url: /framework

Describe the bug you're encountering


Unable to render query string parameter when using 'content' instead of schema. I'm using 'content' because my query string is a json string, as stated in the example.

To reproduce...

Steps to reproduce the behavior:

  1. Use 'content' as stated in https://swagger.io/docs/specification/describing-parameters/
      parameters:
        - in: query
          name: filter
          content:
            application/json:  # <---- media type indicates how to serialize / deserialize the parameter content
              schema:
                type: object
                properties:
                  type:
                    type: string
                  color:
                    type: string

(complete yaml above)

  1. See error when rendering in swagger UI: 馃槺 Could not render ParameterRow, see the console.
  2. Console output:
    root-injects.js:95 TypeError: Cannot read property 'get' of undefined
    at t.value (parameter-row.jsx:145)
    at t.render (root-injects.js:93)
    at s._renderValidatedComponentWithoutOwnerOrContext (ReactCompositeComponent.js:796)
    at s._renderValidatedComponent (ReactCompositeComponent.js:819)
    at s.performInitialMount (ReactCompositeComponent.js:359)
    at s.mountComponent (ReactCompositeComponent.js:255)
    at Object.mountComponent (ReactReconciler.js:43)
    at X.mountChildren (ReactMultiChild.js:234)
    at X._createInitialChildren (ReactDOMComponent.js:701)
    at X.mountComponent (ReactDOMComponent.js:520)

Expected behavior

Input is rendered

Screenshots

Additional context or thoughts

lock-bot

All 4 comments

Thanks for the report! This issue is tracked in #4442.

Closing as a duplicate of #4442 馃槃

The solution to the problem : "馃槺 Could not render this component, see the console." in Swagger Open API 3 can be resolved by following the link: https://swagger.io/docs/specification/describing-parameters/

sorry, this issue was resolved??

Was this page helpful?
0 / 5 - 0 ratings

Related issues

liuya05 picture liuya05  路  3Comments

ankon picture ankon  路  4Comments

DavidBiesack picture DavidBiesack  路  4Comments

insideshell picture insideshell  路  3Comments

fehguy picture fehguy  路  3Comments