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

Regex-patterned example values are regenerated on every keystroke in the UI #8297

Open
glennmatthews opened this issue Nov 14, 2022 · 0 comments

Comments

@glennmatthews
Copy link

Q&A (please complete the following information)

  • OS: macOS 12.6
  • Browser: Firefox
  • Version: 104
  • Method of installation:
  • Swagger-UI version: 4.14.0
  • Swagger/OpenAPI version: OpenAPI 3.0

Content & configuration

Example behavior can be seen on https://demo.nautobot.com/api/docs/ but I do not believe this issue to be specific to our schema or configuration of Swagger-UI (which is using drf-spectactular-sidecar Python package for distribution/installation).

Describe the bug you're encountering

Upon expanding any API endpoint that provides an "Example Value", then selecting "Try it out", it appears that any input into any of the input fields in the UI causes the entire "Example Value" to be regenerated, substantially slowing the UI when the example value (schema) is relatively large and/or complex. This is most noticeable on fields with a regex pattern as a new random string appears in the example value on each such regeneration/refresh.

Worse, this refreshing behavior isn't even specific to the particular API endpoint for which input is being entered -- if multiple API endpoints are expanded, it appears that all "Example Value" data is regenerated on any input to any endpoint, making the slowdown that much more significant.

To reproduce...

Steps to reproduce the behavior:

  1. Go to https://demo.nautobot.com/api/docs/
  2. Can be seen for any API endpoint, but GET /circuits/provider-networks/{id}/ is a decent example.
  3. Expand the endpoint, and click "Try it out".
  4. Enter text into any input field (for example, "id" for the above endpoint)
  5. Observe that each slug field in the "Example Value" is refreshed to a new random value after every keystroke.

Expected behavior

Example values should be generated once and once only and should not change in response to user input. The UI should be more responsive and performant than it currently is.

Screenshots

Note how the slug values (which are defined with a pattern in the schema) change in each successive screenshot:

image

image

image

image

Additional context or thoughts

Appears related to #7829, may also be a contributing factor to #6787?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant