Skip to content

Bring in changes from joschi/openapi-diff #159

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 67 commits into from
Aug 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
7eb3317
Add swagger2 compatibility
quen2404 Jul 25, 2018
b2f7986
build(deps): bump maven-source-plugin from 3.1.0 to 3.2.1
dependabot-preview[bot] Jan 9, 2020
1f86a31
build(deps-dev): bump assertj-core from 3.14.0 to 3.15.0
dependabot-preview[bot] Jan 29, 2020
53b4149
build(deps): bump lombok from 1.18.10 to 1.18.12
dependabot-preview[bot] Feb 7, 2020
da2fd09
build(deps): bump maven-javadoc-plugin from 3.1.1 to 3.2.0
dependabot-preview[bot] Mar 16, 2020
5e27745
build(deps): bump githook-maven-plugin from 1.0.4 to 1.0.5
dependabot-preview[bot] Mar 23, 2020
25bd154
Fix Issue #136 new read-only property breaks PUT
Mar 24, 2020
3314a84
build(deps-dev): bump junit.jupiter.version from 5.5.2 to 5.6.2
dependabot-preview[bot] Apr 13, 2020
da4d555
Merge branch 'pr-128'
joschi Apr 16, 2020
1ba07ff
Merge branch 'pr-131'
joschi Apr 16, 2020
df2812c
Merge branch 'pr-133'
joschi Apr 16, 2020
d596966
Merge branch 'pr-135'
joschi Apr 16, 2020
dd3272b
Merge branch 'pr-141'
joschi Apr 16, 2020
72eaac9
Merge branch 'pr-137'
joschi Apr 16, 2020
7734db0
Adding oapi 2.x compatibility
Mar 16, 2019
8c4ddf7
Merge branch 'pr-54' into pr-70
joschi Apr 16, 2020
03b1646
Format code
joschi Apr 16, 2020
9bb3520
Disable failing Swagger2CompatibilityTest
joschi Apr 16, 2020
c355dca
Clean up POM
joschi Apr 16, 2020
8e837d1
Clean up Lombok usage
joschi Apr 16, 2020
65fa64f
Add wrapper script for Maven 3.6.3
joschi Apr 16, 2020
13951b1
Add GitHub Actions workflow for running tests
joschi Apr 16, 2020
cef8549
Remove Circle CI and Travis CI configuration
joschi Apr 16, 2020
3350900
Refactor output parameters
joschi Apr 16, 2020
f81e67b
Streamline Docker image build
joschi Apr 16, 2020
981c8f2
Add parameter to fail if API changed
joschi Apr 17, 2020
a0f81c9
swagger-parser 2.0.19
sullis May 3, 2020
0818dd5
Merge branch 'pr-156'
joschi May 4, 2020
cd37edf
build(deps-dev): bump assertj-core from 3.14.0 to 3.16.1
dependabot-preview[bot] May 11, 2020
036440f
Fix NPE when response changed from no schema to any schema (#1)
joschi May 11, 2020
0e49ce4
build(deps): bump swagger-parser-v3 from 2.0.17 to 2.0.20
dependabot-preview[bot] May 18, 2020
9453dc9
Merge branch 'pr-151'
joschi Jun 22, 2020
711201a
Merge branch 'pr-148'
joschi Jun 22, 2020
47ec0dc
Create Dependabot config file (#2)
dependabot-preview[bot] Jun 22, 2020
4e6e2b8
build(deps): bump maven-assembly-plugin from 3.2.0 to 3.3.0 (#3)
dependabot-preview[bot] Jun 22, 2020
0fffe53
Add Quentin Desramé to Thanks section in README.md
joschi Jun 22, 2020
be72782
Replace CircleCI badge with GitHub Actions badge
joschi Jun 22, 2020
8fccce8
Update Docker image in README.md
joschi Jun 22, 2020
a3e5789
Upgrae to fmt-maven-plugin 2.9.1
joschi Jun 22, 2020
842ea3c
Change SCM and group ID in POM
joschi Jun 22, 2020
9ec0290
Split openapi-diff into core and CLI modules (#5)
joschi Jun 22, 2020
7df69df
Streamline Docker image build process
joschi Jun 22, 2020
c55cb82
[maven-release-plugin] prepare release 2.0.0-beta.1
joschi Jun 23, 2020
3c6f9af
[maven-release-plugin] prepare for next development iteration
joschi Jun 23, 2020
d348630
Fix exception in ConsoleRender when property has been removed (#7)
joschi Jun 24, 2020
b86a0f9
Use HTTPS for SCM connections
joschi Jun 24, 2020
129937f
Add developer to POM
joschi Jun 24, 2020
de2b659
Restore version on maven-gpg-plugin in profile
joschi Jun 24, 2020
a4016b1
Add maven-deploy-plugin to pluginManagement
joschi Jun 24, 2020
3d3950f
[maven-release-plugin] prepare release 2.0.0-beta.2
joschi Jun 24, 2020
573fa4f
[maven-release-plugin] prepare for next development iteration
joschi Jun 24, 2020
0aaa1c2
Fix exceptions in HTML and Markdown renderers with removed property (#8)
joschi Jun 24, 2020
47b12b1
Fix NPE when description is empty
jlamaille Jul 6, 2020
e735f78
Clean imports
jlamaille Jul 6, 2020
0d8662f
Merge branch 'pr-155'
joschi Jul 13, 2020
3543fa5
[maven-release-plugin] prepare release 2.0.0-beta.3
joschi Jul 13, 2020
e406351
[maven-release-plugin] prepare for next development iteration
joschi Jul 13, 2020
320ddca
build(deps): bump commons-lang3 from 3.10 to 3.11 (#9)
dependabot[bot] Jul 21, 2020
074f882
build(deps): bump swagger-parser.version from 2.0.20 to 2.0.21 (#10)
dependabot[bot] Aug 11, 2020
793b393
[maven-release-plugin] prepare release 2.0.0-beta.4
joschi Aug 13, 2020
e4a9b11
[maven-release-plugin] prepare for next development iteration
joschi Aug 13, 2020
35fe0c7
Update README.md
joschi Aug 13, 2020
a6b076e
Use Maven profile "release" for releases
joschi Aug 13, 2020
5fe3a91
Allow optional discriminator
dang-gyg Aug 18, 2020
4f10108
Format source code
joschi Aug 18, 2020
726740a
Merge branch 'dang-gyg-optional-discriminator-29' into master
joschi Aug 18, 2020
c3ebfd9
Revert "Remove Circle CI configuration"
joschi Aug 27, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,23 @@ jobs:
- restore_cache:
key: openapi-diff-{{ checksum "pom.xml" }}

- run: mvn dependency:go-offline
- run: ./mvnw package -X

- save_cache:
paths:
- ~/.m2
key: openapi-diff-{{ checksum "pom.xml" }}

- run: mvn package -X

- run:
name: Save test results
command: |
mkdir -p ~/test-results/junit/
find . -type f -regex ".*/target/surefire-reports/.*xml" -exec cp {} ~/test-results/junit/ \;
when: always
- store_test_results:
path: target/surefire-reports
path: ~/test-results

- store_artifacts:
path: target/openapi-diff-*-SNAPSHOT.jar
path: core/target/openapi-diff-*-SNAPSHOT.jar
- store_artifacts:
path: cli/target/openapi-diff-*-SNAPSHOT.jar
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 2
updates:
- package-ecosystem: maven
directory: "/"
schedule:
interval: daily
time: "04:00"
open-pull-requests-limit: 10
33 changes: 33 additions & 0 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Test
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
build:
runs-on: 'ubuntu-latest'
strategy:
fail-fast: false
matrix:
java_version: ['8', '11', '14']
env:
JAVA_OPTS: "-XX:+TieredCompilation -XX:TieredStopAtLevel=1"
steps:
- uses: actions/checkout@v2
- name: Set up JDK
uses: joschi/setup-jdk@v1
with:
java-version: ${{ matrix.java_version }}
- uses: actions/cache@v1
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Build with Maven
run: ./mvnw -V -B -ff install '-DskipTests=true' '-Dmaven.javadoc.skip=true'
- name: Run tests
run: ./mvnw -V -B -ff verify
Binary file added .mvn/wrapper/maven-wrapper.jar
Binary file not shown.
1 change: 1 addition & 0 deletions .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
2 changes: 0 additions & 2 deletions .travis.yml

This file was deleted.

18 changes: 5 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
FROM maven:3.5-jdk-8-alpine as build
WORKDIR /app
COPY ./ /app
RUN mvn install -q && \
mvn package -q && \
ls /app/target/ && \
MVN_VERSION=$(mvn -q \
-Dexec.executable="echo" \
-Dexec.args='${project.version}' \
--non-recursive \
org.codehaus.mojo:exec-maven-plugin:1.6.0:exec) && \
mv /app/target/openapi-diff-${MVN_VERSION}-jar-with-dependencies.jar /app/openapi-diff.jar
FROM openjdk:8-jdk-alpine AS build
WORKDIR /build
COPY ./ /build
RUN ./mvnw -V -B -ff -P docker package -q

FROM openjdk:8-jre-alpine
WORKDIR /app
COPY --from=0 /app/openapi-diff.jar /app
COPY --from=build /build/cli/target/openapi-diff-jar-with-dependencies.jar /app/openapi-diff.jar
ENTRYPOINT ["java", "-jar", "/app/openapi-diff.jar"]
CMD ["--help"]
78 changes: 57 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,63 @@
# OpenAPI-diff

Compare two OpenAPI specifications(3.x) and render the difference to html file or markdown file.
Compare two OpenAPI specifications (3.x) and render the difference to HTML plaintext, or Markdown files.

[![CircleCI](https://circleci.com/gh/quen2404/openapi-diff/tree/master.svg?style=svg)](https://circleci.com/gh/quen2404/openapi-diff/tree/master)
[![Test](https://github.com/joschi/openapi-diff/workflows/Test/badge.svg)](https://github.com/joschi/openapi-diff/actions?query=branch%3Amaster+workflow%3ATest+)

# Requirements
`jdk1.8+`

* Java 8

# Feature
* Supports OpenAPi spec v3.0.
* Depth comparison of parameters, responses, endpoint, http method(GET,POST,PUT,DELETE...)

* Supports OpenAPI spec v3.0.
* Depth comparison of parameters, responses, endpoint, http method (GET,POST,PUT,DELETE...)
* Supports swagger api Authorization
* Render difference of property with Expression Language
* html & markdown render
* HTML & Markdown render

# Maven

Available on [Maven Central](https://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.qdesrame%22%20AND%20a%3A%22openapi-diff%22)
Available on [Maven Central](https://search.maven.org/artifact/com.github.joschi.openapi-diff/core)

```xml
<dependency>
<groupId>com.qdesrame</groupId>
<artifactId>openapi-diff</artifactId>
<version>1.2.0</version>
<groupId>com.github.joschi.openapi-diff</groupId>
<artifactId>core</artifactId>
<version>${openapi-diff-version}</version>
</dependency>
```

# Docker

Available on [Docker Hub](https://hub.docker.com/r/quen2404/openapi-diff/) as `quen2404/openapi-diff`.
Available on [Docker Hub](https://hub.docker.com/r/joschi/openapi-diff/) as `joschi/openapi-diff`.

```bash
# docker run joschi/openapi-diff:latest
usage: openapi-diff <old> <new>
--debug Print debugging information
--error Print error information
--fail-on-changed Fail if API changed but is backward
compatible
--fail-on-incompatible Fail only if API changes broke backward
compatibility
-h,--help print this message
--header <property=value> use given header for authorisation
--html <file> export diff as html in given file
--info Print additional information
-l,--log <level> use given level for log (TRACE, DEBUG,
INFO, WARN, ERROR, OFF). Default: ERROR
--markdown <file> export diff as markdown in given file
--off No information printed
--query <property=value> use query param for authorisation
--state Only output diff state: no_changes,
incompatible, compatible
--text <file> export diff as text in given file
--trace be extra verbose
--version print the version information and exit
--warn Print warning information
```


## Build the image

Expand All @@ -42,19 +71,20 @@ You can replace the local image name `local-openapi-diff` by any name of your ch

## Run an instance

In this example the `$(pwd)/src/test/resources` directory is mounted in the `/specs` directory of the container
In this example the `$(pwd)/core/src/test/resources` directory is mounted in the `/specs` directory of the container
in readonly mode (`ro`).

```bash
docker run -t \
-v $(pwd)/src/test/resources:/specs:ro \
quen2404/openapi-diff /specs/path_1.yaml /specs/path_2.yaml
-v $(pwd)/core/src/test/resources:/specs:ro \
joschi/openapi-diff /specs/path_1.yaml /specs/path_2.yaml
```

The remote name `quen2404/openapi-diff` can be replaced with `local-openapi-diff` or the name you gave to your local image.
The remote name `joschi/openapi-diff` can be replaced with `local-openapi-diff` or the name you gave to your local image.

# Usage
OpenDiff can read swagger api spec from json file or http.

openapi-diff can read OpenAPI specs from JSON files or HTTP URLs.

## Command Line

Expand All @@ -70,13 +100,12 @@ usage: openapi-diff <old> <new>
-l,--log <level> use given level for log (TRACE, DEBUG,
INFO, WARN, ERROR, OFF). Default: ERROR
--markdown <file> export diff as markdown in given file
-o,--output <format=file> use given format (html, markdown) for
output in file
--off No information printed
--query <property=value> use query param for authorisation
--state Only output diff state: no_changes,
incompatible, compatible
--fail-on-incompatible Fail only if API changes broke backward compatibility
--fail-on-changed Fail if API changed but is backward compatible
--trace be extra verbose
--version print the version information and exit
--warn Print warning information
Expand All @@ -100,6 +129,7 @@ public class Main {
### Render difference
---
#### HTML

```java
String html = new HtmlRender("Changelog",
"http://deepoove.com/swagger-diff/stylesheets/demo.css")
Expand All @@ -117,6 +147,7 @@ try {
```

#### Markdown

```java
String render = new MarkdownRender().render(diff);
try {
Expand All @@ -131,11 +162,13 @@ try {
```

### Extensions

This project uses Java Service Provider Inteface (SPI) so additional extensions can be added.

To build your own extension, you simply need to create a `src/main/resources/META-INF/services/com.qdesrame.openapi.diff.compare.ExtensionDiff` file with the full classname of your implementation. Your class must also implement the `com.qdesrame.openapi.diff.compare.ExtensionDiff` interface. Then, including your library with the `openapi-diff` module will cause it to be triggered automatically.
To build your own extension, you simply need to create a `src/main/resources/META-INF/services/com.qdesrame.openapi.diff.core.compare.ExtensionDiff` file with the full classname of your implementation. Your class must also implement the `com.qdesrame.openapi.diff.core.compare.ExtensionDiff` interface. Then, including your library with the `openapi-diff` module will cause it to be triggered automatically.

# Examples

# Example
### CLI Output

```text
Expand Down Expand Up @@ -234,6 +267,7 @@ To build your own extension, you simply need to create a `src/main/resources/MET
```

### Markdown

```markdown
### What's New
---
Expand Down Expand Up @@ -308,10 +342,12 @@ To build your own extension, you simply need to create a `src/main/resources/MET
```

# License

openapi-diff is released under the Apache License 2.0.

# Thanks
* Adarsh Sharma / [adarshsharma](https://github.com/adarshsharma)

* Adarsh Sharma / [adarshsharma](https://github.com/adarshsharma)
* Quentin Desramé / [quen2404](https://github.com/quen2404)
* [Sayi](https://github.com/Sayi) for his project [swagger-diff](https://github.com/Sayi/swagger-diff)
which was a source of inspiration for this tool
67 changes: 67 additions & 0 deletions cli/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.github.joschi.openapi-diff</groupId>
<artifactId>parent</artifactId>
<version>2.0.0-SNAPSHOT</version>
</parent>

<artifactId>cli</artifactId>
<packaging>jar</packaging>

<name>openapi-diff-cli</name>
<description>CLI for openapi-diff</description>

<dependencies>
<dependency>
<groupId>com.github.joschi.openapi-diff</groupId>
<artifactId>core</artifactId>
<version>2.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>com.qdesrame.openapi.diff.cli.Main</mainClass>
</manifest>
</archive>
<finalName>openapi-diff</finalName>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Loading