Skip to content

Commit 96f20ff

Browse files
authored
Merge pull request #159 from joschi/update-origin
Bring in changes from joschi/openapi-diff
2 parents 443246f + c3ebfd9 commit 96f20ff

File tree

166 files changed

+2182
-779
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

166 files changed

+2182
-779
lines changed

.circleci/config.yml

+11-5
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,23 @@ jobs:
1414
- restore_cache:
1515
key: openapi-diff-{{ checksum "pom.xml" }}
1616

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

1919
- save_cache:
2020
paths:
2121
- ~/.m2
2222
key: openapi-diff-{{ checksum "pom.xml" }}
2323

24-
- run: mvn package -X
25-
24+
- run:
25+
name: Save test results
26+
command: |
27+
mkdir -p ~/test-results/junit/
28+
find . -type f -regex ".*/target/surefire-reports/.*xml" -exec cp {} ~/test-results/junit/ \;
29+
when: always
2630
- store_test_results:
27-
path: target/surefire-reports
31+
path: ~/test-results
2832

2933
- store_artifacts:
30-
path: target/openapi-diff-*-SNAPSHOT.jar
34+
path: core/target/openapi-diff-*-SNAPSHOT.jar
35+
- store_artifacts:
36+
path: cli/target/openapi-diff-*-SNAPSHOT.jar

.github/dependabot.yml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: maven
4+
directory: "/"
5+
schedule:
6+
interval: daily
7+
time: "04:00"
8+
open-pull-requests-limit: 10

.github/workflows/maven.yml

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Test
2+
on:
3+
push:
4+
branches:
5+
- master
6+
pull_request:
7+
branches:
8+
- master
9+
jobs:
10+
build:
11+
runs-on: 'ubuntu-latest'
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
java_version: ['8', '11', '14']
16+
env:
17+
JAVA_OPTS: "-XX:+TieredCompilation -XX:TieredStopAtLevel=1"
18+
steps:
19+
- uses: actions/checkout@v2
20+
- name: Set up JDK
21+
uses: joschi/setup-jdk@v1
22+
with:
23+
java-version: ${{ matrix.java_version }}
24+
- uses: actions/cache@v1
25+
with:
26+
path: ~/.m2/repository
27+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
28+
restore-keys: |
29+
${{ runner.os }}-maven-
30+
- name: Build with Maven
31+
run: ./mvnw -V -B -ff install '-DskipTests=true' '-Dmaven.javadoc.skip=true'
32+
- name: Run tests
33+
run: ./mvnw -V -B -ff verify

.mvn/wrapper/maven-wrapper.jar

48.4 KB
Binary file not shown.

.mvn/wrapper/maven-wrapper.properties

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip

.travis.yml

-2
This file was deleted.

Dockerfile

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

146
FROM openjdk:8-jre-alpine
157
WORKDIR /app
16-
COPY --from=0 /app/openapi-diff.jar /app
8+
COPY --from=build /build/cli/target/openapi-diff-jar-with-dependencies.jar /app/openapi-diff.jar
179
ENTRYPOINT ["java", "-jar", "/app/openapi-diff.jar"]
1810
CMD ["--help"]

README.md

+57-21
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,63 @@
11
# OpenAPI-diff
22

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

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

77
# Requirements
8-
`jdk1.8+`
8+
9+
* Java 8
910

1011
# Feature
11-
* Supports OpenAPi spec v3.0.
12-
* Depth comparison of parameters, responses, endpoint, http method(GET,POST,PUT,DELETE...)
12+
13+
* Supports OpenAPI spec v3.0.
14+
* Depth comparison of parameters, responses, endpoint, http method (GET,POST,PUT,DELETE...)
1315
* Supports swagger api Authorization
1416
* Render difference of property with Expression Language
15-
* html & markdown render
17+
* HTML & Markdown render
1618

1719
# Maven
1820

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

2123
```xml
2224
<dependency>
23-
<groupId>com.qdesrame</groupId>
24-
<artifactId>openapi-diff</artifactId>
25-
<version>1.2.0</version>
25+
<groupId>com.github.joschi.openapi-diff</groupId>
26+
<artifactId>core</artifactId>
27+
<version>${openapi-diff-version}</version>
2628
</dependency>
2729
```
2830

2931
# Docker
3032

