Skip to content

displayRequestDuration not working as expected #7243

Open
@Lazu13

Description

@Lazu13

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions