Swagger Backwards Compatibility Maven Plugin

A Maven plugin for analyzing Swagger API Specs backwards compatible changes.

License

License

Categories

Categories

Maven Build Tools Swagger Program Interface REST Frameworks
GroupId

GroupId

io.kemtoa.swagger
ArtifactId

ArtifactId

swagger-backwards-compat-maven-plugin
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

maven-plugin
Description

Description

Swagger Backwards Compatibility Maven Plugin
A Maven plugin for analyzing Swagger API Specs backwards compatible changes.
Project URL

Project URL

https://github.com/bgK/swagger-backwards-compat-maven-plugin
Source Code Management

Source Code Management

http://github.com/bgK/swagger-backwards-compat-maven-plugin/tree/master

Download swagger-backwards-compat-maven-plugin

How to add to project

<plugin>
    <groupId>io.kemtoa.swagger</groupId>
    <artifactId>swagger-backwards-compat-maven-plugin</artifactId>
    <version>1.0.0</version>
</plugin>

Dependencies

compile (8)

Group / Artifact Type Version
org.apache.maven : maven-core jar 3.3.9
org.apache.maven : maven-plugin-api jar 3.2.5
org.apache.maven : maven-artifact jar 3.3.9
org.apache.maven.plugins : maven-resources-plugin jar 3.1.0
io.swagger : swagger-core jar 1.5.22
io.swagger : swagger-models jar 1.5.22
io.swagger : swagger-parser jar 1.0.44
org.apache.maven : maven-model jar 3.3.9

provided (1)

Group / Artifact Type Version
org.apache.maven.plugin-tools : maven-plugin-annotations jar 3.5.2

test (5)

Group / Artifact Type Version
junit : junit jar 4.12
org.apache.maven.plugin-testing : maven-plugin-testing-harness jar 3.3.0
org.apache.maven : maven-aether-provider jar 3.3.9
org.apache.maven : maven-compat jar 3.3.9
org.codehaus.plexus : plexus-utils jar 3.1.0

Project Modules

There are no modules declared in this project.

Swagger Backwards Compatibility Check Maven Plugin

The swagger-backwards-compat plugin is a Maven plugin to run a backwards compatibility check on a set of Swagger API 2.0 JSON specification files. The plugin can be integrated into various phases of a maven build to check that any changes to a set of Swagger .json files are backwards compatible. This ensures that these changes do not impact existing users that haven't had a chance to update to these latest changes. .lock files are created to keep track of the state of the .json files. This file is updated when a non-breaking change is made, and should be checked in along with any other changes.

It is also possible to force any breaking changes and reset the current state by deleting .lock files. It will then reinitialize the next time the plugin is run.

Configuration

<build>
    <plugins>
        <plugin>
            <groupId>io.kemtoa.swagger</groupId>
            <artifactId>swagger-backwards-compat-maven-plugin</artifactId>
            <version>1.0.0</version>
            <configuration>
                <!-- Optional alternate .json Swagger spec location -->
                <swaggerSourceDir>${basedir}/src/main/swagger</swaggerSourceDir>
                <!-- Optional alternate .lock reference Swagger spec location -->
                <swaggerLockDir>${basedir}/src/main/swagger</swaggerLockDir>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>backwards-compatibility-check</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

Rules

The following rules are enforced when checking for backwards incompatible changes:

  • PropertyRemovedInResponseRule: A property was removed from a response.

    Clients using the old spec may rely on it being present and fail with the new implementation.

  • PropertyTypeChangedRule: The type of a property was changed.

    Clients using the old spec may fail to interpret the new type. This rule triggers on all type changes. There is no such thing as backwards compatible types at the moment.

  • AddedRequiredRequestParameterRule: A new required parameter was added to a request.

    Clients using the old spec don't provide the new parameter resulting in the request being rejected by the server.

  • ParameterLocationChangedRule: The way a parameter is transmitted in the request changed.

    For example a parameter that was passed in the query string is now passed as a header. Clients using the old spec provide the parameter at the old location resulting in the request being rejected by the server.

  • RemovedOperationRule: An endpoint path or a verb was removed.

    Clients using the old spec will keep calling the removed endpoint, resulting in the request being rejected by the server.

  • AddedEnumValueInResponseRule: An enumeration value was added in an object used in a response.

    Clients using the old spec may fail to interpret the new value.

  • RemovedEnumValueInRequestRule: An enumeration value was removed in an object used in a request.

    Client using the old spec may keep sending the old value, resulting in the request being rejected by the server.

This plugin not detecting backwards incompatible changes does not mean there are not. However, it does covers the most usual cases. Only the API specification is verified, this plugin cannot detect backwards incompatible changes in the service implementation.

Acknowledgements

Yelp's swagger-spec-compatibility Python library and Salesforce's proto-backwards-compat-maven-plugin were large sources of inspiration:

Versions

Version
1.0.0