Coder Social home page Coder Social logo

openapi-diff's Introduction

About openapi-diff

Build Status

This repository contains source code of openapi-diff aka oad aka "Breaking change detector tool" npm package. This package is invoked internally by the azure-rest-api-specs and azure-rest-api-specs-pr repos Swagger Breaking Change and Breaking Change(Cross-Version) GitHub checks, validating PRs submitted to them.

For description of the overall process of which oad is part of, see https://aka.ms/azsdk/specreview.

npm package

Caution

Do not use the package oad npm package version shield. It is deprecated and obsolete.

How to run locally

See relevant section in CONTRIBUTING.md

openapi-diff's People

Contributors

alvadb avatar dependabot[bot] avatar jianyexi avatar konrad-jamrozik avatar kooli89 avatar ling1726 avatar michaeljqzq avatar microsoft-github-policy-service[bot] avatar microsoftopensource avatar mikeharder avatar mikekistler avatar msftgits avatar qiaozha avatar ruowan avatar sarangan12 avatar sergey-shandar avatar veronicagg avatar vishrutshah avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

openapi-diff's Issues

Process is terminated due to StackOverflowException

E:\repos\openapi-diff>oad compare E:\repos\azure-rest-api-specs\arm-resources\resources\2016-09-01\swagger\resources.json E:\repos\azure-rest-api-specs\arm-resources\resources\2017-05-10\swagger\resources.json
(node:16864) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Command failed: C:\Users\vissha\.autorest\frameworks\dotnet.exe C:\Users\vissha\AppData\Roaming\npm\node_modules\oad\lib\dlls\OpenApiDiff.dll -o C:\Users\vissha\AppData\Local\Temp\old.json -n C:\Users\vissha\AppData\Local\Temp\new.json -JsonValidationMessages

Process is terminated due to StackOverflowException.

(node:16864) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

[Rule] Property type has changed

Property “foo” was a “boolean” in v1 but is changed to a "string". A client using the existing api-version tries to set it as a bool, but the service will fail since its now expecting a string. So, the api-version must be updated.

[Rule] Property name has changed

If a property was called “foo” in v1 of API and the name will be changed to “bar”, this requires an API-version change since this will result in a breaking change for the client.

[Rule] Property is made required (from optional)

If property “foo” was optional in the request body of v1 and now it is required, this should result in an api-version change. If not changed, clients relying on older api-version will fail if this property is not passed.

Food for thought

  • Naming of the repo & command line
  • CLI structure align with the AutoRest CLI and it's command-line experience
  • long term we should leverage JSON-RPC to perform in-memory spec resolution
  • Each comparison should handle minimal model of swagger 2.0
  • Move towards TypeScript model from NodeJS based CLI

Feel free to add more stuff as you come across.

fyi: @dsgouda @veronicagg

[Rule] Bug fixes to existing API

Bug fixes to existing API which don’t fall into one of the above categories of breaking changes as described above are fine

Initialize all the rules from the configuration file

Class ComparisonMessages should be initialized from the json file for all the rules.

  • Initialization from config file
  • Categorization from config file
  • Run tools in context (Azure v/s NonAzure, SDK v/s NonSDK)
  • Initialize the severity from the config file
  • Generate documentation from master list of rules

[Rule] Resource naming rules should not change

This could result in failures which would have earlier succeeded. Even if the rules become less strict, clients relying on earlier name constraints to perform local validation will fail.

[Rule] Allowed values for an enum have changed

Enum “foo” had allowed values as “val1” and “val2” in v1 of API. If now, the values allowed/accepted by the service are “val1”, “val2” and “val3”, client will fail to de-serialize if “val3” comes back in the response.

[Rule] API has been removed or renamed

V1 of API contract supported PUT /resourceType1/{resourceType1_name} but the service no longer supports this method. This scenario should follow the proper Azure API deprecation policy and must be done in an updated api-version.

[Rule] New property added to response

If a new property/field is added to the response an API, the GET-PUT pipeline will be broken. Consider the case where from portal a customer updates the value of a new property "A". Another customer does a GET of this resource using the SDK. The SDK will ignore the property since it does not understand it. From the SDK, the customer does a PUT using the model that was returned from the GET. This will overwrite the change made by the first customer from the portal.

Enhance and fix following Rules

Update / Correct each rules

  • VersionsReversed
  • ProtocolNoLongerSupported
  • RequestBodyFormatNoLongerSupported
  • RemovedPath
  • RemovedDefinition
  • RemovedClientParameter
  • ModifiedOperationId
  • RemovedRequiredParameter
  • AddingRequiredParameter
  • AddingResponseCode
  • RemovedResponseCode
  • AddingHeader
  • RemovingHeader
  • ParameterInHasChanged
  • ConstantStatusHasChanged
  • ReferenceRedirection
  • RemovedEnumValues
  • RemovedEnumValue
  • AddedEnumValues
  • AddedAdditionalProperties
  • RemovedAdditionalProperties
  • TypeFormatChanged
  • ConstraintIsStronger
  • RequiredStatusChange
  • TypeChanged
  • DefaultValueChanged
  • ArrayCollectionFormatChanged
  • ReadonlyPropertyChanged2
  • DifferentDiscriminator
  • DifferentExtends
  • DifferentAllOf
  • RemovedProperty1
  • AddedRequiredProperty1
  • RemovedOperation
  • ConstraintChanged
  • ConstraintIsWeaker
  • NoVersionChange
  • ResponseBodyFormatNowSupported

Eliminate duplicate messages

Think about whether do we need to eliminate duplicate messages. In the current system given a graph, if one node is dirty then all the paths reaching to that node is reported as dirty.

[Rule] Operation Id has been changed

Operation Id has been changed from one version of the swagger to the another is considered a breaking change in SDK as the generated code would have method with different name.

[Rule] URL format has changed

Resource parameter names change from /resourceType1/{resourceType1_name} to /resourceType1/{resourceType1_id}. This will impact code generation.

Enable integration with the VS Code

  • Scenario 1:
    Developer copy existing folder -> Paste to new api-version -> make commit -> then update that swager
    i.e braking change tool should work on previous commit v/s uncommitted changes

  • Scenario 2:
    Developer updates existing swagger inside a folder ->
    i.e braking change tool should work on previous commit v/s uncommitted changes

  • Tell me two commits and i'll work on it

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.