31-
Available on [Docker Hub](https://hub.docker.com/r/quen2404/openapi-diff/) as `quen2404/openapi-diff`.
33+
Available on [Docker Hub](https://hub.docker.com/r/joschi/openapi-diff/) as `joschi/openapi-diff`.
34+
35+
```bash
36+
# docker run joschi/openapi-diff:latest
37+
usage: openapi-diff <old> <new>
38+
--debug Print debugging information
39+
--error Print error information
40+
--fail-on-changed Fail if API changed but is backward
41+
compatible
42+
--fail-on-incompatible Fail only if API changes broke backward
43+
compatibility
44+
-h,--help print this message
45+
--header <property=value> use given header for authorisation
46+
--html <file> export diff as html in given file
47+
--info Print additional information
48+
-l,--log <level> use given level for log (TRACE, DEBUG,
49+
INFO, WARN, ERROR, OFF). Default: ERROR
50+
--markdown <file> export diff as markdown in given file
51+
--off No information printed
52+
--query <property=value> use query param for authorisation
53+
--state Only output diff state: no_changes,
54+
incompatible, compatible
55+
--text <file> export diff as text in given file
56+
--trace be extra verbose
57+
--version print the version information and exit
58+
--warn Print warning information
59+
```
60+
3261
3362
## Build the image
3463
@@ -42,19 +71,20 @@ You can replace the local image name `local-openapi-diff` by any name of your ch
4271
4372
## Run an instance
4473
45-
In this example the `$(pwd)/src/test/resources` directory is mounted in the `/specs` directory of the container
74+
In this example the `$(pwd)/core/src/test/resources` directory is mounted in the `/specs` directory of the container
4675
in readonly mode (`ro`).
4776
4877
```bash
4978
docker run -t \
50-
-v $(pwd)/src/test/resources:/specs:ro \
51-
quen2404/openapi-diff /specs/path_1.yaml /specs/path_2.yaml
79+
-v $(pwd)/core/src/test/resources:/specs:ro \
80+
joschi/openapi-diff /specs/path_1.yaml /specs/path_2.yaml
5281
```
5382
54-
The remote name `quen2404/openapi-diff` can be replaced with `local-openapi-diff` or the name you gave to your local image.
83+
The remote name `joschi/openapi-diff` can be replaced with `local-openapi-diff` or the name you gave to your local image.
5584
5685
# Usage
57-
OpenDiff can read swagger api spec from json file or http.
86+
87+
openapi-diff can read OpenAPI specs from JSON files or HTTP URLs.
5888
5989
## Command Line
6090
@@ -70,13 +100,12 @@ usage: openapi-diff <old> <new>
70100
-l,--log <level> use given level for log (TRACE, DEBUG,
71101
INFO, WARN, ERROR, OFF). Default: ERROR
72102
--markdown <file> export diff as markdown in given file
73-
-o,--output <format=file> use given format (html, markdown) for
74-
output in file
75103
--off No information printed
76104
--query <property=value> use query param for authorisation
77105
--state Only output diff state: no_changes,
78106
incompatible, compatible
79107
--fail-on-incompatible Fail only if API changes broke backward compatibility
108+
--fail-on-changed Fail if API changed but is backward compatible
80109
--trace be extra verbose
81110
--version print the version information and exit
82111
--warn Print warning information
@@ -100,6 +129,7 @@ public class Main {
100129
### Render difference
101130
---
102131
#### HTML
132+
103133
```java
104134
String html = new HtmlRender("Changelog",
105135
"http://deepoove.com/swagger-diff/stylesheets/demo.css")
@@ -117,6 +147,7 @@ try {
117147
```
118148
119149
#### Markdown
150+
120151
```java
121152
String render = new MarkdownRender().render(diff);
122153
try {
@@ -131,11 +162,13 @@ try {
131162
```
132163
133164
### Extensions
165+
134166
This project uses Java Service Provider Inteface (SPI) so additional extensions can be added.
135167
136-
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.
168+
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.
169+
170+
# Examples
137171
138-
# Example
139172
### CLI Output
140173
141174
```text
@@ -234,6 +267,7 @@ To build your own extension, you simply need to create a `src/main/resources/MET
234267
```
235268
236269
### Markdown
270+
237271
```markdown
238272
### What's New
239273
---
@@ -308,10 +342,12 @@ To build your own extension, you simply need to create a `src/main/resources/MET
308342
```
309343
310344
# License
345+
311346
openapi-diff is released under the Apache License 2.0.
312347
313348
# Thanks
314-
* Adarsh Sharma / [adarshsharma](https://github.com/adarshsharma)
315349
350+
* Adarsh Sharma / [adarshsharma](https://github.com/adarshsharma)
351+
* Quentin Desramé / [quen2404](https://github.com/quen2404)
316352
* [Sayi](https://github.com/Sayi) for his project [swagger-diff](https://github.com/Sayi/swagger-diff)
317353
which was a source of inspiration for this tool

cli/pom.xml

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<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">
2+
<modelVersion>4.0.0</modelVersion>
3+
4+
<parent>
5+
<groupId>com.github.joschi.openapi-diff</groupId>
6+
<artifactId>parent</artifactId>
7+
<version>2.0.0-SNAPSHOT</version>
8+
</parent>
9+
10+
<artifactId>cli</artifactId>
11+
<packaging>jar</packaging>
12+
13+
<name>openapi-diff-cli</name>
14+
<description>CLI for openapi-diff</description>
15+
16+
<dependencies>
17+
<dependency>
18+
<groupId>com.github.joschi.openapi-diff</groupId>
19+
<artifactId>core</artifactId>
20+
<version>2.0.0-SNAPSHOT</version>
21+
</dependency>
22+
<dependency>
23+
<groupId>commons-cli</groupId>
24+
<artifactId>commons-cli</artifactId>
25+
</dependency>
26+
<dependency>
27+
<groupId>org.apache.commons</groupId>
28+
<artifactId>commons-lang3</artifactId>
29+
</dependency>
30+
<dependency>
31+
<groupId>org.slf4j</groupId>
32+
<artifactId>slf4j-api</artifactId>
33+
</dependency>
34+
<dependency>
35+
<groupId>org.slf4j</groupId>
36+
<artifactId>slf4j-log4j12</artifactId>
37+
</dependency>
38+
</dependencies>
39+
<build>
40+
<plugins>
41+
<plugin>
42+
<groupId>org.apache.maven.plugins</groupId>
43+
<artifactId>maven-assembly-plugin</artifactId>
44+
<configuration>
45+
<descriptorRefs>
46+
<descriptorRef>jar-with-dependencies</descriptorRef>
47+
</descriptorRefs>
48+
<archive>
49+
<manifest>
50+
<mainClass>com.qdesrame.openapi.diff.cli.Main</mainClass>
51+
</manifest>
52+
</archive>
53+
<finalName>openapi-diff</finalName>
54+
</configuration>
55+
<executions>
56+
<execution>
57+
<id>make-assembly</id>
58+
<phase>package</phase>
59+
<goals>
60+
<goal>single</goal>
61+
</goals>
62+
</execution>
63+
</executions>
64+
</plugin>
65+
</plugins>
66+
</build>
67+
</project>

0 commit comments

Comments
 (0)