This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.
- Contributing
Table of contents generated with yzhang.markdown-all-in-one
To execute any instructions in this file, first ensure you fulfill all the following prerequisites:
- Install Node.js, version 14.x or higher.
- Install .NET runtime and SDK, version 6 or higher.
- Install .NET CLI tools version 2.0.0 or higher.
- Execute all commands in this file from your
openapi-diffgit repo local clone root dir. - Run
npm cito install the required node modules.
openapi-diff is composed both of TypeScript and .NET/C# projects, all of which have to be built
to be able to run the tool locally from sources.
The core logic for openapi-diff is written in C# and compiled to a .NET binary.
The CLI for openapi-diff is written in TypeScript and compiled to a Node.js binary.
| Build command | Effect |
|---|---|
npm run dn.build |
Runs dotnet build and related commands to build the C# code. |
npm run tsc |
Builds the TypeScript code. |
For more commands, see the package.json scripts element.
Notably:
| Command | Effect |
|---|---|
npm run dn.restore |
Runs dotnet restore in preparation to build the C# code. |
npm run dn.test |
Runs dotnet test and related commands to test the C# code. |
If the npm run dn.build command outputs error like:
C:\Program Files\dotnet\sdk\8.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targe ts(266,5): error NETSDK1005: Assets file 'C:(...)\openapi-diff\src\core\OpenApiDiff\ob j\project.assets.json' doesn't have a target for 'netcoreapp6.0'. Ensure that restore has run and that you have included 'netcoreapp6.0' in the TargetFrameworks for your project.
Then first run npm run dn.restore and then run the npm run dn.build command again.
After you have built the C# and TypeScript code, you can run the openapi-diff aka oad tool locally.
- Run
npm linkonce. - Then you can use
oadby runningoad -h.
Caution
Following commands have different behavior: oad, oad -h, oad --help.
As of 11/2/2023 only oad -h appears to work as intended.
If Swagger BreakingChange or BreakingChange(Cross-Version) checks fail on your Azure/azure-rest-api-specs[-pr] PR,
you can reproduce the failure locally as follows:
- Open the GitHub check pane.
- Click the hyperlinked
View Azure DevOps build log for more details.Open the relevant job (BreakingChangeorCrossVersionBreakingChange) and a task within the job with the same name. Search for logENTER definition runOad. This log will show you theoldSpecandnewSpecvalues, which you can pass as input tooadwhen running it locally, per Runoadlocally from sources. Note you will have to clone locally relevant git branches with the specs.
You can also install the oad tool globally and run it from anywhere.
npm list -g @azure/oad # verify oad is not installed globally
npm install -g # Install oad from local repo clone source
npm list -g @azure/oad # verify oad is installed
oad --version # verify correct version got installed.
oad -hCaution
Be careful to use @azure/oad and not oad as the latter is an obsolete, deprecated package.
Tip
If you want to install oad not from your local sources, but the latest from the npm feed,
use this alternative npm install:
npm install -g @azure/oad
To uninstall oad globally:
# if installed from sources
npm uninstall -g
# if installed from npm feed
npm uninstall -g @azure/oadTo purge the obsolete, deprecated oad package from your system, including the cache.
# To remove oad from the cache
npm cache ls oad
npm cache clean <copy paste here entries from "ls oad"> # run once per each entry from "ls oad"
npm cache verify # to fix the cache after removing oad
# To remove oad from the local node_modules
npm uninstall oad
npm list oad # Should denote no packages installed
# To remove oad from the global node_modules
npm uninstall -g oad
npm list -g oad # Should denote no packages installed- Ensure you bumped the package version in
openapi-diffpackage.json. - Queue a run of the
openapi-diffpipeline and approve thepublishstage. (Note: there is also thepublic.openapi-diffpipeline for CI checks.) - Verify in
@azure/oadversions that the newest package version was published on npmjs.org. You can also runnpm show @azure/oad. - Create a PR to
azure-rest-api-specs, updating all references to@azure/oadinpackage[-lock].json