Skip to content

Add openapi-to-frontend plugin#109

Draft
rbren wants to merge 8 commits intomainfrom
add-openapi-to-frontend-plugin
Draft

Add openapi-to-frontend plugin#109
rbren wants to merge 8 commits intomainfrom
add-openapi-to-frontend-plugin

Conversation

@rbren
Copy link

@rbren rbren commented Mar 15, 2026

Summary

This PR adds a new plugin that generates a full TypeScript client, React component library, and frontend app from an OpenAPI specification.

Features

Five Generation Phases

  1. Generate Client (skills/generate-client/) — Creates TypeScript types, API class with typed methods, and auth handlers
  2. Generate Components (skills/generate-components/) — Creates React Form, Detail, and List components for each schema
  3. Generate Frontend (skills/generate-frontend/) — Creates a complete React app with routing, context providers, and pages
  4. Generate Tests (skills/generate-tests/) — Creates unit, integration, and e2e tests with mock factories
  5. Generate CI (skills/generate-ci/) — Creates GitHub Actions workflows for build, test, deploy, and publish

Incremental Updates

The update-from-spec skill makes surgical edits when the OpenAPI spec changes, rather than regenerating everything. It uses the spec-differ agent to classify changes and apply targeted modifications.

Authentication Support

Supports three auth patterns:

  • API Key — Header or query parameter
  • Bearer Token — JWT or opaque tokens
  • OAuth2 — Authorization code flow with PKCE, auto-refresh

E2E Backend Strategy

The test generation intelligently detects how to start the backend for e2e tests:

  1. Docker Compose (if available)
  2. Language-specific entrypoint detection
  3. Prism mock server from spec
  4. External URL fallback

Plugin Structure

plugins/openapi-to-frontend/
├── README.md
├── commands/
│   └── generate-all.md              # Slash command for full generation
├── skills/
│   ├── generate-client/SKILL.md
│   ├── generate-components/SKILL.md
│   ├── generate-frontend/SKILL.md
│   ├── generate-tests/SKILL.md
│   ├── generate-ci/SKILL.md
│   └── update-from-spec/SKILL.md
├── agents/
│   └── spec-differ.md               # Subagent for spec diffing
├── scripts/
│   ├── parse-openapi.py             # Spec parsing utility
│   ├── lint-generated.sh            # Code quality checks
│   ├── verify-coverage.py           # Spec vs client verification
│   └── verify-components.py         # Client vs components verification
├── references/
│   ├── auth-patterns.md
│   ├── naming-conventions.md
│   └── change-taxonomy.md
└── hooks/
    └── hooks.json                   # Reserved for future use

Marketplace Entry

Added to marketplaces/default.json with keywords: openapi, swagger, typescript, react, codegen, frontend, api, client

Checklist

  • Plugin follows repository conventions from AGENTS.md
  • All skills have SKILL.md with proper frontmatter
  • Reference documentation is complete
  • Utility scripts are executable
  • Marketplace entry added

This plugin generates a full TypeScript client, React component library,
and frontend app from an OpenAPI specification.

Features:
- Phase 1: Generate TypeScript client (types, API class, auth handlers)
- Phase 2: Generate React components (Form, Detail, List per schema)
- Phase 3: Generate React frontend app (routing, context, pages)
- Phase 4: Generate comprehensive tests (unit, integration, e2e)
- Phase 5: Generate GitHub Actions CI/CD workflows

Additional capabilities:
- Incremental updates when spec changes (surgical edits, not regeneration)
- Support for API Key, Bearer Token, and OAuth2 authentication
- E2E backend strategy detection (Docker, mock server, external URL)
- Verification scripts for coverage and component completeness

Co-authored-by: openhands <openhands@all-hands.dev>
- Uses OpenHands CLI in headless mode via Docker
- Snapshots OpenAPI spec to track changes between runs
- Initial run: generates full codebase
- Subsequent runs: applies incremental updates
- Creates PR with generated/updated code

Co-authored-by: openhands <openhands@all-hands.dev>
- Install via uv tool install openhands
- Run with openhands --headless -t for automation
- Configure via ~/.openhands/settings.json

Co-authored-by: openhands <openhands@all-hands.dev>
- Clones OpenHands/extensions repo to get the plugin
- Installs plugin to ~/.openhands/plugins/
- OPENHANDS_EXTENSIONS_BRANCH variable defaults to 'main'
- Task prompts now reference the installed plugin paths

Co-authored-by: openhands <openhands@all-hands.dev>
- Rename command from generate-all.md to openapi-to-frontend.md
- Single command handles both initial generation and incremental updates
- Usage: /openapi-to-frontend new-spec.json [old-spec.json]
- GitHub Action prompts now just reference the command file
- All detailed instructions moved into the command itself

Co-authored-by: openhands <openhands@all-hands.dev>
- Use correct settings.json format with LLM_MODEL, LLM_API_KEY, etc.
- Default to ANTHROPIC_API_KEY secret and claude-opus-4-20250514 model
- Add LLM_BASE_URL for custom API endpoints
- Document how to use different LLM providers
- Settings now properly created before running headless mode

Co-authored-by: openhands <openhands@all-hands.dev>
- Remove settings.json file generation (not needed)
- Use --override-with-envs flag with LLM_API_KEY and LLM_MODEL env vars
- This is the correct way to configure OpenHands CLI in headless mode
- Update configuration docs to explain env vars approach

Co-authored-by: openhands <openhands@all-hands.dev>
@rbren
Copy link
Author

rbren commented Mar 15, 2026

@OpenHands change the github action example in README.md to revert any changes to the .github/ directory before trying to push and open a PR

@openhands-ai
Copy link

openhands-ai bot commented Mar 15, 2026

I'm on it! rbren can track my progress at all-hands.dev

The generated CI workflows could overwrite the sync-openapi workflow itself.
This step ensures the .github/ directory is restored before pushing changes.

Co-authored-by: openhands <openhands@all-hands.dev>
Copy link
Author

rbren commented Mar 15, 2026

Fixed in commit 6a0b87d. Added a step to revert any changes to the .github/ directory before pushing and creating the PR. This ensures that the generated CI workflows don't overwrite the sync-openapi workflow itself.

@openhands-ai
Copy link

openhands-ai bot commented Mar 15, 2026

Summary

I've successfully addressed the PR comment requesting that the GitHub Action example in README.md revert changes to the .github/ directory before pushing and opening a PR.

Checklist

  • ✅ Added a new step "Revert changes to .github directory" to the sample workflow in plugins/openapi-to-frontend/README.md
  • ✅ Step runs git checkout HEAD -- .github/ to restore the .github/ directory before PR creation
  • ✅ Step has the same conditional (if: steps.check-mode.outputs.mode == 'initial' || steps.check-changes.outputs.changed == 'true') as surrounding steps
  • ✅ Step is positioned between "Update spec snapshot" and "Create Pull Request" steps
  • ✅ Changes are concise (only 6 lines added)
  • ✅ Changes committed and pushed to add-openapi-to-frontend-plugin branch
  • ✅ Left a comment on the PR acknowledging the fix

Changes Made

+      - name: Revert changes to .github directory
+        if: steps.check-mode.outputs.mode == 'initial' || steps.check-changes.outputs.changed == 'true'
+        run: |
+          git checkout HEAD -- .github/ 2>/dev/null || true
+          echo "🔄 Reverted any changes to .github/ directory"

Commit: 6a0b87d - "Add step to revert .github/ changes before PR creation"

PR: #109

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