Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.0: Swagger UI broken for POST /dcim/cables/, possibly others #3778

Closed
glennmatthews opened this issue May 19, 2023 · 7 comments · Fixed by #4000
Closed

2.0: Swagger UI broken for POST /dcim/cables/, possibly others #3778

glennmatthews opened this issue May 19, 2023 · 7 comments · Fixed by #4000
Assignees
Labels
type: bug Something isn't working as expected
Milestone

Comments

@glennmatthews
Copy link
Contributor

Environment

  • Nautobot version (Docker tag too if applicable): 2.0
  • Python version:
  • Database platform, version:
  • Middleware(s):

Steps to Reproduce

  1. Navigate to https://next.demo.nautobot.com/api/docs/ (you must be using the legacy UI or the page fails to load at all; this is probably a separate bug)
  2. Click to expand the POST /dcim/cables/ subheading.

Expected Behavior

Section to expand and render information about how to POST to this endpoint - this works in demo.nautobot.com (1.5.7) by comparison:

image

Observed Behavior

Loading spinner appears indefinitely, eventually the browser may complain about a long-running script and offer to stop it for you:

image

Maybe related to #3500?

@glennmatthews glennmatthews added the type: bug Something isn't working as expected label May 19, 2023
@glennmatthews glennmatthews added this to the v2.0.0 milestone Jun 20, 2023
@glennmatthews
Copy link
Contributor Author

Profiling in the browser shows that the size of the Swagger docs has increased by over an order of magnitude:

demo.nautobot.com: 295kB (and that includes a number of installed plugins, default size will be lower still)
next.demo.nautobot.com: 10.64MB

@gsnider2195
Copy link
Contributor

gsnider2195 commented Jun 20, 2023

I'm seeing similar schema sizes for demo and next:

https://demo.nautobot.com/api/swagger/?api_version=1.2

Allow: GET, HEAD, OPTIONS
Content-Disposition: inline; filename="API Documentation (1.2).json"
Content-Length: 12467165
Content-Type: application/json
Date: Tue, 20 Jun 2023 16:43:02 GMT
Referrer-Policy: same-origin
Vary: Accept, Cookie, Origin
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
https://next.demo.nautobot.com/api/swagger/?api_version=2.0

Allow: GET, HEAD, OPTIONS
Content-Disposition: inline; filename="API Documentation (2.0).json"
Content-Length: 10640435
Content-Type: application/json
Date: Tue, 20 Jun 2023 16:44:52 GMT
Referrer-Policy: same-origin
Server: Caddy
Server: WSGIServer/0.2 CPython/3.9.16
Vary: Accept, Cookie, Origin
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
$ wc -l *.json
  292742 1.2.json
  251157 2.0.json

$ sort 1.2.json | uniq -c | sort -n | tail -20
   2472                                                     },
   2617                                 "format": "uuid"
   2952                                 "type": "string",
   3049                                 },
   3552                                                         "type": "string",
   3578                         }
   3667                 ],
   4257                         "type": "string",
   4315                                 "type": "string"
   4723                     }
   7455                             "items": {
   7455                             "type": "array",
   7455                         "explode": true,
   7455                         "style": "form"
   9221                         "in": "query",
   9593                         },
   9948                         "schema": {
  10348                             }
  12735                     {
  18510                     },

$ sort 2.0.json | uniq -c | sort -n | tail -20
   1950                             "type": "string",
   2044                                 "schema": {
   2090                                 "type": "string",
   2268                                                         "type": "string",
   2791                                 }
   3508                         "type": "string",
   3570                 ],
   3679                         }
   3900                                 "type": "string"
   4269                     }
   6235                         "style": "form"
   6314                             "items": {
   6314                             "type": "array",
   6314                         "explode": true,
   8811                         },
   9015                             }
   9063                         "in": "query",
   9705                         "schema": {
  12240                     {
  15751                     },

@bryanculver
Copy link
Member

Definition of Done: Ensure the Swagger UI loads, can expand different API endpoints, and is not stuck with a spinner like in the screenshot above. No hard line on file size.

@bryanculver
Copy link
Member

Might want to look at "ENUM_GENERATE_CHOICE_DESCRIPTION": False to cut down on bloat. A feature introduced upstream in Swagger might be adding a lot of very verbose ENUM value choices.

@glennmatthews
Copy link
Contributor Author

It looks like we now have a number of cyclic / infinitely recursive schema definitions. For example,

  • Cable has termination_a of type CableTermination
  • CableTermination is one of CircuitTermination, ConsolePort, etc.
  • CircuitTermination has a cable_peer of type CableTermination.... 💀

Looks like the depth isn't being accurately reflected in the schema.

@lampwins
Copy link
Member

Going guess this is a contributing factor to the size of the schema. Or at least, not helping.

@glennmatthews
Copy link
Contributor Author

Fixed by #4000

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug Something isn't working as expected
Projects
No open projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants