swagger-api / swagger-api/swagger-ui

"Try it out" doesn't prompt with form when parameters are a schema

Open
#2,771 11 comments 23 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

P3 type: feature version: 3.x
Dominant language
JavaScript
Stars
29k
Forks
9.3k
Avg merge
2d 23h
Merged PRs (30d)
25

Description

The following path used to provide username/password text input fields. In 3.0.2 it now requires the "Example Value" text box to be edited. It looks like this happens when the input parameters are specified using schema.

        "/auth/token": {
            "post": {
                "tags": [
                    "auth"
                ],
                "summary": "Get an API key",
                "description": "",
                "operationId": "getApiKey",
                "security": [],
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json; version=1.0"
                ],
                "parameters": [
                    {
                        "in": "body",
                        "name": "body",
                        "description": "Authentication",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/auth_credentials"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful Authentication",
                        "schema": {
                            "description": "Authorization Result",
                            "allOf": [
                                {
                                    "$ref": "#/definitions/Response"
                                },
                                {
                                    "properties": {
                                        "result": {
                                            "description": "API Key",
                                            "type": "string",
                                            "example": "example_api-key_iZkjs8-Yc2LzRjpwKbai11kkPZg"
                                        }
                                    }
                                }
                            ]
                        }
                    },
                    "400": {
                        "description": "Invalid Format",
                        "schema": {
                            "$ref": "#/definitions/ErrorResponse"
                        }
                    },
                    "401": {
                        "description": "Invalid Credentials",
                        "schema": {
                            "$ref": "#/definitions/AuthErrorResponse"
                        }
                    }
                }
            }
        }
...
        "auth_credentials": {
            "type": "object",
            "properties": {
                "username": {
                    "type": "string",
                    "minLength": 1,
                    "title": "Username"
                },
                "password": {
                    "type": "string",
                    "format": "password",
                    "minLength": 1,
                    "title": "Password",
                    "secret": true
                }
            },
            "additionalProperties": false,
            "required": [
                "username",
                "password"
            ]
        },

screen shot 2017-03-22 at 1 03 41 pm

As an example the following path which does not use schema provides a text input field for name:

        "/support_bundles/{name}": {
            "delete": {
                "tags": [
                    "support_bundles"
                ],
                "summary": "Delete a single support bundle",
                "description": "",
                "operationId": "deleteSupportBundle",
                "produces": [
                    "application/json; version=1.0"
                ],
                "parameters": [
                    {
                        "name": "name",
                        "in": "path",
                        "description": "Name of support bundle",
                        "required": true,
                        "type": "string"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Success",
                        "schema": {
                            "$ref": "#/definitions/Response"
                        }
                    }
                }
            }
        },

screen shot 2017-03-22 at 1 07 17 pm

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

No file or test is named in the issue. Start at the Swagger UI "Try it out" form handling for body parameters with a schema, compare it with the path-parameter example, and verify that schema-defined username/password fields are shown without editing Example Value.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
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.