|
| 1 | +# Copilot Instructions |
| 2 | + |
| 3 | +## Project Overview |
| 4 | + |
| 5 | +This repository contains the source code for `openapi-diff` (aka `oad`, aka `@azure/oad`), a breaking-change |
| 6 | +detector tool for OpenAPI specifications. It is published as an npm package and is used internally by the |
| 7 | +[azure-rest-api-specs](https://github.com/Azure/azure-rest-api-specs) and |
| 8 | +[azure-rest-api-specs-pr](https://github.com/Azure/azure-rest-api-specs-pr) repos to validate PRs. |
| 9 | + |
| 10 | +The core diff logic is written in C#/.NET and the CLI/validation layer is written in TypeScript. |
| 11 | + |
| 12 | +## Tech Stack |
| 13 | + |
| 14 | +- **TypeScript** (ES2017 target, CommonJS modules) — CLI, validation, and test code in `src/` |
| 15 | +- **C#/.NET 6** — core diff engine in `openapi-diff/` |
| 16 | +- **Node.js 20+** |
| 17 | +- **Jest** with `ts-jest` for TypeScript tests |
| 18 | +- **ESLint** (`typescript-eslint`) for linting |
| 19 | +- **Prettier** for formatting |
| 20 | +- **markdownlint** for Markdown style |
| 21 | + |
| 22 | +## Setup |
| 23 | + |
| 24 | +```sh |
| 25 | +npm ci # Install Node.js dependencies |
| 26 | +npm run dn.restore # Restore .NET dependencies (if working on C# code) |
| 27 | +``` |
| 28 | + |
| 29 | +## Build |
| 30 | + |
| 31 | +```sh |
| 32 | +npm run tsc # Build TypeScript code (outputs to dist/) |
| 33 | +npm run dn.build # Build C# code |
| 34 | +``` |
| 35 | + |
| 36 | +## Lint and Format |
| 37 | + |
| 38 | +```sh |
| 39 | +npm run lint # Run ESLint (zero warnings allowed) |
| 40 | +npm run lint:fix # Auto-fix ESLint issues |
| 41 | +npm run prettier # Check formatting with Prettier |
| 42 | +npm run prettier:write # Auto-fix formatting |
| 43 | +``` |
| 44 | + |
| 45 | +## Test |
| 46 | + |
| 47 | +```sh |
| 48 | +npm run ts.test # Run TypeScript tests (Jest) |
| 49 | +npm run dn.test # Run C# tests (dotnet test) |
| 50 | +npm test # Run both C# and TypeScript tests |
| 51 | +``` |
| 52 | + |
| 53 | +TypeScript tests live in `src/test/` and follow the naming pattern `*[tT]est.ts`. |
| 54 | + |
| 55 | +## Code Conventions |
| 56 | + |
| 57 | +- **No semicolons** — Prettier is configured with `"semi": false` |
| 58 | +- **Print width** is 140 characters |
| 59 | +- **Trailing commas** are not used (`"trailingComma": "none"`) |
| 60 | +- **Arrow function parentheses** are avoided when possible (`"arrowParens": "avoid"`) |
| 61 | +- **Strict TypeScript** — `tsconfig.json` has `"strict": true` |
| 62 | +- **ESLint config** is in `eslint.config.js` (CommonJS format, not ESM) |
| 63 | +- **Markdown line length** limit is 120 characters (tables and headings are exempt) |
| 64 | +- Prefer `const` over `let` where possible |
| 65 | + |
| 66 | +## Repository Structure |
| 67 | + |
| 68 | +``` |
| 69 | +src/ |
| 70 | + cli.ts # CLI entry point |
| 71 | + index.ts # Package entry point |
| 72 | + lib/ |
| 73 | + commands/ # Command implementations |
| 74 | + util/ # Utility modules |
| 75 | + validate.ts # Validation logic |
| 76 | + validators/ # Validator implementations |
| 77 | + test/ # TypeScript tests (Jest) |
| 78 | + specs/ # Test fixture OpenAPI spec files |
| 79 | +openapi-diff/ # C#/.NET solution (core diff engine) |
| 80 | +docs/ # Documentation |
| 81 | +``` |
| 82 | + |
| 83 | +## CI |
| 84 | + |
| 85 | +CI runs on both Ubuntu and Windows via GitHub Actions (`.github/workflows/ci.yml`). It runs: |
| 86 | +`npm run lint`, `npm run prettier`, and `npm test` (which includes both C# and TypeScript tests). |
| 87 | + |
| 88 | +## Guidelines |
| 89 | + |
| 90 | +- Run `npm run lint` and `npm run prettier` before submitting changes. |
| 91 | +- Add or update tests in `src/test/` for any TypeScript code changes. |
| 92 | +- Do not modify CI/CD pipeline files (`.github/workflows/`, `azure-pipelines.yml`) unless specifically required. |
| 93 | +- When working only on TypeScript, use `npm run ts.test` to run just the TypeScript tests. |
0 commit comments