Skip to content

Realizar Deploy do comparador de OpenAPI's e commit do projeto no maven #1

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 1 commit into from
May 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions apicompare/.settings/org.eclipse.core.resources.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/test/java=UTF-8
encoding/<project>=UTF-8
7 changes: 7 additions & 0 deletions apicompare/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.methodParameters=generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
4 changes: 4 additions & 0 deletions apicompare/.settings/org.eclipse.m2e.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
112 changes: 112 additions & 0 deletions apicompare/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
<?xml version="1.0" encoding="UTF-8"?>
<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>
<groupId>com.totvs.ttalk</groupId>
<artifactId>apicompare</artifactId>
<version>2.0.0</version>
<name>apicompare Maven Webapp</name>
<url>http://maven.apache.org</url>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.4.RELEASE</version>
</parent>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.qdesrame</groupId>
<artifactId>openapi-diff</artifactId>
<version>2.0.4-TOTVS</version>
</dependency>

<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>

<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>

<dependency>
<groupId>asm</groupId>
<artifactId>asm</artifactId>
<version>3.3.1</version>
</dependency>

<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.4.1</version>
</dependency>

<dependency>
<groupId>org.apache.ws.security</groupId>
<artifactId>wss4j</artifactId>
<version>1.6.19</version>
</dependency>

<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20180130</version>
</dependency>

</dependencies>

<properties>
<java.version>1.8</java.version>
</properties>


<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<requiresUnpack>
<dependency>
<groupId>org.apache.ws.security</groupId>
<artifactId>wss4j</artifactId>
</dependency>
</requiresUnpack>
</configuration>
</plugin>
</plugins>
</build>

<repositories>
<repository>
<id>spring-releases</id>
<url>https://repo.spring.io/libs-release</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-releases</id>
<url>https://repo.spring.io/libs-release</url>
</pluginRepository>
</pluginRepositories>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.totvs.ttalk.apicompare;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;

@SpringBootApplication
public class ApiCompareApplication extends SpringBootServletInitializer {

public static void main(String[] args) {
SpringApplication.run(ApiCompareApplication.class, args);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package com.totvs.ttalk.apicompare.resources;

import java.io.UnsupportedEncodingException;

import org.json.JSONException;
import org.json.JSONObject;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.qdesrame.openapi.diff.OpenApiCompare;
import com.qdesrame.openapi.diff.model.ChangedOpenApi;
import com.qdesrame.openapi.diff.output.ConsoleRender;
import com.qdesrame.openapi.diff.output.JSONRender;

@RestController
@RequestMapping("/totvseai/openapicomparator/v1")
public class ApiCompareResource {

@RequestMapping(path = "/console", method = RequestMethod.POST, produces = { "text/plain" })
public String postConsole(@RequestBody String body) throws UnsupportedEncodingException, JSONException {
return console(body);
}

@RequestMapping(path = "/json", method = RequestMethod.POST, produces = { "application/JSON" })
public String postJSON(@RequestParam(value = "hasConsole", defaultValue = "true") Boolean hasConsole,
@RequestBody String body) throws UnsupportedEncodingException, JSONException {
return json(hasConsole, body);
}

@RequestMapping(path = "/console", method = RequestMethod.GET, produces = { "text/plain" })
public String console(@RequestBody String body) throws UnsupportedEncodingException, JSONException {
JSONObject jsonBody = new JSONObject(body);
ChangedOpenApi result = compare(jsonBody.get("olderVersion").toString(),
jsonBody.get("newerVersion").toString());

ConsoleRender consoleRender = new ConsoleRender();
String meuTexto = consoleRender.render(result);
return meuTexto;
}

@RequestMapping(path = "/json", method = RequestMethod.GET, produces = { "application/JSON" })
public String json(@RequestParam(value = "hasConsole", defaultValue = "true") Boolean hasConsole,
@RequestBody String body) throws UnsupportedEncodingException, JSONException {

JSONObject jsonBody = new JSONObject(body);

ChangedOpenApi result = compare(jsonBody.get("olderVersion").toString(),
jsonBody.get("newerVersion").toString());

JSONRender jsonRender = new JSONRender();

String responsejson = jsonRender.render(result, hasConsole);
return responsejson;
}

private ChangedOpenApi compare(String olderVersion, String newerVersion) throws UnsupportedEncodingException {

// converting into UTF-8
String oVersion = new String(olderVersion.getBytes("UTF-8"));
String nVersion = new String(newerVersion.getBytes("UTF-8"));

ChangedOpenApi result = OpenApiCompare.fromContents(oVersion, nVersion);
return result;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.totvs.ttalk.apicompare.resources;

import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/teste")
public class teste {

@RequestMapping(path = "/console", method = RequestMethod.GET)
public String console(@RequestBody String body){

String meuTexto = "teste";
return meuTexto;
}

@RequestMapping(path = "/json", method = RequestMethod.GET)
public String json(@RequestParam(value="hasConsole", defaultValue="true") Boolean hasConsole,
@RequestBody String body){


String response = "TESTES";
return response;
}

}
26 changes: 8 additions & 18 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<groupId>com.qdesrame</groupId>
<artifactId>openapi-diff</artifactId>
<version>2.0.0-SNAPSHOT</version>
<version>2.0.4-TOTVS</version>
<packaging>jar</packaging>

<name>openapi-diff</name>
Expand Down Expand Up @@ -130,6 +130,11 @@
<artifactId>lombok</artifactId>
<version>1.18.2</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20180130</version>
</dependency>
</dependencies>

<profiles>
Expand Down Expand Up @@ -280,30 +285,15 @@
<artifactId>fmt-maven-plugin</artifactId>
<version>2.6.0</version>
<executions>
<execution>
<goals>
<goal>format</goal>
</goals>
</execution>

</executions>
</plugin>
<plugin>
<groupId>io.github.phillipuniverse</groupId>
<artifactId>githook-maven-plugin</artifactId>
<version>1.0.0</version>
<executions>
<execution>
<goals>
<goal>install</goal>
</goals>
<configuration>
<hooks>
<pre-commit>
mvn com.coveo:fmt-maven-plugin:format
</pre-commit>
</hooks>
</configuration>
</execution>

</executions>
</plugin>
</plugins>
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/qdesrame/openapi/diff/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.qdesrame.openapi.diff.model.ChangedOpenApi;
import com.qdesrame.openapi.diff.output.ConsoleRender;
import com.qdesrame.openapi.diff.output.HtmlRender;
import com.qdesrame.openapi.diff.output.JSONRender;
import com.qdesrame.openapi.diff.output.MarkdownRender;
import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -143,6 +144,10 @@ public static void main(String... args) {
if (!logLevel.equals("OFF")) {
System.out.println(consoleRender.render(result));
}

JSONRender jsonRender = new JSONRender();
System.out.println(jsonRender.render(result,true));

HtmlRender htmlRender = new HtmlRender();
MarkdownRender mdRender = new MarkdownRender();
String output = null;
Expand Down
Loading