Skip to content

refactor(library): modularize Schema component and extract sub-components#1244

Closed
techmannih wants to merge 1 commit intoasyncapi:masterfrom
techmannih:mod
Closed

refactor(library): modularize Schema component and extract sub-components#1244
techmannih wants to merge 1 commit intoasyncapi:masterfrom
techmannih:mod

Conversation

@techmannih
Copy link

Description

Changes proposed in this pull request:

  • Modularized the Schema component: Created a dedicated library/src/components/Schema/ directory to house the complex schema rendering logic.
  • Extracted sub-components: Moved SchemaProperties, AdditionalProperties, SchemaItems, and AdditionalItems into separate, focused files to improve code readability and reduce cognitive complexity in the main component.
  • Decoupled State Management: Moved SchemaContext to a dedicated SchemaContext.tsx file for better state isolation and cleaner component files.
  • Refined Export Strategy: Implemented an index.ts within the Schema directory and updated the components' main entry point to maintain backward compatibility for existing imports.
  • Verified with Unit Tests: Updated and passed all tests in Schema.test.tsx (Circular references, boolean defaults, and array rendering) ensuring no regressions were introduced.

Related issue(s)

Testing Results

 PASS  library/src/components/__tests__/Schema.test.tsx
  Schema component
    ✓ should work with true schema (24 ms)
    ✓ should work with false schema (4 ms)
    ✓ should work with circular references in schema (29 ms)
    should render boolean values
      ✓ defined as defaults (9 ms)
      ✓ defined as const (9 ms)
    should render arrays
      ✓ which includes oneOf (31 ms)

@sonarqubecloud
Copy link

@techmannih
Copy link
Author

hey @AceTheCreator Can I get your review.
thanks!

@AceTheCreator
Copy link
Member

Sorry, closing this PR. A PR doing exactly this already exists :(

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