Files
brunoandClaude Sonnet 4.5 0a91cb0677 feat(openspec): integrate OpenSpec 0.17.2 for API-first development
Integrate OpenSpec with complete OpenAPI-first development workflow:

**Configuration Files:**
- Add package.json with npm scripts for spec validation
- Add .openspec.yaml for validation rules (strict mode)
- Add .spectral.yaml for OpenAPI linting (100+ rules)
- Add openapi.yaml with initial API specification

**Automation:**
- Add scripts/generate-openapi-spec.py to auto-generate spec from FastAPI
- Add .claude/hooks/pre-commit-openspec.sh for pre-commit validation
- Add .github/workflows/openspec-validation.yml for CI/CD validation

**Documentation:**
- Add docs/workflows/openspec-development-workflow.md (500+ lines workflow guide)
- Add OPENSPEC-SETUP.md (quick start guide)
- Add README-OPENSPEC-INTEGRATION.md (integration summary)
- Update .claude/CLAUDE.md with OpenSpec commands and 9-step workflow

**Features Enabled:**
- OpenAPI-first development (design before code)
- Automatic spec validation on commit
- Breaking change detection in PRs
- Bidirectional sync between spec and code
- Spectral linting with 100+ best practice rules
- Auto-generated API documentation

**Validation Rules:**
- Require operationId, tags, descriptions on all operations
- Require 4xx and 5xx error responses
- Enforce naming conventions (kebab-case paths, PascalCase schemas)
- Require /health and /metrics endpoints (observability)

**Commands Available:**
- npm run spec:validate - Validate OpenAPI spec
- npm run spec:lint - Lint with Spectral
- npm run spec:generate - Generate from FastAPI
- npm run spec:sync - Generate + validate
- npm run spec:diff - Detect breaking changes
- npm run spec:watch - Auto-regenerate on changes

**Breaking Changes:** None (new feature)

**Next Steps:**
1. Run: npm install
2. Run: npm run spec:generate
3. Run: npm run spec:validate
4. Enable pre-commit hook: ln -sf ../../.claude/hooks/pre-commit-openspec.sh .git/hooks/pre-commit

Closes #7 (partially - Claude Configuration optimization)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-31 23:25:52 +08:00

30 lines
861 B
JSON

{
"name": "gold-template",
"version": "1.0.0",
"description": "Production-ready FastAPI template with OpenSpec-driven development",
"private": true,
"scripts": {
"spec:validate": "openspec validate openapi.yaml",
"spec:lint": "openspec lint openapi.yaml",
"spec:generate": "python3 scripts/generate-openapi-spec.py",
"spec:diff": "openspec diff openapi.yaml openapi.yaml.backup",
"spec:sync": "npm run spec:generate && npm run spec:validate",
"spec:watch": "nodemon --watch backend --ext py --exec 'npm run spec:sync'",
"precommit": "npm run spec:validate"
},
"devDependencies": {
"@stoplight/spectral-cli": "^6.11.0",
"nodemon": "^3.0.2"
},
"dependencies": {},
"keywords": [
"fastapi",
"openapi",
"openspec",
"api-first",
"python"
],
"author": "DevOps Team",
"license": "MIT"
}