Generate and diff openAPI specs in dotnet
Setup generation of open api spec json
Using swashbuckle
dotnet add package Swashbuckle.AspNetCore.Swagger
dotnet tool install --global Swashbuckle.AspNetCore.Cli
dotnet build
Generate openAPI spec
dotnet build
swagger tofile --output "openapi.json" bin/Debug/net8.0/bkr-provider-api.dll [version]
# e.g
swagger tofile --output "openapi.json" bin/Debug/net8.0/bkr-provider-api.dll v1
OpenAPI diff
https://github.com/OpenAPITools/openapi-diff
Compare two openAPI specs to find breaking changes in the contract.
openapi-diff <old> <new>
# two openapi specs from files
docker run --rm -v ${PWD}:/spec openapitools/openapi-diff /spec/openapi_v4.json /spec/openapi_v5.json
# spec from url. host.docker.internal points to host locahost, so, app running locally on the host machine.
docker run --rm -v ${PWD}:/spec openapitools/openapi-diff /spec/openapi_v4.json http://host.docker.internal:5062/swagger/v5/swagger.json