This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] 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-diff
git repo local clone root dir. - Run
npm ci
to 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 link
once. - Then you can use
oad
by 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 (BreakingChange
orCrossVersionBreakingChange
) and a task within the job with the same name. Search for logENTER definition runOad
. This log will show you theoldSpec
andnewSpec
values, which you can pass as input tooad
when running it locally, per Runoad
locally 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 -h
Caution
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/oad
To 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-diff
package.json
. - Queue a run of the
openapi-diff
pipeline and approve thepublish
stage. (Note: there is also thepublic.openapi-diff
pipeline for CI checks.) - Verify in
@azure/oad
versions that the newest package version was published on npmjs.org. You can also runnpm show @azure/oad
. - Save it to
openapi-platform
feed via upstream feeds ofopenapi-platform
.- For the desired version, you must click
Save to feed
in the context menu of the hidden triple-dot button on the right. It will reveal on hover. - You may need to wait a bit until the newest version shows up in the
Upstream Versions
tab.
- For the desired version, you must click
- To make
openapi-alps
use the newly published package:- Ensure that you update the minimum package version in relevant
package.json
files and then runrush update
and commit the changes. - ❗ Do the update even if semver rules say the new package version is in scope. E.g. if the version is
~0.10.7
but you published0.10.8
, then still update the entry to~0.10.8
. - If you will not modify any
package.json
at all, rush will not recognize the newly published package version. This can be worked around by runningrush update --full
, but this is discouraged. - Example file:
private/azure-swagger-validation/azureSwaggerValidation/package.json
. - Example
openapi-alps
PR doing the package update: #537791.
- Ensure that you update the minimum package version in relevant
- Redeploy relevant
openapi-alps
parts to pick up the new package, even if you didn't had to commit any changes. Follow this doc.