Skip to content

feat: split conditions and rules into separate tabs, refactor schema component#1121

Open
catosaurusrex2003 wants to merge 60 commits intoasyncapi:masterfrom
catosaurusrex2003:refactor-messages
Open

feat: split conditions and rules into separate tabs, refactor schema component#1121
catosaurusrex2003 wants to merge 60 commits intoasyncapi:masterfrom
catosaurusrex2003:refactor-messages

Conversation

@catosaurusrex2003
Copy link
Contributor

@catosaurusrex2003 catosaurusrex2003 commented Jan 11, 2025

The problem

The current schema UI assumes a deep understanding of the AsyncAPI specification, making it difficult for many users to interpret. Since schemas can be recursive and heavily nested with various properties, the complexity often becomes overwhelming and unintuitive.

The solution

This PR introduces a new UI structure that splits schema properties into two logical sections: Rules and Conditions, making the documentation easier to understand and navigate.

Reference: AsyncAPI Schema Object (v3.0.0)

The properties which come under the Rules section are:
format, pattern, constraints, contentEncoding, enum, default, const

The properties which come under the Conditions section are:
oneOf, anyOf, allOf, not, propertyNames, contains, if, then, else, dependentSchemas

All other properties remain in their original positions.

A tabbed interface now allows users to toggle between Rules and Conditions. This design reduces visual clutter and helps users digest smaller, relevant portions of the schema at a time.

Visual Comparison

Old schema UI 👇
image

New implementation - Rules tab 👇
image

New implementation - Conditions tab 👇
image

New implementation - Conditions tab and expand all 👇
image

Alternative approaches explored
We initially considered a sidebar-based layout as demonstrated here that separated Rules and Conditions spatially. However, it introduced several issues:.

  • Significant empty space when one section had more items than the other.

Without sidebar 👇 :
image

With sidebar 👇 : (you can notice how the empty spaces in red which is very unoptimal)
image

  • Reduced horizontal space for nested schemas
  • Poor responsiveness on smaller screens

After discussions with @AceTheCreator we opted for the tabbed layout, which offers better responsiveness, clarity, and overall user experience.

Other changes

  • The existing library/src/components/Schema.tsx has been refactored into smaller, modular components under a new library/src/components/Schema/ directory for better maintainability and readability.

  • Updated the way constraints are displayed: ranges like [0..1000] are now represented in a more intuitive format as 1 <= value <= 1000 for better readability.

  • Updated the start and build:styles:dev script to include all the available tailwind styles during development. This ensures that when you add a new Tailwind class (even one not yet used anywhere else in the project), you don’t need to rebuild the styles manually. The new styles are already available in default.min.css, so changes take effect instantly through hot reloading — speeding up the development workflow.

Source/Inspiration

#618
https://www.asmitbm.me/projects/asyncapi-docsux

This PR is part of https://github.com/orgs/asyncapi/discussions/1361#discussioncomment-10811342

@catosaurusrex2003 catosaurusrex2003 marked this pull request as ready for review February 25, 2025 11:47
@catosaurusrex2003 catosaurusrex2003 changed the title feat: refactor payload feat: introduce seperate conditions and rules tabs and refactor schema component Apr 10, 2025
@catosaurusrex2003 catosaurusrex2003 changed the title feat: introduce seperate conditions and rules tabs and refactor schema component feat: split conditions and rules into separate tabs, refactor schema component Apr 10, 2025
@sonarqubecloud
Copy link

@sonarqubecloud
Copy link

@catosaurusrex2003
Copy link
Contributor Author

@AceTheCreator
I updated the scripts and added description for it.

@github-actions
Copy link

This pull request has been automatically marked as stale because it has not had recent activity 😴

It will be closed in 120 days if no further activity occurs. To unstale this pull request, add a comment with detailed explanation.

There can be many reasons why some specific pull request has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model.

Let us figure out together how to push this pull request forward. Connect with us through one of many communication channels we established here.

Thank you for your patience ❤️

@github-actions github-actions bot added the stale label Sep 22, 2025
@catosaurusrex2003
Copy link
Contributor Author

still relevant

@github-actions github-actions bot removed the stale label Oct 1, 2025
Copy link
Member

@AceTheCreator AceTheCreator left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@catosaurusrex2003 I left some review :) Let's get this PR merged.

expandAll();

expandAll();

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this expandAll() called twice intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it is intentional
But
Idealy it shouldnt be needed (theres an issue with the recursive working of expandAll)

test it against this schema in playground and you will understand.

asyncapi: 2.6.0
info:
  title: Sets Example
  version: 1.0.0

channels: {}

components:
  schemas:
    Sets:
      title: Sets
      type: array
      items:
        type: object
        title: Set
        properties:
          pets:
            title: Pets
            type: array
            items:
              title: Pet
              type: object
              discriminator: type
              required:
                - type
              properties:
                type:
                  title: Pet.Type
                  type: string
                  enum:
                    - CAT
                    - DOG
              oneOf:
                - title: Cat
                  type: object
                  properties:
                    type:
                      const: CAT
                - title: Dog
                  type: object
                  properties:
                    type:
                      const: DOG

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, this makes sense in the case of deeply nested schema structure. I think you should add a comment why it needs to be called that way 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this makes sense.

Shouldn't expand all work irrespective of schema being deeply nested ?

Copy link
Member

@AceTheCreator AceTheCreator left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that'll be all from my end... I'm happy to chat about how best to represent these rules constraints especially in number types 😄

expandAll();

expandAll();

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, this makes sense in the case of deeply nested schema structure. I think you should add a comment why it needs to be called that way 😄

@sonarqubecloud
Copy link

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

Successfully merging this pull request may close these issues.

2 participants