azure-openapi-validator
Copilot instructions53 starsChanged 5 years agoMITView on GitHub
This is azure-openapi-validator (aka LintDiff), a linter for Azure OpenAPI specifications. It is an extension of AutoRest and supports Spectral lint rule format. The repository contains automated linter rules that apply to API specs in the azure-rest-api-specs repository. This is a monorepo managed by Rush.js with the following main packages:
- Installs packages
The file
Show its rules and text
We split this copilot-instructions.md into the rules it gives an agent
19 rules. About 0 are common, 10 are distinctive, and 9 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈10
Distinctive · estimate
This author's own choices. Worth a look.
9
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 56
Ensure branch is based on up-to-date main
- Very specific: line 57
Run rush prep - this will execute all necessary checks
- Very specific: line 58
If adding/modifying rules, run rush regen-ruleindex to update docs/rules.md
- Very specific: line 59
Run rush change and follow prompts to generate changelog entries
- Distinctive: line 63
Add the new rule with appropriate severity and documentation
- Very specific: line 64
Add a label to your PR in the format test-<RuleName> to trigger the staging-lint check pipeline
- Distinctive: line 65
Verify the rule works correctly by checking the staging-lint check results
- Very specific: line 76
Import helpers from tslib (set noEmitHelpers: true, importHelpers: true)
- Distinctive: line 83
Use existing libraries when possible
- Distinctive: line 84
Prefer clear, descriptive variable names
- Very specific: line 87
Important: After calling Workspace.resolveRef(), always check both !source and !source.value since the function's return type is …
- Distinctive: line 100
When writing validation rules:
- Very specific: line 104
Follow existing rule patterns in packages/rulesets/src/
- Very specific: line 119
Add a label to your PR in format test-<RuleName> (e.g., test-ProvisioningStateSpecifiedForLROPut)
- Distinctive: line 122
Check the workflow results and linter-findings artifact to validate rule behavior
- Distinctive: line 137
Follow instructions in CONTRIBUTING.md under "How to locally reproduce a LintDiff failure"
- Very specific: line 149
All rules should have documentation in docs/ directory.
- Distinctive: line 164
Create release PR with changelog
- Distinctive: line 167
Verify deployment using CloudMine/Kusto queries
≈ “Common” is an estimate: at least 1 in 5 of the 1,644 Copilot instructions files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
GitHub Copilot Instructions for azure-openapi-validator
Project Overview
This is azure-openapi-validator (aka LintDiff), a linter for Azure OpenAPI specifications. It is an extension of AutoRest and supports Spectral lint rule format. The repository contains automated linter rules that apply to API specs in the azure-rest-api-specs repository.
Architecture
This is a monorepo managed by Rush.js with the following main packages:
packages/azure-openapi-validator/core- Core functionality (@microsoft.azure/openapi-validator-core)packages/azure-openapi-validator/autorest- AutoRest extension (@microsoft.azure/openapi-validator)packages/rulesets- Ruleset implementations (@microsoft.azure/openapi-validator-rulesets)src/spectral/- Spectral format rulessrc/native/- Native TypeScript rules
regression- Regression tests
Build and Test Commands
Prerequisites
- Node.js >= 18.0.0 (some packages like rulesets require >= 20)
- Rush.js (
npm install -g @microsoft/rush)
Essential Commands
Build:
rush update # Install dependencies
rush build # Build all projectsTest:
rush test # Run all tests
npx jest --config packages/rulesets/jest.native.config.js # Native tests only (in packages/rulesets)
npx jest --config packages/rulesets/jest.config.js # Spectral tests only (in packages/rulesets)Lint:
rush lint # Run linter on all projects
rush lint:fix # Auto-fix linting issuesOther:
rush prep # Complete pre-PR workflow: update, build, lint, test, regen-ruleindex, change
rush regen-ruleindex # Regenerate docs/rules.md after rule changes
rush change # Generate Rush changelog entries
rush regression-test # Run regression testsDevelopment Workflow
Before Submitting a PR
- Ensure branch is based on up-to-date
main - Run
rush prep- this will execute all necessary checks - If adding/modifying rules, run
rush regen-ruleindexto updatedocs/rules.md - Run
rush changeand follow prompts to generate changelog entries - For significant changes, manually update
changelog.md
Adding New Linter Rules
- Add the new rule with appropriate severity and documentation
- Add a label to your PR in the format
test-<RuleName>to trigger the staging-lint check pipeline - Verify the rule works correctly by checking the staging-lint check results
- Iterate on the rule based on validation results until it works as expected
- Once the PR is merged, the rule is automatically deployed and released
Coding Conventions
TypeScript
- Target: ES2019
- Module: CommonJS
- Strict null checks enabled
- No implicit any
- Import helpers from tslib (set
noEmitHelpers: true,importHelpers: true)
Code Style
- Prettier configured as auto-formatter
- No semicolons (
semi: false) - Print width: 140 characters
- No semicolons (
- ESLint enforced - all projects must pass
rush lintwith--max-warnings=0 - Use existing libraries when possible
- Prefer clear, descriptive variable names
Null Safety Pattern
Important: After calling Workspace.resolveRef(), always check both !source and !source.value since the function's return type is EnhancedSchema | undefined, and the value property can be undefined when the $ref target doesn't exist.
Example:
const source = Workspace.resolveRef(enhancedSchema, inventory)
if (!source || !source.value) {
// Handle undefined case
return
}
// Safe to use source.valueRule Properties
When writing validation rules:
- Provide clear error messages
- Include documentation links
- Set appropriate severity (error/warning/info)
- Follow existing rule patterns in
packages/rulesets/src/
Testing
- Jest is used for testing
- Spectral tests are in
packages/rulesets/src/spectral/test/ - Native tests are in
packages/rulesets/src/native/tests/and match*-test(s).ts - Coverage threshold: ≥80% statement coverage for
src/spectral/functions/*.ts - Native tests use
jest.native.config.js - Spectral tests use
jest.config.js
Common Tasks
Testing Rules with Staging-Lint Check
The .github/workflows/staging-lint-checks.yaml workflow allows you to test specific rules:
- Add a label to your PR in format
test-<RuleName>(e.g.,test-ProvisioningStateSpecifiedForLROPut) - You can also specify rules in the PR body:
rules: RuleName1, RuleName2 - The workflow runs selected rules against a subset of Azure REST API specs
- Check the workflow results and linter-findings artifact to validate rule behavior
Running Locally from Source
See CONTRIBUTING.md section "How to run LintDiff locally from source"
Setting Rule to Staging Only (Legacy)
The stagingOnly: true property in Spectral rules still exists but the deployment process has evolved. For new rules, use the staging-lint check workflow (above) to validate before production deployment. See CONTRIBUTING.md section "How to set a Spectral rule to run only in staging" for details on the stagingOnly property.
Regenerating Rules Documentation
rush regen-ruleindexThis updates docs/rules.md with the current rules index.
Reproducing LintDiff Failures
Follow instructions in CONTRIBUTING.md under "How to locally reproduce a LintDiff failure"
Important Files
rush.json- Monorepo configurationcommon/config/rush/command-line.json- Custom Rush commandsdocs/rules.md- Generated index of all rules (regenerate withrush regen-ruleindex)CONTRIBUTING.md- Detailed contribution guidelines (41KB+)changelog.md- Project changelog
Documentation
All rules should have documentation in docs/ directory. When adding a new rule, create a corresponding .md file in docs/ with:
- Rule description
- Examples of violations
- Examples of correct usage
- Links to relevant Azure API guidelines
Dependencies
- Rush.js uses pnpm (v8.15.7) as the underlying package manager (configured in rush.json)
- Strict peer dependencies enabled
- Node.js >= 18.0.0 supported by Rush (individual packages like rulesets may require >= 20)
Deployment
Changes merge to main deploy to staging LintDiff. For production deployment:
- Create release PR with changelog
- Tag release
- Build and publish to npm
- Verify deployment using CloudMine/Kusto queries
See CONTRIBUTING.md "How to deploy your changes" for detailed instructions.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

