Computed URL correct but not honored when executing
#5770 aperta il 31 dic 2019
Metriche repository
- Star
- (25.447 star)
- Metriche merge PR
- (Merge medio 20h 34m) (14 PR mergiate in 30 g)
Descrizione
Q&A (please complete the following information)
- OS: macOS
- Browser: chrome
- Version: 79
- Method of installation: Docker Hub latest
- Swagger-UI version: 3.24.3
- Swagger/OpenAPI version: OpenAPI 3.0
Content & configuration
Nothing out of the ordinary. Just running docker version
Example Swagger/OpenAPI definition:
openapi: 3.0.0
info:
title: Todo API
description: Todo API
version: 1.0.0
servers:
- url: '{scheme}://{host}:{port}{basePath}'
description: Generic request that defaults to values for local service
variables:
scheme:
description: request scheme
enum:
- http
- https
default: http
host:
description: server host
default: localhost
port:
description: the port of the service
default: '8000'
basePath:
description: Base path options, leave empty for use with mock service
enum:
- ''
- /services/opp/todos/1.0.0
default: /services/opp/todos/1.0.0
tags:
- name: Tasks
description: Tasks
paths:
/todos:
get:
tags:
- Tasks
summary: List the available tasks
description: |
The list of tasks can be filtered by their status.
operationId: todo.todos.api.query
parameters:
- name: id
in: query
description: Todo ID to filter on
schema:
type: string
example: 42
- name: page_token
in: query
description: Pagination page token
schema:
type: string
- name: per_page
in: query
description: The max number of items to include per page or results.
schema:
type: integer
- name: status
in: query
description: Filters the tasks by their status
required: false
schema:
type: string
enum:
- done
- waiting
- working
example: working
responses:
'200':
description: Successfully
content:
application/json:
schema:
$ref: '#/components/schemas/Todos'
'422':
description: Invalid query parameter key or value
content:
'application/problem+json':
schema:
$ref: '#/components/schemas/ProblemDetail'
Swagger-UI configuration options: NA
Describe the bug you're encountering
Depending on the default value for basePath above, the UI will not honor the computed path (which is computed correctly in the UI).
If the default is the current value, when you select the empty string enum for the base path, the executed path just uses the default base path even though the computed URL is correct. No matter how you switch it, it does not work.
However, if you change the spec to use the empty string as the default, then switching the base path is honored by the UI when executing.
To reproduce...
Steps to reproduce the behavior:
- Load the UI.
- Click on basePath and switch to the empty base path
- Got to GET /todos and click try it
- Click Execute
- Look at the generated curl statement.
- See that is uses the wrong server url
Expected behavior
The computed URL should always be the value used for the server URL in a request.
Screenshots


Additional context or thoughts
Running this against a stoplight prism mock server running the spec.