Skip to content

feat: show example values and improve section spacing#60

Merged
rsbh merged 1 commit into
mainfrom
fix/api-overview-styling
May 13, 2026
Merged

feat: show example values and improve section spacing#60
rsbh merged 1 commit into
mainfrom
fix/api-overview-styling

Conversation

@rsbh
Copy link
Copy Markdown
Member

@rsbh rsbh commented May 13, 2026

Summary

  • Show example values from OpenAPI schema inline with field definitions (e.g., Example: "AOI-D2")
  • Increase divider margin between sections for better visual separation

Test plan

  • API page fields show example values when defined in spec
  • Fields without examples show nothing extra
  • Sections have visible spacing between dividers

🤖 Generated with Claude Code

@vercel
Copy link
Copy Markdown

vercel Bot commented May 13, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
chronicle Ready Ready Preview, Comment May 13, 2026 5:47am

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 13, 2026

Review Change Stack

Warning

Rate limit exceeded

@rsbh has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 42 minutes and 30 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 90fad74a-d61d-466a-a953-841540416e48

📥 Commits

Reviewing files that changed from the base of the PR and between 749f7ef and 34d8a96.

📒 Files selected for processing (6)
  • packages/chronicle/src/components/api/api-field-list.module.css
  • packages/chronicle/src/components/api/api-field-list.tsx
  • packages/chronicle/src/components/api/api-overview.module.css
  • packages/chronicle/src/components/api/api-overview.tsx
  • packages/chronicle/src/components/api/playground-dialog.tsx
  • packages/chronicle/src/lib/schema.ts
📝 Walkthrough

Walkthrough

This PR adds optional field example support to Chronicle's API documentation. The SchemaField interface gains an example property, schema flattening propagates examples from OpenAPI definitions, and the field list UI renders formatted examples with new styling. Divider spacing is also increased for improved layout.

Changes

Field example support

Layer / File(s) Summary
Schema example field and propagation
packages/chronicle/src/lib/schema.ts
SchemaField interface gains optional example?: unknown field; flattenSchema now propagates prop.example from OpenAPI schema properties into resulting flattened field descriptors.
Example display and layout styling
packages/chronicle/src/components/api/api-field-list.tsx, packages/chronicle/src/components/api/api-field-list.module.css, packages/chronicle/src/components/api/api-overview.module.css
FieldItem conditionally renders an "Example:" row with JSON-stringified example in a <code> element when field.example is defined; new .fieldExample and .fieldExample code CSS rules style the example display; .divider rule margin increased from var(--rs-space-2) to var(--rs-space-4).

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Suggested reviewers

  • rohanchkrabrty
  • rohilsurana
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the two main changes: displaying example values from OpenAPI schema and improving visual spacing between sections.
Description check ✅ Passed The description clearly explains both changes (showing example values and increasing divider spacing) and provides a test plan related to the implementation.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/api-overview-styling

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/chronicle/src/components/api/api-field-list.module.css (1)

39-45: ⚡ Quick win

Use design tokens for spacing/radius in code-chip styles.

padding: 1px ... and border-radius: 3px should be tokenized for consistency with the Apsara design system.

Proposed tokenized update
 .fieldExample code {
   font-family: var(--rs-font-mono);
   font-size: var(--rs-font-size-mono-small);
   background: var(--rs-color-background-neutral-secondary);
-  padding: 1px var(--rs-space-2);
-  border-radius: 3px;
+  padding: var(--rs-space-1) var(--rs-space-2);
+  border-radius: var(--rs-radius-1);
 }

