Skip to content

Changing openApi version to 3.1.1 in spec file leads to much longer resolving time #4152

@meijey

Description

@meijey

Q&A (please complete the following information)

  • OS: linux mint 22.3
  • Environment: Node.js v22.16.0
  • Method of installation: npm i
  • Swagger-Client version: 3.36.1
  • Swagger/OpenAPI version: OpenApi V.3.0.4 / OpenApi V.3.1.1

Content & configuration

Using the same specfile but changing the openapi version from 3.0.4 to 3.1.1 leads to a much higher resolving time (about 10 - 15x).

I understand that there may be some new functions have to be checked, but the time difference seems a bit odd for me.

On smaller files this may not be that noticable on larger files thou it is (a file with 900 paths goes from ~350ms up to ~5-7s).

Swagger/OpenAPI definition:

Using the default petstore json (https://petstore3.swagger.io/api/v3/openapi.json) shows already a huge difference.

Swagger-Client usage:

const SwaggerClient = require('swagger-client')
const path = require('path')
const fs = require('fs/promises')

const test = async () => {
  // get specs (default petstore)
  const petstoreV3 = JSON.parse(await fs.readFile(path.join(__dirname, './PetstoreV3.0.4.json')))
  const petStoreV311 = JSON.parse(await fs.readFile(path.join(__dirname, './PetstoreV3.1.1.json')))

  // start tests
  console.log('------------------------', __dirname)
  // petstoreV3: ~ 35ms
  console.time('petstore v3')
  await new SwaggerClient({ spec: petstoreV3 })
  console.timeEnd('petstore v3')

  // petStoreV311: ~ 406ms
  console.time('petstore v3.1.1')
  await new SwaggerClient({ spec: petStoreV311 })
  console.timeEnd('petstore v3.1.1')
  console.log('----------------')
}

test()

Describe the bug you're encountering

Much longer loading times.

To reproduce...

Steps to reproduce the behavior:

Use the petstore or any other >3.1.1 version and change it to 3.1.1.
Then use await new SwaggerClient({ spec })

Expected behavior

The loading times difference should propably not be that huge.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions