Skip to content

Commit

Permalink
Disable Swagger-UI + eliminate "duplicate operation ID" warnings in Q…
Browse files Browse the repository at this point in the history
…uarkus tests (#9340)

Disable the Swagger-UI in Quarkus, because the OpenAPI path "mismatches" between the interfaces in the `org.projectnessie.api.v1/2.http` packages and the implementations in the `org.projectnessie.services.rest` package. Those do either produce duplicate entries in the Swagger UI or, when only including the implementations via `mp.openapi.scan.include`, no entries. Also, the Swagger UI is rather a dev-mode thing and is only available on the Quarkus management port and therefore not publicly available. Also disables the Quarkus provided download of the OpenAPI yaml and replaced it with a download of the `openapi.yaml` from `:nessie-model`.
  • Loading branch information
snazy authored Aug 15, 2024
1 parent f91a1dd commit 9b64ede
Show file tree
Hide file tree
Showing 11 changed files with 75 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import jakarta.ws.rs.core.Response;
import java.io.IOException;
import java.util.Map;
import org.eclipse.microprofile.openapi.annotations.Operation;
import org.jboss.resteasy.reactive.server.ServerExceptionMapper;
import org.projectnessie.api.v2.params.ParsedReference;
import org.projectnessie.catalog.formats.iceberg.rest.IcebergCatalogOperation;
Expand Down Expand Up @@ -63,6 +64,7 @@ public Response mapException(Exception ex) {
}

/** Exposes the Iceberg REST configuration for the Nessie default branch. */
@Operation(operationId = "iceberg.v1.getConfig")
@GET
@Path("/v1/config")
public IcebergConfigResponse getConfig(@QueryParam("warehouse") String warehouse) {
Expand All @@ -73,6 +75,7 @@ public IcebergConfigResponse getConfig(@QueryParam("warehouse") String warehouse
* Exposes the Iceberg REST configuration for the named Nessie {@code reference} in the
* {@code @Path} parameter.
*/
@Operation(operationId = "iceberg.v1.getConfig.reference")
@GET
@Path("{reference}/v1/config")
public IcebergConfigResponse getConfig(
Expand All @@ -83,6 +86,7 @@ public IcebergConfigResponse getConfig(
.build();
}

@Operation(operationId = "iceberg.v1.getToken")
@POST
@Path("/v1/oauth/tokens")
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
Expand All @@ -99,6 +103,7 @@ public Response getToken() {
.build();
}

@Operation(operationId = "iceberg.v1.getToken.reference")
@POST
@Path("/{reference}/v1/oauth/tokens")
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
Expand All @@ -107,6 +112,7 @@ public Response getToken(@PathParam("reference") String ignored) {
return getToken();
}

@Operation(operationId = "iceberg.v1.commitTransaction")
@POST
@Path("/v1/{prefix}/transactions/commit")
@Blocking
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import java.util.List;
import java.util.Map;
import java.util.stream.Stream;
import org.eclipse.microprofile.openapi.annotations.Operation;
import org.jboss.resteasy.reactive.server.ServerExceptionMapper;
import org.projectnessie.api.v2.params.ParsedReference;
import org.projectnessie.catalog.formats.iceberg.meta.IcebergNamespace;
Expand Down Expand Up @@ -68,13 +69,13 @@
public class IcebergApiV1NamespaceResource extends IcebergApiV1ResourceBase {

@Inject IcebergErrorMapper errorMapper;
@Inject IcebergConfigurer icebergConfigurer;

@ServerExceptionMapper
public Response mapException(Exception ex) {
return errorMapper.toResponse(ex, IcebergEntityKind.NAMESPACE);
}

@Operation(operationId = "iceberg.v1.createNamespace")
@POST
@Path("/v1/{prefix}/namespaces")
@Blocking
Expand All @@ -101,6 +102,7 @@ public IcebergCreateNamespaceResponse createNamespace(
.build();
}

@Operation(operationId = "iceberg.v1.dropNamespace")
@DELETE
@Path("/v1/{prefix}/namespaces/{namespace}")
@Blocking
Expand All @@ -117,6 +119,7 @@ public void dropNamespace(
.delete();
}

@Operation(operationId = "iceberg.v1.listNamespaces")
@GET
@Path("/v1/{prefix}/namespaces")
@Blocking
Expand Down Expand Up @@ -148,6 +151,7 @@ public IcebergListNamespacesResponse listNamespaces(
return response.build();
}

@Operation(operationId = "iceberg.v1.namespaceExists")
@HEAD
@Path("/v1/{prefix}/namespaces/{namespace}")
@Blocking
Expand All @@ -164,6 +168,7 @@ public void namespaceExists(
.get();
}

@Operation(operationId = "iceberg.v1.loadNamespaceMetadata")
@GET
@Path("/v1/{prefix}/namespaces/{namespace}")
@Blocking
Expand Down Expand Up @@ -235,6 +240,7 @@ public IcebergGetNamespaceResponse loadNamespaceMetadata(
.build();
}

@Operation(operationId = "iceberg.v1.updateNamespaceProperties")
@POST
@Path("/v1/{prefix}/namespaces/{namespace}/properties")
@Blocking
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import java.time.Clock;
import java.util.List;
import java.util.Optional;
import org.eclipse.microprofile.openapi.annotations.Operation;
import org.jboss.resteasy.reactive.server.ServerExceptionMapper;
import org.projectnessie.catalog.files.api.RequestSigner;
import org.projectnessie.catalog.formats.iceberg.rest.IcebergS3SignRequest;
Expand Down Expand Up @@ -67,6 +68,7 @@ public Response mapException(Exception ex) {
return errorMapper.toResponse(ex, IcebergEntityKind.UNKNOWN);
}

@Operation(operationId = "iceberg.v1.s3sign")
@POST
@Path("/v1/{prefix}/s3-sign/{identifier}")
@Blocking
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
import java.util.Map;
import java.util.Optional;
import java.util.function.ToIntFunction;
import org.eclipse.microprofile.openapi.annotations.Operation;
import org.jboss.resteasy.reactive.server.ServerExceptionMapper;
import org.projectnessie.api.v2.params.ParsedReference;
import org.projectnessie.catalog.formats.iceberg.meta.IcebergJson;
Expand Down Expand Up @@ -101,7 +102,8 @@
import org.projectnessie.model.ContentKey;
import org.projectnessie.model.ContentResponse;
import org.projectnessie.model.IcebergTable;
import org.projectnessie.model.Operation;
import org.projectnessie.model.Operation.Delete;
import org.projectnessie.model.Operation.Put;
import org.projectnessie.storage.uri.StorageUri;

/** Handles Iceberg REST API v1 endpoints that are associated with tables. */
Expand All @@ -119,6 +121,7 @@ public Response mapException(Exception ex) {
return errorMapper.toResponse(ex, IcebergEntityKind.TABLE);
}

@Operation(operationId = "iceberg.v1.loadTable")
@GET
@Path("/v1/{prefix}/namespaces/{namespace}/tables/{table}")
@Blocking
Expand Down Expand Up @@ -250,6 +253,7 @@ private ContentResponse fetchIcebergTable(TableRef tableRef, boolean forWrite)
return fetchIcebergEntity(tableRef, ICEBERG_TABLE, "table", forWrite);
}

@Operation(operationId = "iceberg.v1.createTable")
@POST
@Path("/v1/{prefix}/namespaces/{namespace}/tables")
@Blocking
Expand Down Expand Up @@ -342,6 +346,7 @@ public Uni<IcebergCreateTableResponse> createTable(
true));
}

@Operation(operationId = "iceberg.v1.registerTable")
@POST
@Path("/v1/{prefix}/namespaces/{namespace}/register")
@Blocking
Expand Down Expand Up @@ -389,7 +394,7 @@ public Uni<IcebergLoadTableResponse> registerTable(
format(
"Register Iceberg table '%s' from '%s'",
ctr.contentKey(), registerTableRequest.metadataLocation())))
.operation(Operation.Put.of(ctr.contentKey(), newContent))
.operation(Put.of(ctr.contentKey(), newContent))
.commitWithResponse();

return this.loadTable(
Expand Down Expand Up @@ -436,7 +441,7 @@ public Uni<IcebergLoadTableResponse> registerTable(
format(
"Register Iceberg table '%s' from '%s'",
tableRef.contentKey(), registerTableRequest.metadataLocation())))
.operation(Operation.Put.of(tableRef.contentKey(), newContent))
.operation(Put.of(tableRef.contentKey(), newContent))
.commitWithResponse();

return this.loadTable(
Expand All @@ -452,6 +457,7 @@ public Uni<IcebergLoadTableResponse> registerTable(
true);
}

@Operation(operationId = "iceberg.v1.dropTable")
@DELETE
@Path("/v1/{prefix}/namespaces/{namespace}/tables/{table}")
@Blocking
Expand All @@ -470,10 +476,11 @@ public void dropTable(
.commitMultipleOperations()
.branch(ref)
.commitMeta(fromMessage(format("Drop ICEBERG_TABLE %s", tableRef.contentKey())))
.operation(Operation.Delete.of(tableRef.contentKey()))
.operation(Delete.of(tableRef.contentKey()))
.commitWithResponse();
}

@Operation(operationId = "iceberg.v1.listTables")
@GET
@Path("/v1/{prefix}/namespaces/{namespace}/tables")
@Blocking
Expand Down Expand Up @@ -509,6 +516,7 @@ public void renameTable(
renameContent(prefix, renameTableRequest, ICEBERG_TABLE);
}

@Operation(operationId = "iceberg.v1.tableExists")
@HEAD
@Path("/v1/{prefix}/namespaces/{namespace}/tables/{table}")
@Blocking
Expand All @@ -522,6 +530,7 @@ public void tableExists(
fetchIcebergTable(tableRef, false);
}

@Operation(operationId = "iceberg.v1.tableMetrics")
@POST
@Path("/v1/{prefix}/namespaces/{namespace}/tables/{table}/metrics")
@Blocking
Expand All @@ -544,6 +553,7 @@ private void pushMetrics(TableRef tableRef, IcebergMetricsReport report) {
// TODO note that metrics for "staged tables" are also received, even if those do not yet exist
}

@Operation(operationId = "iceberg.v1.updateTable")
@POST
@Path("/v1/{prefix}/namespaces/{namespace}/tables/{table}")
@Blocking
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import org.eclipse.microprofile.openapi.annotations.Operation;
import org.jboss.resteasy.reactive.server.ServerExceptionMapper;
import org.projectnessie.catalog.formats.iceberg.meta.IcebergViewMetadata;
import org.projectnessie.catalog.formats.iceberg.rest.IcebergCommitViewRequest;
Expand All @@ -67,7 +68,7 @@
import org.projectnessie.model.ContentKey;
import org.projectnessie.model.ContentResponse;
import org.projectnessie.model.IcebergView;
import org.projectnessie.model.Operation;
import org.projectnessie.model.Operation.Delete;

/** Handles Iceberg REST API v1 endpoints that are associated with views. */
@RequestScoped
Expand All @@ -83,6 +84,7 @@ public Response mapException(Exception ex) {
return errorMapper.toResponse(ex, IcebergEntityKind.VIEW);
}

@Operation(operationId = "iceberg.v1.createView")
@POST
@Path("/v1/{prefix}/namespaces/{namespace}/views")
@Blocking
Expand Down Expand Up @@ -137,6 +139,7 @@ private IcebergLoadViewResponse loadViewResult(
return builder.metadata(viewMetadata).metadataLocation(metadataLocation).build();
}

@Operation(operationId = "iceberg.v1.dropView")
@DELETE
@Path("/v1/{prefix}/namespaces/{namespace}/views/{view}")
@Blocking
Expand All @@ -155,7 +158,7 @@ public void dropView(
.commitMultipleOperations()
.branch(ref)
.commitMeta(fromMessage(format("Drop ICEBERG_VIEW %s", tableRef.contentKey())))
.operation(Operation.Delete.of(tableRef.contentKey()))
.operation(Delete.of(tableRef.contentKey()))
.commitWithResponse();
}

Expand All @@ -164,6 +167,7 @@ private ContentResponse fetchIcebergView(TableRef tableRef, boolean forWrite)
return fetchIcebergEntity(tableRef, ICEBERG_VIEW, "view", forWrite);
}

@Operation(operationId = "iceberg.v1.listViews")
@GET
@Path("/v1/{prefix}/namespaces/{namespace}/views")
@Blocking
Expand All @@ -189,6 +193,7 @@ public IcebergListTablesResponse listViews(
return response.build();
}

@Operation(operationId = "iceberg.v1.loadView")
@GET
@Path("/v1/{prefix}/namespaces/{namespace}/views/{view}")
@Blocking
Expand All @@ -212,6 +217,7 @@ private Uni<IcebergLoadViewResponse> loadView(TableRef tableRef) throws NessieNo
.map(snap -> loadViewResultFromSnapshotResponse(snap, IcebergLoadViewResponse.builder()));
}

@Operation(operationId = "iceberg.v1.renameView")
@POST
@Path("/v1/{prefix}/views/rename")
@Blocking
Expand All @@ -223,6 +229,7 @@ public void renameView(
renameContent(prefix, renameTableRequest, ICEBERG_VIEW);
}

@Operation(operationId = "iceberg.v1.viewExists")
@HEAD
@Path("/v1/{prefix}/namespaces/{namespace}/views/{view}")
@Blocking
Expand All @@ -236,6 +243,7 @@ public void viewExists(
fetchIcebergView(tableRef, false);
}

@Operation(operationId = "iceberg.v1.updateView")
@POST
@Path("/v1/{prefix}/namespaces/{namespace}/views/{view}")
@Blocking
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import jakarta.ws.rs.QueryParam;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import org.eclipse.microprofile.openapi.annotations.Operation;
import org.jboss.resteasy.reactive.server.ServerExceptionMapper;
import org.projectnessie.catalog.service.rest.IcebergErrorMapper.IcebergEntityKind;