As per coding guidelines, "Use CSS modules with Apsara design tokens for styling (e.g., --rs-color-*, --rs-font-*, --rs-space-*)."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/chronicle/src/components/api/api-field-list.module.css` around lines
39 - 45, The .fieldExample code rule currently uses hard-coded spacing and
radius (padding: 1px var(--rs-space-2); border-radius: 3px); update this rule to
use Apsara design tokens instead—replace the 1px vertical padding with the
appropriate spacing token (e.g., --rs-space-1) while keeping the horizontal
token (--rs-space-2), and replace the 3px radius with the appropriate radius
token (e.g., --rs-radii-1 or --rs-radius-small); edit the .fieldExample code
selector to use these tokens so spacing and border-radius follow the design
system.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/chronicle/src/components/api/api-field-list.module.css`:
- Around line 39-45: The .fieldExample code rule currently uses hard-coded
spacing and radius (padding: 1px var(--rs-space-2); border-radius: 3px); update
this rule to use Apsara design tokens instead—replace the 1px vertical padding
with the appropriate spacing token (e.g., --rs-space-1) while keeping the
horizontal token (--rs-space-2), and replace the 3px radius with the appropriate
radius token (e.g., --rs-radii-1 or --rs-radius-small); edit the .fieldExample
code selector to use these tokens so spacing and border-radius follow the design
system.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 3799471c-7e91-4407-9658-e58f52017ade

📥 Commits

Reviewing files that changed from the base of the PR and between ad10d6c and 749f7ef.

📒 Files selected for processing (4)
  • packages/chronicle/src/components/api/api-field-list.module.css
  • packages/chronicle/src/components/api/api-field-list.tsx
  • packages/chronicle/src/components/api/api-overview.module.css
  • packages/chronicle/src/lib/schema.ts

- Add example field to SchemaField from OpenAPI schema examples
- Display example values inline with field description
- Increase divider margin between sections for better readability

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
<span className={styles.fieldDescription}>{field.description}</span>
)}
{field.example !== undefined && (
<span className={styles.fieldExample}>Example: <code>{JSON.stringify(field.example)}</code></span>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

JSON.stringify wraps string examples in quotes, so a string example like active renders as Example: "active" with escaped double-quotes. For primitive types it'd look cleaner to show the raw value and only stringify objects/arrays.

Suggested change
<span className={styles.fieldExample}>Example: <code>{JSON.stringify(field.example)}</code></span>
<span className={styles.fieldExample}>Example: <code>{typeof field.example === 'object' ? JSON.stringify(field.example) : String(field.example)}</code></span>

<div className={styles.arrayField}>
<div className={styles.fieldRow}>
<span className={styles.fieldLabel}>{field.name}</span>
<span className={styles.fieldLabel}>{field.name} {field.required && <Badge variant="danger" size="micro">required</Badge>}</span>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The <Badge> component is nested inside a text <span> alongside the field name. In api-field-list.tsx you put the required badge inside a <Flex> container which handles alignment properly. Doing the same here would keep it consistent and avoid potential inline layout quirks.

Suggested change
<span className={styles.fieldLabel}>{field.name} {field.required && <Badge variant="danger" size="micro">required</Badge>}</span>
<span className={styles.fieldLabel}><Flex align="center" gap={2}>{field.name} {field.required && <Badge variant="danger" size="micro">required</Badge>}</Flex></span>

return (
<div className={styles.fieldRow}>
<span className={styles.fieldLabel}>{field.name}</span>
<span className={styles.fieldLabel}>{field.name} {field.required && <Badge variant="danger" size="micro">required</Badge>}</span>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same as above - wrapping in <Flex> would be more consistent with how the required badge is rendered in the field list.

Suggested change
<span className={styles.fieldLabel}>{field.name} {field.required && <Badge variant="danger" size="micro">required</Badge>}</span>
<span className={styles.fieldLabel}><Flex align="center" gap={2}>{field.name} {field.required && <Badge variant="danger" size="micro">required</Badge>}</Flex></span>

required: required.includes(name),
description: rawProp.description ?? prop.description,
default: prop.default,
example: prop.example,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice addition. One gap though: paramsToFields in api-overview.tsx (and playground-dialog.tsx) doesn't pass example through when building SchemaField objects from ParameterObjects. So path/query params that have examples defined in the OpenAPI spec won't display them - only request body fields will. Worth adding example: p.example ?? schema.example in paramsToFields to be consistent.

@rsbh rsbh merged commit 3421242 into main May 13, 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