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

fix(editor-preview): reset error boundaries on editor content change #4347

Merged
merged 1 commit into from
Aug 7, 2023

Conversation

char0n
Copy link
Member

@char0n char0n commented Aug 7, 2023

When following AsyncAPI definition was provided to the editor, the AsyncAPI renderer crashed, error boundary caught the error and displayed the fallback component. When we changed the editor content to fix the issue, the fallback component was still displaying, because it's error state was persistent. This is fine in SwaggerUI content, where the definition is immutable. But it's impractical in SwaggerEditor@5 content, where definition always changes. This PR introduces override for error boundary mechanism provided by SwaggerUI, which detects if editor has changed. If the editor content has changed the error boundary state resets.

Definition:

asyncapi: '2.6.0'
info:
  title: AsyncAPI
  version: '1.0.0'
channels:
  'foo':
    description: Bar.
    publish:
      message:
        oneOf:
          - $ref: '#/components/messages/Foo'
       
          
components:
  messages:
    Foo:
      name: Foo
      payload:
        $ref: "#/components/schemas/Bar"
      examples:
        - name: standard
          payload:
            after: 
              oneOf:
              - $ref: '#/components/messages/Foo'
              
  schemas:
    Bar:
      type: object
      properties:
        eventType:
          type: string
          desciption: Foo

Fallback component displayed instead of rendered AsyncAPI definition:

image

@char0n char0n self-assigned this Aug 7, 2023
@char0n char0n merged commit 6fbf235 into next Aug 7, 2023
2 checks passed
@swagger-bot
Copy link
Contributor

🎉 This PR is included in version 5.0.0-alpha.74 🎉

The release is available on:

Your semantic-release bot 📦🚀

swagger-bot pushed a commit that referenced this pull request Aug 7, 2023
# [5.0.0-alpha.74](v5.0.0-alpha.73...v5.0.0-alpha.74) (2023-08-07)

### Bug Fixes

* **editor-preview:** reset error boundaries on editor content change ([#4347](#4347)) ([6fbf235](6fbf235))
@char0n char0n deleted the char0n/editor-safe-render branch August 9, 2023 07:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants