Skip to content

Commit

Permalink
Update to swagger 2
Browse files Browse the repository at this point in the history
  • Loading branch information
alainbodiguel committed May 17, 2024
1 parent 75124fe commit 3412e9d
Show file tree
Hide file tree
Showing 30 changed files with 2,641 additions and 1,594 deletions.
9 changes: 4 additions & 5 deletions arlas-tagger-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@
<!-- ____________________________________________________ -->
<!-- KAFKA -->
<!-- ____________________________________________________ -->
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
<version>${kafka.version}</version>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>connect-json</artifactId>
Expand All @@ -47,6 +42,10 @@
<artifactId>jackson-datatype-jdk8</artifactId>
<groupId>com.fasterxml.jackson.datatype</groupId>
</exclusion>
<exclusion>
<artifactId>slf4j-api</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.ws.rs.NotFoundException;
import jakarta.ws.rs.NotFoundException;
import java.io.IOException;
import java.util.Optional;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,43 @@
import io.arlas.tagger.model.response.UpdateResponse;
import io.arlas.tagger.service.ManagedKafkaConsumers;
import io.arlas.tagger.util.TagRequestFieldsExtractor;
import io.swagger.annotations.*;
import io.swagger.v3.oas.annotations.ExternalDocumentation;
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.info.Contact;
import io.swagger.v3.oas.annotations.info.Info;
import io.swagger.v3.oas.annotations.info.License;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.servers.Server;
import io.swagger.v3.oas.annotations.tags.Tag;

import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import jakarta.ws.rs.*;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import java.util.Optional;

import static io.arlas.commons.rest.utils.ServerConstants.*;

@Path("/write")
@Api(value = "/write")
@SwaggerDefinition(
info = @Info(contact = @Contact(email = "[email protected]", name = "Gisaia", url = "http://www.gisaia.com/"),
title = "ARLAS Tagger API",
@Tag(name="write", description="Tagger API")
@OpenAPIDefinition(
info = @Info(
title = "ARLAS Tagger APIs",
description = "(Un)Tag fields of ARLAS collections",
license = @License(name = "Apache 2.0", url = "https://www.apache.org/licenses/LICENSE-2.0.html"),
contact = @Contact(email = "[email protected]", name = "Gisaia", url = "http://www.gisaia.com/"),
version = "API_VERSION"),
schemes = { SwaggerDefinition.Scheme.HTTP, SwaggerDefinition.Scheme.HTTPS })
externalDocs = @ExternalDocumentation(
description = "API documentation",
url="https://docs.arlas.io/arlas-api/"),
servers = {
@Server(url = "/arlas_tagger", description = "default server")
}
)

public class TagRESTService {
public static final String UTF8JSON = MediaType.APPLICATION_JSON + ";charset=utf-8";
Expand All @@ -67,16 +86,25 @@ public TagRESTService(ManagedKafkaConsumers consumersManager, Long statusTimeout
@POST
@Produces(UTF8JSON)
@Consumes(UTF8JSON)
@ApiOperation(value = "Tag", produces = UTF8JSON, notes = Documentation.TAG_OPERATION, consumes = UTF8JSON, response = UpdateResponse.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Successful operation", response = UpdateResponse.class),
@ApiResponse(code = 500, message = "Arlas Server Error.", response = Error.class), @ApiResponse(code = 400, message = "Bad request.", response = Error.class) })
@Operation(
summary = "Tag",
description = Documentation.TAG_OPERATION
)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Successful operation",
content = @Content(schema = @Schema(implementation = UpdateResponse.class))),
@ApiResponse(responseCode = "500", description = "Arlas Server Error.",
content = @Content(schema = @Schema(implementation = Error.class))),
@ApiResponse(responseCode = "400", description = "Bad request.",
content = @Content(schema = @Schema(implementation = Error.class)))
})
public Response tagPost(
// --------------------------------------------------------
// ----------------------- PATH -----------------------
// --------------------------------------------------------
@ApiParam(
@Parameter(
name = "collection",
value = "collection",
description = "collection",
required = true)
@PathParam(value = "collection") String collection,
// --------------------------------------------------------
Expand All @@ -88,20 +116,20 @@ public Response tagPost(
// ----------------------- FILTER -----------------------
// --------------------------------------------------------

@ApiParam(hidden = true)
@HeaderParam(value= PARTITION_FILTER) String partitionFilter,
@Parameter(hidden = true)
@HeaderParam(value = PARTITION_FILTER) String partitionFilter,

@ApiParam(hidden = true)
@Parameter(hidden = true)
@HeaderParam(value = COLUMN_FILTER) String columnFilter,

@ApiParam(hidden = true)
@Parameter(hidden = true)
@HeaderParam(value = ARLAS_ORGANISATION) String organisations,

// --------------------------------------------------------
// ----------------------- FORM -----------------------
// --------------------------------------------------------
@ApiParam(name ="pretty", value=Documentation.FORM_PRETTY,
defaultValue = "false")
@Parameter(name ="pretty", description=Documentation.FORM_PRETTY,
schema = @Schema(defaultValue = "false"))
@QueryParam(value="pretty") Boolean pretty
) throws ArlasException {
assertColumnFilter(collection, tagRequest, Optional.ofNullable(columnFilter), Optional.ofNullable(organisations));
Expand All @@ -118,30 +146,38 @@ public Response tagPost(
@POST
@Produces(UTF8JSON)
@Consumes(UTF8JSON)
@ApiOperation(value = "TagReplay", produces = UTF8JSON, notes = Documentation.TAG_REPLAY, consumes = UTF8JSON, response = Long.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Successful operation", response = Long.class),
@ApiResponse(code = 500, message = "Arlas Server Error.", response = Error.class), @ApiResponse(code = 400, message = "Bad request.", response = Error.class) })
@Operation(
summary = "TagReplay",
description = Documentation.TAG_REPLAY
)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Successful operation",
content = @Content(schema = @Schema(implementation = Long.class))),
@ApiResponse(responseCode = "500", description = "Arlas Server Error.",
content = @Content(schema = @Schema(implementation = Error.class))),
@ApiResponse(responseCode = "400", description = "Bad request.",
content = @Content(schema = @Schema(implementation = Error.class))) })
public Response tagReplay(
// --------------------------------------------------------
// ----------------------- PATH -----------------------
// --------------------------------------------------------
@ApiParam(
@Parameter(
name = "collection",
value = "collection",
description = "collection",
required = true)
@PathParam(value = "collection") String collection,
// --------------------------------------------------------
// ----------------------- SEARCH -----------------------
// --------------------------------------------------------
@ApiParam(name = "offset", value = Documentation.TAG_REPLAY_PARAM_OFFSET,
@Parameter(name = "offset", description = Documentation.TAG_REPLAY_PARAM_OFFSET,
required = true)
@QueryParam(value = "offset") Long offset,

// --------------------------------------------------------
// ----------------------- FORM -----------------------
// --------------------------------------------------------
@ApiParam(name ="pretty", value=Documentation.FORM_PRETTY,
defaultValue = "false")
@Parameter(name ="pretty", description=Documentation.FORM_PRETTY,
schema = @Schema(defaultValue = "false"))
@QueryParam(value="pretty") Boolean pretty
) {

Expand All @@ -154,16 +190,21 @@ public Response tagReplay(
@POST
@Produces(UTF8JSON)
@Consumes(UTF8JSON)
@ApiOperation(value = "Untag", produces = UTF8JSON, notes = Documentation.UNTAG_OPERATION, consumes = UTF8JSON, response = UpdateResponse.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Successful operation", response = UpdateResponse.class),
@ApiResponse(code = 500, message = "Arlas Server Error.", response = Error.class), @ApiResponse(code = 400, message = "Bad request.", response = Error.class) })
@Operation(summary = "Untag", description = Documentation.UNTAG_OPERATION)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Successful operation",
content = @Content(schema = @Schema(implementation = UpdateResponse.class))),
@ApiResponse(responseCode = "500", description = "Arlas Server Error.",
content = @Content(schema = @Schema(implementation = Error.class))),
@ApiResponse(responseCode = "400", description = "Bad request.",
content = @Content(schema = @Schema(implementation = Error.class))) })
public Response untagPost(
// --------------------------------------------------------
// ----------------------- PATH -----------------------
// --------------------------------------------------------
@ApiParam(
@Parameter(
name = "collection",
value = "collection",
description = "collection",
required = true)
@PathParam(value = "collection") String collection,
// --------------------------------------------------------
Expand All @@ -175,20 +216,20 @@ public Response untagPost(
// ----------------------- FILTER -----------------------
// --------------------------------------------------------

@ApiParam(hidden = true)
@HeaderParam(value=PARTITION_FILTER) String partitionFilter,
@Parameter(hidden = true)
@HeaderParam(value = PARTITION_FILTER) String partitionFilter,

@ApiParam(hidden = true)
@Parameter(hidden = true)
@HeaderParam(value = COLUMN_FILTER) String columnFilter,

@ApiParam(hidden = true)
@Parameter(hidden = true)
@HeaderParam(value = ARLAS_ORGANISATION) String organisations,

// --------------------------------------------------------
// ----------------------- FORM -----------------------
// --------------------------------------------------------
@ApiParam(name ="pretty", value=Documentation.FORM_PRETTY,
defaultValue = "false")
@Parameter(name ="pretty", description=Documentation.FORM_PRETTY,
schema = @Schema(defaultValue = "false"))
@QueryParam(value="pretty") Boolean pretty
) throws ArlasException {
assertColumnFilter(collection, tagRequest, Optional.ofNullable(columnFilter), Optional.ofNullable(organisations));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,42 @@
import io.arlas.tagger.model.request.TagRefRequest;
import io.arlas.tagger.model.response.UpdateResponse;
import io.arlas.tagger.service.TagExploreService;
import io.swagger.annotations.*;
import io.swagger.v3.oas.annotations.ExternalDocumentation;
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.info.Contact;
import io.swagger.v3.oas.annotations.info.Info;
import io.swagger.v3.oas.annotations.info.License;
import io.swagger.v3.oas.annotations.media.ArraySchema;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.servers.Server;
import io.swagger.v3.oas.annotations.tags.Tag;

import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import jakarta.ws.rs.*;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;

@Path("/status")
@Api(value = "/status")
@Tag(name="status", description="Tagger status API")
@OpenAPIDefinition(
info = @Info(
title = "ARLAS Tagger APIs",
description = "(Un)Tag fields of ARLAS collections",
license = @License(name = "Apache 2.0", url = "https://www.apache.org/licenses/LICENSE-2.0.html"),
contact = @Contact(email = "[email protected]", name = "Gisaia", url = "http://www.gisaia.com/"),
version = "API_VERSION"),
externalDocs = @ExternalDocumentation(
description = "API documentation",
url="https://docs.arlas.io/arlas-api/"),
servers = {
@Server(url = "/arlas_tagger", description = "default server")
}
)

public class TagStatusRESTService {
public static final String UTF8JSON = MediaType.APPLICATION_JSON + ";charset=utf-8";
private final TaggingStatus status;
Expand All @@ -49,27 +77,37 @@ public TagStatusRESTService(TagExploreService tagExploreService) {
@GET
@Produces(UTF8JSON)
@Consumes(UTF8JSON)
@ApiOperation(value = "TagStatus", produces = UTF8JSON, notes = Documentation.TAGSTATUS_OPERATION, consumes = UTF8JSON, response = UpdateResponse.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Successful operation", response = UpdateResponse.class),
@ApiResponse(code = 500, message = "Arlas Server Error.", response = Error.class), @ApiResponse(code = 400, message = "Bad request.", response = Error.class) })
@Operation(
summary = "TagStatus",
description = Documentation.TAGSTATUS_OPERATION
)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Successful operation",
content = @Content(schema = @Schema(implementation = UpdateResponse.class))),
@ApiResponse(responseCode = "500", description = "Arlas Server Error.",
content = @Content(schema = @Schema(implementation = Error.class))),
@ApiResponse(responseCode = "400", description = "Bad request.",
content = @Content(schema = @Schema(implementation = Error.class)))
})
public Response taggingGet(
// --------------------------------------------------------
// ----------------------- PATH -----------------------
// --------------------------------------------------------
@ApiParam(
@Parameter(
name = "collection",
value = "collection",
description = "collection",
required = true)
@PathParam(value = "collection") String collection,

@ApiParam(name = "id", value = Documentation.TAGSTATUS_PARAM_ID,
@Parameter(name = "id", description = Documentation.TAGSTATUS_PARAM_ID,
required = true)
@PathParam(value = "id") String id,
// --------------------------------------------------------
// ----------------------- FORM -----------------------
// --------------------------------------------------------
@ApiParam(name ="pretty", value=Documentation.FORM_PRETTY,
defaultValue = "false")
@Parameter(name ="pretty",
description=Documentation.FORM_PRETTY,
schema = @Schema(defaultValue = "false"))
@QueryParam(value="pretty") Boolean pretty
) {
return Response.ok(status.getStatus(id).orElseGet(UpdateResponse::new)).build();
Expand All @@ -80,24 +118,33 @@ public Response taggingGet(
@GET
@Produces(UTF8JSON)
@Consumes(UTF8JSON)
@ApiOperation(value = "TagList", produces = UTF8JSON, notes = Documentation.TAGLIST_OPERATION, consumes = UTF8JSON, response = TagRefRequest.class, responseContainer = "List")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Successful operation", response = TagRefRequest.class, responseContainer = "List"),
@ApiResponse(code = 500, message = "Arlas Server Error.", response = Error.class), @ApiResponse(code = 400, message = "Bad request.", response = Error.class) })
@Operation(
summary = "TagList",
description = Documentation.TAGLIST_OPERATION
)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Successful operation",
content = @Content(array = @ArraySchema(schema = @Schema(implementation = TagRefRequest.class)))),
@ApiResponse(responseCode = "500", description = "Arlas Server Error.",
content = @Content(schema = @Schema(implementation = Error.class))),
@ApiResponse(responseCode = "400", description = "Bad request.",
content = @Content(schema = @Schema(implementation = Error.class)))
})
public Response taggingGetList(
// --------------------------------------------------------
// ----------------------- PATH -----------------------
// --------------------------------------------------------
@ApiParam(
@Parameter(
name = "collection",
value = "collection",
description = "collection",
required = true)
@PathParam(value = "collection") String collection,

// --------------------------------------------------------
// ----------------------- FORM -----------------------
// --------------------------------------------------------
@ApiParam(name ="pretty", value=Documentation.FORM_PRETTY,
defaultValue = "false")
@Parameter(name ="pretty", description=Documentation.FORM_PRETTY,
schema = @Schema(defaultValue = "false"))
@QueryParam(value="pretty") Boolean pretty
) {

Expand Down
Loading

0 comments on commit 3412e9d

Please sign in to comment.