swagger-api / swagger-api/swagger-ui

displayRequestDuration not working as expected

Open
#7,243 4 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

cat: performance
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: Linux
  • Browser: firefox,chrom
  • Version: 88.0 (64-bit)
  • Method of installation: maven (scala tapir library dependency)
  • Swagger-UI version: 3.45.0
  • Swagger/OpenAPI version: OpenAPI 3.0
Content & configuration

Example Swagger/OpenAPI definition:

openapi: 3.0.3
info:
  title: The tapir library
  version: 1.0.0
paths:
  /books/list/all:
    get:
      operationId: getBooksListAll
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Book'
  /books/add:
    post:
      operationId: postBooksAdd
      requestBody:
        description: The book to add
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Book'
            example:
              title: Pride and Prejudice
              year: 1813
              author:
                name: Jane Austen
        required: true
      responses:
        '200':
          description: ''
components:
  schemas:
    Book:
      required:
      - title
      - year
      - author
      type: object
      properties:
        title:
          type: string
        year:
          type: integer
        author:
          $ref: '#/components/schemas/Author'
    Author:
      required:
      - name
      type: object
      properties:
        name:
          type: string

Swagger-UI configuration options:

SwaggerUIBundle({
        url: "https://petstore.swagger.io/v2/swagger.json",
        dom_id: '#swagger-ui',
        deepLinking: true,
        presets: [
          SwaggerUIBundle.presets.apis,
          SwaggerUIStandalonePreset
        ],
        plugins: [
          SwaggerUIBundle.plugins.DownloadUrl
        ],
        layout: "StandaloneLayout"
      });

Query string options

?url=/admin/docs/docs.yaml&displayRequestDuration=true
Describe the bug you're encountering

after adding displayRequestduration to swagger query parameters: displayRequestDuration=true as per above, I can see request duration, however time shown is far from what other means of measurements calculated.

The request duration is not correctly calculated.

To reproduce...

Steps to reproduce the behavior:

  1. Install and run sample akka-http project with tapir. I will use this one as an example: sample-project
  2. Go to localhost.swagger-ui.html with displayRequestDuration=true already appended in query parameters.
  3. Try it out on /books/list/all endpoint.
  4. See request duration
  5. Use the same query with other tools like Postman or CURL
  6. See the difference in request duration times
Expected behavior

I expect time to be at least similar (not 4 or 5 times higher) to the time shown by Postman or CURL.

Screenshots

Swagger
obraz-20210423-093822
Postman
obraz-20210423-093630
In-application metrics
obraz-20210423-093659

Additional context or thoughts

Maybe the time that I see is, somehow, correct? If so, please let me know how should I interpret it.

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

Start by reproducing the request from the provided Swagger UI URL with displayRequestDuration=true, then compare its timing with curl or Postman as described. Trace the Swagger UI implementation responsible for displaying request duration and determine whether the measured interval matches the documented behavior; done means the discrepancy is corrected or the timing interpretation is clarified.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend, performance
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.