Skip to content
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

OpenAPI definition files #2784

Closed
wants to merge 6 commits into from
Closed
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
6 changes: 6 additions & 0 deletions assembly/api/descriptors/kapua-api-jetty.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,10 @@
</excludes>
</fileSet>
</fileSets>
<files>
<file>
<source>${project.build.directory}/tmp/openapi.yaml</source>
<outputDirectory>var/opt/jetty/webapps/root/doc</outputDirectory>
</file>
</files>
</assembly>
76 changes: 76 additions & 0 deletions assembly/api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
<packaging>pom</packaging>
<artifactId>kapua-assembly-api</artifactId>

<properties>
<nodejs.version>10.16.3</nodejs.version>
</properties>

<dependencies>

<dependency>
Expand Down Expand Up @@ -222,6 +226,31 @@

<build>
<plugins>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<executions>
<execution>
<id>install-node-and-npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
</execution>
<execution>
<id>install-swagger-cli</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>install -g swagger-cli</arguments>
</configuration>
</execution>
</executions>
<configuration>
<nodeVersion>v${nodejs.version}</nodeVersion>
<installDirectory>target</installDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
Expand All @@ -244,7 +273,54 @@
</artifactItems>
</configuration>
</execution>
<execution>
<id>unpack-openapi</id>
<phase>prepare-package</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.eclipse.kapua</groupId>
<artifactId>kapua-rest-api-resources</artifactId>
<version>${project.version}</version>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}/tmp</outputDirectory>
<includes>openapi/**/*</includes>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>copy-openapi</id>
<goals>
<goal>exec</goal>
</goals>
<phase>prepare-package</phase>
</execution>
</executions>
<configuration>
<executable>${project.build.directory}/bin/swagger-cli</executable>
<environmentVariables>
<PATH>$PATH:${project.build.directory}/node</PATH>
</environmentVariables>
<arguments>
<argument>bundle</argument>
<argument>--dereference</argument>
<argument>-t</argument>
<argument>yaml</argument>
<argument>-o</argument>
<argument>${project.build.directory}/tmp/openapi.yaml</argument>
<argument>${project.build.directory}/tmp/openapi/openapi.yaml</argument>
</arguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
2 changes: 1 addition & 1 deletion assembly/api/resources/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<script>
window.onload = function() {
window.ui = SwaggerUIBundle({
url: "../v1/swagger.json",
url: "./openapi.yaml",
dom_id: '#swagger-ui',
deepLinking: true,
presets: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
*******************************************************************************/
package org.eclipse.kapua.message;

import io.swagger.annotations.ApiModelProperty;
import org.eclipse.kapua.message.device.data.KapuaDataMessage;
import org.eclipse.kapua.message.xml.MessageXmlRegistry;
import org.eclipse.kapua.model.id.KapuaId;
Expand Down Expand Up @@ -76,7 +75,6 @@ public interface KapuaMessage<C extends KapuaChannel, P extends KapuaPayload> ex
*/
@XmlElement(name = "scopeId")
@XmlJavaTypeAdapter(KapuaIdAdapter.class)
@ApiModelProperty(dataType = "string")
KapuaId getScopeId();

/**
Expand Down Expand Up @@ -112,7 +110,6 @@ public interface KapuaMessage<C extends KapuaChannel, P extends KapuaPayload> ex
*/
@XmlElement(name = "deviceId")
@XmlJavaTypeAdapter(KapuaIdAdapter.class)
@ApiModelProperty(dataType = "string")
KapuaId getDeviceId();

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
*******************************************************************************/
package org.eclipse.kapua.message;

import io.swagger.annotations.ApiModelProperty;
import org.eclipse.kapua.commons.util.Payloads;
import org.eclipse.kapua.message.xml.MessageXmlRegistry;
import org.eclipse.kapua.message.xml.MetricsXmlAdapter;
Expand Down Expand Up @@ -62,7 +61,6 @@ public interface KapuaPayload extends Payload {
*/
@XmlElement(name = "body")
@XmlJavaTypeAdapter(BinaryXmlAdapter.class)
@ApiModelProperty(dataType = "string")
byte[] getBody();

/**
Expand Down
20 changes: 13 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@

<logback.version>1.2.3</logback.version>
<snakeyaml.version>1.15</snakeyaml.version>
<swagger.version>1.5.12</swagger.version>
<cucumber.version>1.2.4</cucumber.version>
<spotify.version>8.15.1</spotify.version>
<elasticsearch.version>5.3.0</elasticsearch.version>
Expand Down Expand Up @@ -110,6 +109,7 @@
<maven-dependency-plugin.version>3.0.1</maven-dependency-plugin.version>
<maven-deploy-plugin.version>2.8.2</maven-deploy-plugin.version>
<maven-enforcer-plugin.version>1.4.1</maven-enforcer-plugin.version>
<maven-frontend-plugin.version>1.8.0</maven-frontend-plugin.version>
<maven-gpg-plugin.version>1.6</maven-gpg-plugin.version>
<maven-install-plugin.version>2.5.2</maven-install-plugin.version>
<maven-javadoc-plugin.version>2.10.4</maven-javadoc-plugin.version>
Expand All @@ -124,6 +124,7 @@
<dependency-check-maven.version>1.4.5</dependency-check-maven.version>
<docker-maven-plugin.version>0.24.0</docker-maven-plugin.version>
<eclipse-lifecycle-mapping.version>1.0.0</eclipse-lifecycle-mapping.version>
<exec-maven-plugin.version>1.6.0</exec-maven-plugin.version>
<jacoco.version>0.7.9</jacoco.version>
<jacoco-extras.version>0.1.1</jacoco-extras.version>
<karaf-maven-plugin.version>4.1.1</karaf-maven-plugin.version>
Expand Down Expand Up @@ -413,7 +414,7 @@

<sourceDirectory>${project.basedir}</sourceDirectory>
<includes>**/*.java, **/*.xml</includes>
<excludes>**/target/**/*, **/.settings/**/*, maven/**/*, .maven/**/*, .idea/**/*</excludes>
<excludes>**/target/**/*, **/.settings/**/*, maven/**/*, .maven/**/*, .idea/**/*, **/node/**/*</excludes>
</configuration>
</plugin>
</plugins>
Expand Down Expand Up @@ -493,6 +494,16 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>${maven-frontend-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>${exec-maven-plugin.version}</version>
</plugin>
</plugins>
</build>

Expand Down Expand Up @@ -1248,11 +1259,6 @@
<artifactId>opencsv</artifactId>
<version>${opencsv.version}</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>${swagger.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.paho</groupId>
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,17 @@
*******************************************************************************/
package org.eclipse.kapua.app.api.core.exception.model;

import io.swagger.annotations.ApiModelProperty;
import org.eclipse.kapua.KapuaEntityNotFoundException;
import org.eclipse.kapua.model.id.KapuaId;
import org.eclipse.kapua.model.id.KapuaIdAdapter;

import javax.ws.rs.core.Response.Status;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;

import org.eclipse.kapua.KapuaEntityNotFoundException;
import org.eclipse.kapua.model.id.KapuaId;
import org.eclipse.kapua.model.id.KapuaIdAdapter;

@XmlRootElement(name = "entityNotFoundExceptionInfo")
@XmlAccessorType(XmlAccessType.FIELD)
public class EntityNotFoundExceptionInfo extends ExceptionInfo {
Expand All @@ -32,7 +31,6 @@ public class EntityNotFoundExceptionInfo extends ExceptionInfo {

@XmlElement(name = "entityId")
@XmlJavaTypeAdapter(KapuaIdAdapter.class)
@ApiModelProperty(dataType = "string")
private KapuaId entityId;

protected EntityNotFoundExceptionInfo() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@
*******************************************************************************/
package org.eclipse.kapua.app.api.resources.v1.resources;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.Authorization;
import org.eclipse.kapua.KapuaEntityNotFoundException;
import org.eclipse.kapua.app.api.resources.v1.resources.model.CountResult;
import org.eclipse.kapua.app.api.resources.v1.resources.model.EntityId;
Expand Down Expand Up @@ -48,7 +44,6 @@
*
* @since 1.0.0
*/
@Api(value = "Access Info", authorizations = {@Authorization(value = "kapuaAccessToken")})
@Path("{scopeId}/accessinfos")
public class AccessInfos extends AbstractKapuaResource {

Expand All @@ -69,15 +64,11 @@ public class AccessInfos extends AbstractKapuaResource {
*/
@GET
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@ApiOperation(nickname = "accessInfoSimpleQuery",
value = "Gets the AccessInfo list in the scope.",
notes = "Gets the AccessInfo list in the scope. The query parameter userId is optional and can be used to filter results",
response = AccessInfoListResult.class)
public AccessInfoListResult simpleQuery(
@ApiParam(value = "The ScopeId in which to search results", required = true, defaultValue = DEFAULT_SCOPE_ID) @PathParam("scopeId") ScopeId scopeId,
@ApiParam(value = "The optional User id to filter results") @QueryParam("userId") EntityId userId,
@ApiParam(value = "The result set offset", defaultValue = "0") @QueryParam("offset") @DefaultValue("0") int offset,
@ApiParam(value = "The result set limit", defaultValue = "50") @QueryParam("limit") @DefaultValue("50") int limit) throws Exception {
@PathParam("scopeId") ScopeId scopeId,
@QueryParam("userId") EntityId userId,
@QueryParam("offset") @DefaultValue("0") int offset,
@QueryParam("limit") @DefaultValue("50") int limit) throws Exception {

AccessInfoQuery query = accessInfoFactory.newQuery(scopeId);

Expand Down Expand Up @@ -106,13 +97,9 @@ public AccessInfoListResult simpleQuery(
@Path("_query")
@Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
@ApiOperation(nickname = "accessInfoQuery",
value = "Queries the AccessInfos",
notes = "Queries the AccessInfos with the given AccessInfoQuery parameter returning all matching AccessInfos",
response = AccessInfoListResult.class)
public AccessInfoListResult query(
@ApiParam(value = "The ScopeId in which to search results", required = true, defaultValue = DEFAULT_SCOPE_ID) @PathParam("scopeId") ScopeId scopeId,
@ApiParam(value = "The AccessInfoQuery to use to filter results", required = true) AccessInfoQuery query) throws Exception {
@PathParam("scopeId") ScopeId scopeId,
AccessInfoQuery query) throws Exception {
query.setScopeId(scopeId);

return accessInfoService.query(query);
Expand All @@ -131,13 +118,9 @@ public AccessInfoListResult query(
@Path("_count")
@Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
@ApiOperation(nickname = "accessInfoCount",
value = "Counts the AccessInfos",
notes = "Counts the AccessInfos with the given AccessInfoQuery parameter returning the number of matching AccessInfos",
response = CountResult.class)
public CountResult count(
@ApiParam(value = "The ScopeId in which to count results", required = true, defaultValue = DEFAULT_SCOPE_ID) @PathParam("scopeId") ScopeId scopeId,
@ApiParam(value = "The AccessInfoQuery to use to filter count results", required = true) AccessInfoQuery query) throws Exception {
@PathParam("scopeId") ScopeId scopeId,
AccessInfoQuery query) throws Exception {
query.setScopeId(scopeId);

return new CountResult(accessInfoService.count(query));
Expand All @@ -156,13 +139,9 @@ public CountResult count(
@POST
@Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
@ApiOperation(nickname = "accessInfoCreate",
value = "Creates a new AccessInfo",
notes = "Creates a new AccessInfo based on the information provided in AccessInfoCreator parameter",
response = AccessInfo.class)
public AccessInfo create(
@ApiParam(value = "The ScopeId in which to create the AccessInfo", required = true, defaultValue = DEFAULT_SCOPE_ID) @PathParam("scopeId") ScopeId scopeId, //
@ApiParam(value = "Provides the information for the new AccessInfo to be created", required = true) AccessInfoCreator accessInfoCreator) throws Exception {
@PathParam("scopeId") ScopeId scopeId, //
AccessInfoCreator accessInfoCreator) throws Exception {
accessInfoCreator.setScopeId(scopeId);

return accessInfoService.create(accessInfoCreator);
Expand All @@ -180,13 +159,9 @@ public AccessInfo create(
@GET
@Path("{accessInfoId}")
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@ApiOperation(nickname = "accessInfoFind",
value = "Gets an AccessInfo",
notes = "Gets the AccessInfo specified by the accessInfoId path parameter",
response = AccessInfo.class)
public AccessInfo find(
@ApiParam(value = "The ScopeId of the requested AccessInfo.", required = true, defaultValue = DEFAULT_SCOPE_ID) @PathParam("scopeId") ScopeId scopeId,
@ApiParam(value = "The id of the requested AccessInfo", required = true) @PathParam("accessInfoId") EntityId accessInfoId) throws Exception {
@PathParam("scopeId") ScopeId scopeId,
@PathParam("accessInfoId") EntityId accessInfoId) throws Exception {
AccessInfo accessInfo = accessInfoService.find(scopeId, accessInfoId);

if (accessInfo == null) {
Expand All @@ -205,12 +180,11 @@ public AccessInfo find(
* @throws Exception Whenever something bad happens. See specific {@link KapuaService} exceptions.
* @since 1.0.0
*/
@ApiOperation(nickname = "accessInfoDelete", value = "Deletes an AccessInfo", notes = "Deletes the AccessInfo specified by the accessInfoId path parameter")
@DELETE
@Path("{accessInfoId}")
public Response deleteAccessInfo(
@ApiParam(value = "The ScopeId in which to create the AccessInfo", required = true, defaultValue = DEFAULT_SCOPE_ID) @PathParam("scopeId") ScopeId scopeId,
@ApiParam(value = "The id of the AccessInfo to delete", required = true) @PathParam("accessInfoId") EntityId accessInfoId) throws Exception {
@PathParam("scopeId") ScopeId scopeId,
@PathParam("accessInfoId") EntityId accessInfoId) throws Exception {
accessInfoService.delete(scopeId, accessInfoId);

return returnOk();
Expand Down
Loading