Skip to content

feat(api-docs): adopt Scalar for interactive API documentation#790

Open
vcnainala wants to merge 4 commits into
developmentfrom
feat/scalar-api-documentation
Open

feat(api-docs): adopt Scalar for interactive API documentation#790
vcnainala wants to merge 4 commits into
developmentfrom
feat/scalar-api-documentation

Conversation

@vcnainala

Copy link
Copy Markdown
Member

Summary

  • Replace Swagger UI on /api-documentation with Scalar loaded from jsDelivr, including COCONUT branding (single header logo, black text, green accent).
  • Fix Lomkit OpenAPI generation so numeric HTTP status codes (e.g. 500, 401) are preserved instead of being mangled to 0 or "\"500\"", which caused Scalar to fail parsing the spec and ignore deep links such as #tag/advanced-search/post/api/search.
  • Update user-facing API documentation copy to refer to Scalar’s authentication UI instead of Swagger’s Authorize button.
  • Allow fonts.scalar.com in the Content Security Policy for Scalar’s default fonts.

Commits

  1. fix(api-docs): preserve HTTP status codes in OpenAPI response generation
  2. feat(api-docs): replace Swagger UI with Scalar reference UI
  3. docs(api-docs): update authentication instructions for Scalar UI

Test plan

  • Open http://localhost/api-documentation and confirm Scalar loads without console errors
  • Navigate directly to http://localhost/api-documentation#tag/advanced-search/post/api/search and confirm the Advanced Molecule Search operation is shown (not Introduction)
  • Verify a single COCONUT logo in the page header
  • Authenticate with a Sanctum Bearer token and run a protected endpoint
  • Run php artisan coconut:generate-api-docs and confirm public/vendor/rest/openapi.json keeps valid response keys (500, not 0)
  • Confirm no CSP violations for scripts, fonts, or connect-src in the browser console

vcnainala added 3 commits June 1, 2026 16:32
Lomkit's Responses::withOthers() used array_merge(), which reindexed
numeric keys such as 500 to 0 and broke Scalar's OpenAPI parser. Add a
custom Responses schema that merges with + instead, sanitize invalid
keys when generating docs, and regenerate the published specification.
Serve the Lomkit OpenAPI spec through Scalar on /api-documentation with
COCONUT branding, black body text, and a single header logo. Allow
fonts.scalar.com in the CSP for Scalar default web fonts.
Replace Swagger-specific wording with generic interactive API
documentation guidance for Bearer token authentication.
@codecov-commenter

codecov-commenter commented Jun 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 20.00000% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 6.13%. Comparing base (a4c26c6) to head (5028945).
⚠️ Report is 3 commits behind head on development.

Files with missing lines Patch % Lines
app/Documentation/Schemas/Responses.php 0.00% 6 Missing ⚠️
app/Providers/RestDocumentationServiceProvider.php 0.00% 2 Missing ⚠️
Additional details and impacted files
@@               Coverage Diff                @@
##             development    #790      +/-   ##
================================================
- Coverage           6.14%   6.13%   -0.02%     
- Complexity          1736    1739       +3     
================================================
  Files                227     228       +1     
  Lines               8945    8967      +22     
================================================
  Hits                 550     550              
- Misses              8395    8417      +22     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@vcnainala vcnainala requested a review from sriramkanakam87 June 1, 2026 16:04
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