Skip to content

Comments

@W-20141096 Adapt type document to properly display response messages#89

Merged
alexpmule merged 8 commits intomainfrom
W-20141096/Adopt-type-document-to-Properly-Display-Response-Messages
Jan 6, 2026
Merged

@W-20141096 Adapt type document to properly display response messages#89
alexpmule merged 8 commits intomainfrom
W-20141096/Adopt-type-document-to-Properly-Display-Response-Messages

Conversation

@alexpmule
Copy link
Contributor

@alexpmule alexpmule commented Dec 29, 2025

Recent Improvements

Enhanced gRPC Support

The component now includes comprehensive support for gRPC APIs with performance optimizations:

Deep Link Resolution

AMF represents complex types using link-target references that point to type definitions elsewhere in the model. In gRPC APIs, nested message types often use multiple levels of these references.

The Challenge: Previously, only the first level of link-target references was resolved. When rendering examples or nested properties, deeper references remained unresolved, appearing as empty objects {} in the UI.

The Solution: A new _deepResolveType() method recursively resolves all link-target references:

  1. Traverses the type's property tree
  2. For each property with a link-target, locates the target definition in declares or references[].declares
  3. Recursively resolves nested properties within the target
  4. Returns a fully resolved type structure with all nested objects expanded

This ensures complex gRPC message structures display their complete property hierarchy in both the properties panel and generated examples.

Performance Caching System

To prevent unnecessary re-renders and expensive recalculations on every render cycle, a lightweight caching system was implemented:

Cached Property Purpose When Updated
_computedProperties Stores computed properties for object types When type, amf, or renderReadOnly changes
_resolvedExampleType Deep-resolved type for example generation Once per type in _typeChanged()
_showExamples Whether to render the examples section Based on isObject, noMainExample, renderMediaSelector
_exampleMediaType Effective media type for examples Defaults to application/json for objects

These values are computed in _typeChanged() and updated() lifecycle methods, ensuring render() uses pre-computed values instead of recalculating on every render call.

Automatic Example Generation

Objects without explicit mediaType (common in gRPC) now default to application/json, enabling the api-resource-example-document component to automatically generate examples from the type schema.


Screen.Recording.2025-12-29.at.3.55.43.PM.mov

- Added @advanced-rest-client/icons version 4.0.2.
- Updated @api-components/amf-helper-mixin to version 4.5.34.
- Introduced grpc-test.json for gRPC testing configurations.
- Updated .gitignore to include grpc-test.json for tracking purposes.
…ution for examples

- Added new computed properties for managing resolved types and rendering examples.
- Implemented a deep resolution method to handle link-target references for example generation.
- Updated the updated lifecycle method to recalculate properties based on changes in relevant attributes.
- Improved example rendering logic by utilizing cached values for better performance.
…deep resolution method

- Introduced new reactive properties for managing computed types and rendering examples.
- Added a method for deeply resolving link-target references to enhance example generation.
- Updated documentation for new properties and methods to clarify their usage.
…ctive properties

- Implemented comprehensive tests for gRPC functionality in ApiTypeDocument.
- Added tests for deep resolution of link-target references and nested properties.
- Enhanced example rendering tests to ensure correct behavior with gRPC payloads.
- Verified reactive updates of computed properties when type and AMF change.
@alexpmule alexpmule self-assigned this Dec 29, 2025
… and consistency

- Renamed cached properties to more accurately reflect their purpose: _cachedDeepResolvedType to _resolvedExampleType, _cachedShouldRenderExamples to _showExamples, and _cachedExampleMediaType to _exampleMediaType.
- Updated logic for determining whether to show examples, improving readability and maintainability.
- Adjusted related tests to ensure compatibility with the new property names and logic.
@alexpmule alexpmule merged commit 6979556 into main Jan 6, 2026
4 checks passed
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.

3 participants