- Home
- F5 XC API Specs
- Development Guide
Development Guide
# Clone and install dev dependenciesgit clone https://github.com/f5xc-salesdemos/api-specs.gitcd api-specsmake dev-install
# Install Spectral CLI (required for linting stages)npm install -g @stoplight/spectral-climake dev-install creates a virtualenv in .venv/ and installs the project with dev extras (pytest, ruff, mypy).
Environment Variables
Section titled “Environment Variables”Live API validation requires:
export F5XC_API_URL="https://example-tenant.console.ves.volterra.io"export F5XC_API_TOKEN="your-api-token"Without these, make validate falls back to dry-run mode.
Running the Pipeline
Section titled “Running the Pipeline”Full Pipeline
Section titled “Full Pipeline”make all# Runs: download → validate → spectral-lint → reconcile → spectral-gate → releaseIndividual Stages
Section titled “Individual Stages”make download # Fetch upstream specsmake validate # Run live API tests (requires API token)make validate-dry # Dry run (no API calls)make spectral-lint # Spectral discover mode on original specsmake reconcile # Apply fixes from both reportsmake spectral-gate # Spectral quality gate on reconciled specsmake release # Build release packageDocumentation
Section titled “Documentation”make docs-generate # Regenerate docs/01-validation-report.mdx from reportsmake docs # Build full documentation sitemake docs-serve # Local dev server with hot reloadRunning Tests
Section titled “Running Tests”make test # pytest with coveragemake lint # ruff check + format checkmake typecheck # mypy type checkingmake ci-test # All three (used in CI)Pre-commit hooks run automatically on commit if installed:
make pre-commit-install # Install git hooksmake pre-commit # Run all hooks manuallyProject Structure
Section titled “Project Structure”scripts/ download.py # Stage 1: Fetch specs from F5 validate.py # Stage 2: Live API testing spectral_lint.py # Stage 3/5: Spectral linting adapter reconcile.py # Stage 4: Apply fixes to specs release.py # Stage 6: Package release generate_docs.py # Generate MDX from reports utils/ auth.py # F5 XC API authentication constraint_validator.py # Constraint testing + Discrepancy types report_generator.py # Report formatting schemathesis_runner.py # Schemathesis test orchestration spec_loader.py # Spec I/O + JSON formatting
config/ validation.yaml # Pipeline configuration endpoints.yaml # Baseline endpoints for live testing
spectral/ functions/ f5-path-params.js # Custom Spectral function
docs/ # Starlight MDX documentationtests/ # pytest test suiterelease/specs/ # Output: reconciled spec filesreports/ # Output: validation and Spectral reportsAdding a New Fix Method
Section titled “Adding a New Fix Method”To add a new Spectral auto-fix to the reconciler:
-
Add the rule to
.spectral.yamlwith the desired severity. -
Enable auto-fix in
config/validation.yamlunderspectral.auto_fix:spectral:auto_fix:your-new-rule: true -
Add the fixer method to
SpecReconcilerinscripts/reconcile.py:def _fix_your_rule(self, spec: dict, discrepancy: Discrepancy) -> dict | None:"""Fix description."""# Modify spec in place# Return spec if changed, None if no change neededreturn spec -
Register it in the
_apply_spectral_fixdispatcher:spectral_fixers = {# ... existing fixers ..."spectral:your-new-rule": self._fix_your_rule,} -
Add tests covering the new fix method.
Adding a New Spectral Rule
Section titled “Adding a New Spectral Rule”To add a custom Spectral rule with a JavaScript function:
-
Create the function in
spectral/functions/your-rule.js. Export a default function that receives(targetVal, options, context)and returns an array of{message, path}objects. -
Register it in
spectral-pipeline.yaml:functions:- f5-path-params- your-rulerules:your-rule:description: "What it checks"message: "{{error}}"severity: errorgiven: "$.paths[*]"then:function: your-rule
CI Pipeline
Section titled “CI Pipeline”The GitHub Actions workflow (validate-and-release.yml) runs on:
- Schedule: Daily at 6 AM UTC
- Push to main: When
scripts/,config/, orpyproject.tomlchanges - Manual dispatch: With options for forced release or dry-run
The workflow has four jobs:
- validate — Downloads specs, runs validation, Spectral lint, reconcile, Spectral gate
- check-release-needed — Compares content hashes to decide if a release is warranted
- release — Packages and creates a GitHub Release (only if content changed)
- update-docs — Regenerates
01-validation-report.mdxand opens a PR if changed
A notify job creates a GitHub issue if any job fails.
Branch and PR Workflow
Section titled “Branch and PR Workflow”All changes follow: Issue -> Branch -> PR -> CI passes -> Merge.
- Branch names:
feature/<issue>-desc,fix/<issue>-desc,docs/<issue>-desc - PRs must link an issue (
Closes #Nin the description) - Required CI checks:
Check linked issuesandLint Code Base - Squash merge preferred; branches auto-delete after merge
See CONTRIBUTING.md for the complete workflow rules.