swagger-api / swagger-api/swagger-client

Resolving large specs takes very long / crashes

Open
#2,532 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
2.7k
Forks
765
Avg merge
1d 1h
Merged PRs (30d)
6

Description

Q&A (please complete the following information)
  • OS: Ubuntu 22.04
  • Environment: Node 16.13.2
  • Method of installation: npm
  • Swagger-Client version: 3.18.5
  • Swagger/OpenAPI version: OpenAPI 3.0
Content & configuration

Swagger/OpenAPI definition: Stripe

Swagger-Client usage:

const SwaggerClient = require('swagger-client');

SwaggerClient.resolve({url: 'https://github.com/stripe/openapi/raw/master/openapi/spec3.json'})
Describe the bug you're encountering

Running the above script takes very long and and uses one CPU core non-stop 100%. I was too impatient to wait until it might complete or node.js fails, so I cancelled the process after 27 minutes. A user of my downstream library reported that the process crashes after about one hour.

To reproduce...

Steps to reproduce the behavior:

  1. Run the script above (e.g. node index.js)
Expected behavior

The script terminates successfully after a reasonable period of time.

Additional context or thoughts

While I think it is acceptable that resolving very large / complex specs takes longer, I would think that it should be faster than it is at the moment. Doing the same using the Java swagger-parser only takes a few seconds for the same spec.

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 running the provided Node.js script against Stripe's OpenAPI definition and measure resolution time, CPU use, and whether the process crashes. Trace the SwaggerClient.resolve entry point to identify the resolution path responsible, then verify that the same reproduction completes in a reasonable time without sustained CPU exhaustion or a crash.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
api, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 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.