Expand All @@ -46,6 +47,7 @@ public Response mapException(Exception ex) {
return errorMapper.toResponse(ex, IcebergEntityKind.UNKNOWN);
}

@Operation(operationId = "iceberg-ext.v1.trinoConfig")
@GET
@Path("/v1/client-template/trino")
@Produces(MediaType.TEXT_PLAIN)
Expand All @@ -54,6 +56,7 @@ public Response getTrinoConfig(
return getTrinoConfig(null, warehouse, format);
}

@Operation(operationId = "iceberg-ext.v1.trinoConfig.reference")
@GET
@Path("{reference}/v1/client-template/trino")
@Produces(MediaType.WILDCARD)
Expand Down
31 changes: 11 additions & 20 deletions servers/quarkus-server/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ dependencies {
compileOnly(libs.immutables.value.annotations)
annotationProcessor(libs.immutables.value.processor)

openapiSource(project(":nessie-model-quarkus", "openapiSource"))
openapiSource(project(":nessie-model-quarkus")) { isTransitive = false }

testFixturesApi(platform(libs.junit.bom))
testFixturesApi(libs.bundles.junit.testing)
Expand Down Expand Up @@ -161,26 +161,22 @@ dependencies {
intTestImplementation("software.amazon.awssdk:sts")
}

val openApiSpecDir = layout.buildDirectory.dir("openapi-extra")

val pullOpenApiSpec by
tasks.registering(Sync::class) {
destinationDir = openApiSpecDir.get().asFile
from(openapiSource) { include("openapi.yaml") }
inputs.files(openapiSource)
destinationDir = layout.buildDirectory.dir("resources/openapi").get().asFile
from(provider { zipTree(openapiSource.singleFile) }) {
include("META-INF/openapi/**")
eachFile { path = "META-INF/resources/nessie-openapi/${file.name}" }
}
}

sourceSets.named("main") { resources.srcDir(pullOpenApiSpec) }

tasks.named("processResources") { dependsOn(pullOpenApiSpec) }

quarkus {
quarkusBuildProperties.put("quarkus.package.type", quarkusPackageType())
quarkusBuildProperties.put(
"quarkus.smallrye-openapi.store-schema-directory",
layout.buildDirectory.asFile.map { it.resolve("openapi") }.get().toString()
)
quarkusBuildProperties.put(
"quarkus.smallrye-openapi.additional-docs-directory",
openApiSpecDir.get().toString()
)
quarkusBuildProperties.put("quarkus.smallrye-openapi.info-version", project.version.toString())
quarkusBuildProperties.put("quarkus.smallrye-openapi.auto-add-security", "false")
// Pull manifest attributes from the "main" `jar` task to get the
// release-information into the jars generated by Quarkus.
quarkusBuildProperties.putAll(
Expand All @@ -202,11 +198,6 @@ val quarkusBuild = tasks.named<QuarkusBuild>("quarkusBuild")

quarkusDependenciesBuild.configure { dependsOn("processJandexIndex") }

quarkusAppPartsBuild.configure {
dependsOn(pullOpenApiSpec)
inputs.files(openapiSource)
}

// Expose runnable jar via quarkusRunner configuration for integration-tests that require the
// server.
artifacts {
Expand Down
Loading

0 comments on commit 9b64ede

Please sign in to comment.