Skip to content
This repository has been archived by the owner on Nov 27, 2017. It is now read-only.

Initialise Swagger setup #6

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
17 changes: 17 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 4
trim_trailing_whitespace=true
max_line_length=120

[*.{xml,yml,json}]
indent_size = 2

[Makefile]
indent_style = tab
17 changes: 15 additions & 2 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This project offers the online verification of https://github.com/redhat-ipaas/connectors[Camel Connectors]. It provides a single Endpoint

```
/verify
/api/v1/verifier
```

which take connector specific parameters as input and returns the result of the verification.
Expand All @@ -24,4 +24,17 @@ It's meant to be used in a synchronous flow.

### Implementation Notes

In the initial version of this service the supported Camel Connectors (Twitter Mention, Salesforce Upsert, Http Get) are called directly from the same JVM in order to perform the validation. In a next step, these connectors are extracted into dedicated Pods which are managed and pooled and called from this Verifier Service on demand. More on this later ...
In the initial version of this service the supported Camel Connectors (Twitter Mention, Salesforce Upsert, Http Get) are called directly from the same JVM in order to perform the validation. In a next step, these connectors are extracted into dedicated Pods which are managed and pooled and called from this Verifier Service on demand. More on this later ...

### Running it

#### Local

For local development purpose the container can be started directly from a Docker container

[source, bash]
----
mvn package fabric8:build docker:start docker:watch
----

This will rebuild and restart your application every time you recompile the code.
13 changes: 13 additions & 0 deletions header.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Copyright (C) ${project.inceptionYear} ${owner}

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
153 changes: 139 additions & 14 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,29 @@
<name>iPaaS Verifier</name>
<version>1.0.0-SNAPSHOT</version>

<properties>
<spring-boot.version>1.5.2.RELEASE</spring-boot.version>
<camel.version>2.19.0.fuse-000036</camel.version>
<swagger.version>1.5.12</swagger.version>
<resteasy-spring-boot-starter.version>2.3.0-RELEASE</resteasy-spring-boot-starter.version>
<jackson.version>2.8.7</jackson.version>
<redhat-ipaas-connector.version>0.3.7</redhat-ipaas-connector.version>

<fabric8-maven-plugin.version>3.3.0</fabric8-maven-plugin.version>
<docker-maven-plugin.version>0.20.1</docker-maven-plugin.version>
<license-maven-plugin.version>3.0</license-maven-plugin.version>
<swagger-maven-plugin.version>1.0.0</swagger-maven-plugin.version>
<swagger2markup-maven-plugin.version>1.1.0</swagger2markup-maven-plugin.version>

<apidocs.dir>${project.build.directory}/api-docs</apidocs.dir>
<apidocs.schema.dir>${project.build.outputDirectory}/static</apidocs.schema.dir>

<!-- Base image to use for Docker images. Pinned to 1.2.3 since 1.2.4 has issues because
of Java 1.8.0_121 (1.2.3 is running 1.8.0_111) -->
<java-image>fabric8/java-jboss-openjdk8-jdk:1.2.3</java-image>
<verifier-image>rhipaas/ipaas-verifier:%l</verifier-image>
</properties>

<inceptionYear>2017</inceptionYear>

<organization>
Expand Down Expand Up @@ -131,19 +154,6 @@
</pluginRepository>
</pluginRepositories>

<properties>
<spring-boot.version>1.5.2.RELEASE</spring-boot.version>
<camel.version>2.19.0.fuse-000020</camel.version>
<swagger.version>1.5.12</swagger.version>
<resteasy-spring-boot-starter.version>2.3.0-RELEASE</resteasy-spring-boot-starter.version>
<jackson.version>2.8.7</jackson.version>
<fabric8-maven-plugin.version>3.3.0</fabric8-maven-plugin.version>
<redhat-ipaas-connector.version>0.3.2</redhat-ipaas-connector.version>
<!-- Base image to use for Docker images. Pinned to 1.2.3 since 1.2.4 has issues because
of Java 1.8.0_121 (1.2.3 is running 1.8.0_111) -->
<java-image>fabric8/java-jboss-openjdk8-jdk:1.2.3</java-image>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
Expand Down Expand Up @@ -259,6 +269,16 @@
<build>
<plugins>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>

<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
Expand All @@ -276,22 +296,127 @@
</executions>
</plugin>

