swagger-editor icon indicating copy to clipboard operation
swagger-editor copied to clipboard

Editor freezes when having circular $ref in schemas

Open alpalex opened this issue 8 months ago • 0 comments

Q&A (please complete the following information)

  • OS: [e.g. macOS]
  • Browser: [e.g. chrome, safari]
  • Version: [e.g. 22]
  • Method of installation: don't remember, i think i cloned the repo and used npm from there on
  • Swagger-Editor version: 174eb07580a4b63ab1b1c31bd1cc840143ab2402
  • Swagger/OpenAPI version: OpenAPI 3.0.3

Describe the bug you're encountering

Tab freezes

To reproduce...

Steps to reproduce the behavior: use following OpenAPI specification:

components:
  schemas:
    xyz:
      type: array
      items:          
        $ref: '#/components/schemas/xyz'

Additional context or thoughts

This circular reference is most of the time a user mistake. (But i guess this could be an actual thing the user wants to do too!!!) This is especially nasty because it is complicated to gain access to the definition again:

  1. wait until browser notifies you the page is running slow and offers you a "stop" button to stop javascript execution
  2. use dev console to remove the circular ref. Example:
localStorage.setItem('swagger-editor-content', localStorage.getItem('swagger-editor-content').replaceAll('#/components/schemas/challenge', ''))

alpalex avatar Dec 13 '23 12:12 alpalex