A standalone tool for comparing two typespec specs based on certain rules which is configurable. Note: each typespec spec may contains multiple versions, for example:
- Spec A (older)
- v1
- v2
- Spec B (newer)
- v1
- v2
- v3
typespec-diff -n <new>/main.tsp -o <old>/main.tsp -c typespec-diff.config
typespec-diff -c typespec-diff.config -n <new>/main.tsp -o <old>/main.tsp --new-version=v2 --old-version=v1
- code: AddedEnumValue
severity: error
message: "The enum 'Foo' added a new value 'Bar'."
old: "old/main.tsp:1:1"
new: "new/main.tsp:1:1"
versions: { oldVersion:'v1', newVersion:'v2' }
a json/yaml file to modify the default rule config (by default each rule will have a default configuration)
rules:
AddedEnumValue: off
RemovedEnumValue: error
AddedResponseCode:
severity:
- warn // the first severity is for the case that version is not bumped
- error // the second severity is for the case that version is bumped
-
for minor or patch version change, we can have below options:
- use the compiler and libs in the newer package.json to load both specs
- always use the latest compiler and libs, this needs the compiler and libs must have the compatibility with older version.
- load older and newer spec by using their own compiler version, but it seems hard to accomplish, as one nodejs process can only load one version of compiler, we can only do the comparison across the process.
-
don't support compare two specs which contains major compiler version change ?
- versions:
namespaces:
interfaces:
operations:
operations:
parameters:
responses:
models:
enums:
unions:
refer to https://github.com/Azure/openapi-diff/tree/main/docs and https://aka.ms/AzBreakingChangesPolicy
- NoVersionChange
- AddedVersion
- RemovedVersion
- ProtocolNoLongerSupported
N/A
N/A
- AddedNameSpace
- RemovedNameSpace
- AddedInterface
- RemovedInterface
- AddedOperation
- RemovedOperation
- ModifiedOperationId
- ChangedPath
- RemovedRequiredParameter
- AddedRequiredParameters
- RemovedOptionalParameter
- AddedOptionalParameters
- RemovedBodyContentType
- AddedBodyContentType
- AddedResponseCode
- RemovedResponseCode
- AddedResponseHeader
- RemovedResponseHeader
- ChangedParameterOrder
- AddedLongrunningOperationSupport
- RemovedLongrunningOperationSupport
- AddedPaginationSupport
- RemovedPaginationSupport
- RemovedModel
- AddedModel
- ChangedModelType
- RemovedProperty
- ChangedPropertyType
- AddedOptionalProperty
- AddedRequiredProperty
- ChangedArrayItemType
- DifferentExtends
- ChangedFormat
- DifferentDiscriminator
- ConstantStatusHasChanged
- ParameterInHasCHanged
- ArrayCollectionFormatChanged
- VisibilityChanged
- ConstraintChanged
- AddedEnumType
- RemovedEnumType
- AddedEnumValue
- RemovedEnumValue
- AddedUnion
- RemovedUnion
- AddedVariant
- RemovedVariant
- ChangedDecoratorArguments
- AddedDecorator
- RemovedDecorator