<plugin>
<groupId>com.mycila</groupId>
<artifactId>license-maven-plugin</artifactId>
<version>${license-maven-plugin.version}</version>
<configuration>
<aggregate>true</aggregate>
<header>header.txt</header>
<properties>
<owner>Red Hat, Inc.</owner>
</properties>
<excludes>
<exclude>.editorconfig</exclude>
<exclude>LICENSE.txt</exclude>
<exclude>**/*.adoc</exclude>
<exclude>Jenkinsfile*</exclude>
</excludes>
</configuration>
</plugin>

<plugin>
<groupId>io.fabric8</groupId>
<artifactId>fabric8-maven-plugin</artifactId>
<version>${fabric8-maven-plugin.version}</version>
<configuration>
<mode>kubernetes</mode>
<generator>
<config>
<spring-boot>
<name>rhipaas/ipaas-verifier:%l</name>
<name>${verifier-image}</name>
<from>${java-image}</from>
</spring-boot>
</config>
</generator>
</configuration>
</plugin>

<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>${docker-maven-plugin.version}</version>
<configuration>
<images>
<image>
<name>${verifier-image}</name>
<alias>verfier</alias>
<run>
<ports>
<port>8080:8080</port>
</ports>
</run>
</image>
</images>
</configuration>
</plugin>

<plugin>
<groupId>dk.nykredit.swagger</groupId>
<artifactId>swagger-maven-plugin</artifactId>
<version>${swagger-maven-plugin.version}</version>
<configuration>
<outputDirectory>${apidocs.schema.dir}</outputDirectory>
<outputFormats>
<outputFormat>JSON</outputFormat>
<outputFormat>YAML</outputFormat>
</outputFormats>
<attachSwaggerArtifact>true</attachSwaggerArtifact>
<resourcePackages>
<resourcePackage>com.redhat.ipaas.verifier.v1</resourcePackage>
</resourcePackages>
<swaggerConfig>
<info>
<title>Red Hat iPaaS Verifier API</title>
<version>v1</version>
<description>
The Red Hat iPaaS Verifier API sole purpose is to verify connection parameters for the endpoints of certain connectors.
</description>
<license>
<url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
<name>Apache 2.0</name>
</license>
<contact>
<email>[email protected]</email>
<name>The Red Hat iPaaS Developers</name>
<url>https://redhat-ipaas.github.io</url>
</contact>
</info>
<schemes>http,https</schemes>
<host>localhost:8080</host>
<basePath>/api/v1</basePath>
</swaggerConfig>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>io.github.swagger2markup</groupId>
<artifactId>swagger2markup-maven-plugin</artifactId>
<version>${swagger2markup-maven-plugin.version}</version>
<configuration>
<swaggerInput>${apidocs.schema.dir}/swagger.json</swaggerInput>
<outputDir>${apidocs.dir}/asciidoc</outputDir>
<config>
<swagger2markup.markupLanguage>ASCIIDOC</swagger2markup.markupLanguage>
</config>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>convertSwagger2markup</goal>
</goals>
</execution>
</executions>
</plugin>

</plugins>
</build>

Expand Down
15 changes: 15 additions & 0 deletions src/main/java/com/redhat/ipaas/verifier/Application.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/**
* Copyright (C) 2017 Red Hat, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.redhat.ipaas.verifier;

import org.springframework.boot.SpringApplication;
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/com/redhat/ipaas/verifier/Verifier.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/**
* Copyright (C) 2017 Red Hat, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.redhat.ipaas.verifier;

import java.util.List;
Expand Down
24 changes: 24 additions & 0 deletions src/main/java/com/redhat/ipaas/verifier/VerifierRegistry.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
/**
* Copyright (C) 2017 Red Hat, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.redhat.ipaas.verifier;

import java.util.Map;

import org.springframework.stereotype.Component;

/**
* A simple registry holding all the verifiers that are currently supported
*
* @author roland
* @since 28/03/2017
*/
Expand All @@ -17,6 +34,13 @@ public VerifierRegistry(Map<String, Verifier> verifiers) {
this.verifiers = verifiers;
}

/**
* Get the verifier by the connector id.
* The connector id is "twitter", not "twitter-mention" (thats an action)
*
* @param connectorId connector id to lookup
* @return the verifier or null if none is registered
*/
public Verifier getVerifier(String connectorId) {
return verifiers.get(connectorId);
}
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/com/redhat/ipaas/verifier/VerifierResponse.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
/**
* Copyright (C) 2017 Red Hat, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.redhat.ipaas.verifier;

import java.util.*;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;

/**
* A verification response.
*
* @author roland
* @since 20/03/2017
*/
Expand Down
Loading