From c78f48849b0dffbf9b9a262d7133bf8dd79513bf Mon Sep 17 00:00:00 2001 From: Eric Wittmann Date: Wed, 7 Aug 2019 13:47:14 -0400 Subject: [PATCH] Now handling header params in the jx-rs generator Signed-off-by: Eric Wittmann --- .../hub/api/codegen/OpenApi2JaxRs.java | 34 +- .../hub/api/codegen/OpenApi2JaxRsTest.java | 8 + .../generated-api/pom.xml | 37 + .../org/example/api/ArtifactsResource.java | 370 +++++++ .../org/example/api/JaxRsApplication.java | 13 + .../java/org/example/api/RulesResource.java | 98 ++ .../example/api/beans/ArtifactMetaData.java | 320 ++++++ .../example/api/beans/EditableMetaData.java | 47 + .../main/java/org/example/api/beans/Rule.java | 62 ++ .../example/api/beans/VersionMetaData.java | 162 ++++ .../src/main/resources/META-INF/openapi.json | 913 ++++++++++++++++++ .../OpenApi2JaxRsTest/registry-api.json | 913 ++++++++++++++++++ 12 files changed, 2976 insertions(+), 1 deletion(-) create mode 100644 back-end/hub-codegen/src/test/resources/OpenApi2JaxRsTest/_expected-registryApi-full/generated-api/pom.xml create mode 100644 back-end/hub-codegen/src/test/resources/OpenApi2JaxRsTest/_expected-registryApi-full/generated-api/src/main/java/org/example/api/ArtifactsResource.java create mode 100644 back-end/hub-codegen/src/test/resources/OpenApi2JaxRsTest/_expected-registryApi-full/generated-api/src/main/java/org/example/api/JaxRsApplication.java create mode 100644 back-end/hub-codegen/src/test/resources/OpenApi2JaxRsTest/_expected-registryApi-full/generated-api/src/main/java/org/example/api/RulesResource.java create mode 100644 back-end/hub-codegen/src/test/resources/OpenApi2JaxRsTest/_expected-registryApi-full/generated-api/src/main/java/org/example/api/beans/ArtifactMetaData.java create mode 100644 back-end/hub-codegen/src/test/resources/OpenApi2JaxRsTest/_expected-registryApi-full/generated-api/src/main/java/org/example/api/beans/EditableMetaData.java create mode 100644 back-end/hub-codegen/src/test/resources/OpenApi2JaxRsTest/_expected-registryApi-full/generated-api/src/main/java/org/example/api/beans/Rule.java create mode 100644 back-end/hub-codegen/src/test/resources/OpenApi2JaxRsTest/_expected-registryApi-full/generated-api/src/main/java/org/example/api/beans/VersionMetaData.java create mode 100644 back-end/hub-codegen/src/test/resources/OpenApi2JaxRsTest/_expected-registryApi-full/generated-api/src/main/resources/META-INF/openapi.json create mode 100644 back-end/hub-codegen/src/test/resources/OpenApi2JaxRsTest/registry-api.json diff --git a/back-end/hub-codegen/src/main/java/io/apicurio/hub/api/codegen/OpenApi2JaxRs.java b/back-end/hub-codegen/src/main/java/io/apicurio/hub/api/codegen/OpenApi2JaxRs.java index ad75e3601..fb0f3c40b 100644 --- a/back-end/hub-codegen/src/main/java/io/apicurio/hub/api/codegen/OpenApi2JaxRs.java +++ b/back-end/hub-codegen/src/main/java/io/apicurio/hub/api/codegen/OpenApi2JaxRs.java @@ -342,6 +342,10 @@ private String generateJavaInterface(CodegenJavaInterface _interface) { paramBuilder.addAnnotation(AnnotationSpec.builder(ClassName.get("javax.ws.rs", "QueryParam")) .addMember("value", "$S", cgArgument.getName()).build()); } + if (cgArgument.getIn().equals("header")) { + paramBuilder.addAnnotation(AnnotationSpec.builder(ClassName.get("javax.ws.rs", "HeaderParam")) + .addMember("value", "$S", cgArgument.getName()).build()); + } methodBuilder.addParameter(paramBuilder.build()); } } @@ -560,7 +564,35 @@ private static String paramNameToJavaArgName(String paramName) { if (paramName == null) { return null; } - return paramName.replaceAll("[^a-zA-Z0-9_]", "_"); + String [] split = paramName.replaceAll("[^a-zA-Z0-9_]", "_").split("_"); + StringBuilder builder = new StringBuilder(); + boolean first = true; + for (String term : split) { + if (term.trim().length() == 0) { + continue; + } + if (first) { + builder.append(decapitalize(term)); + first = false; + } else { + builder.append(capitalize(term)); + } + } + return builder.toString(); + } + + private static String capitalize(String term) { + if (term.length() == 1) { + return term.toUpperCase(); + } + return term.substring(0, 1).toUpperCase() + term.substring(1); + } + + private static String decapitalize(String term) { + if (term.length() == 1) { + return term.toLowerCase(); + } + return term.substring(0, 1).toLowerCase() + term.substring(1); } /** diff --git a/back-end/hub-codegen/src/test/java/io/apicurio/hub/api/codegen/OpenApi2JaxRsTest.java b/back-end/hub-codegen/src/test/java/io/apicurio/hub/api/codegen/OpenApi2JaxRsTest.java index 52c980d60..18fe30375 100644 --- a/back-end/hub-codegen/src/test/java/io/apicurio/hub/api/codegen/OpenApi2JaxRsTest.java +++ b/back-end/hub-codegen/src/test/java/io/apicurio/hub/api/codegen/OpenApi2JaxRsTest.java @@ -60,6 +60,14 @@ public void testGenerateFull_GatewayApi() throws IOException { doFullTest("OpenApi2JaxRsTest/gateway-api.json", UpdateOnly.no, Reactive.no, "_expected-gatewayApi-full/generated-api", false); } + /** + * Test method for {@link io.apicurio.hub.api.codegen.OpenApi2JaxRs#generate()}. + */ + @Test + public void testGenerateFull_RegistryApi() throws IOException { + doFullTest("OpenApi2JaxRsTest/registry-api.json", UpdateOnly.no, Reactive.no, "_expected-registryApi-full/generated-api", false); + } + /** * Test method for {@link io.apicurio.hub.api.codegen.OpenApi2JaxRs#generate()}. */ diff --git a/back-end/hub-codegen/src/test/resources/OpenApi2JaxRsTest/_expected-registryApi-full/generated-api/pom.xml b/back-end/hub-codegen/src/test/resources/OpenApi2JaxRsTest/_expected-registryApi-full/generated-api/pom.xml new file mode 100644 index 000000000..eaac0d369 --- /dev/null +++ b/back-end/hub-codegen/src/test/resources/OpenApi2JaxRsTest/_expected-registryApi-full/generated-api/pom.xml @@ -0,0 +1,37 @@ + + + 4.0.0 + org.example.api + generated-api + 1.0.0 + jar + Apicurio Registry API + The Apicurio Registry project's primary REST API - used by clients to add and remove APIs and Schemas to the registry. + + + 1.8 + 1.8 + false + UTF-8 + + 1.0.2.Final + 2.9.8 + + + + + + com.fasterxml.jackson.core + jackson-annotations + ${version.com.fasterxml.jackson} + + + + org.jboss.spec.javax.ws.rs + jboss-jaxrs-api_2.1_spec + ${version.org.jboss.spec.javax.ws.jboss-jaxrs-api_2.1_spec} + + + diff --git a/back-end/hub-codegen/src/test/resources/OpenApi2JaxRsTest/_expected-registryApi-full/generated-api/src/main/java/org/example/api/ArtifactsResource.java b/back-end/hub-codegen/src/test/resources/OpenApi2JaxRsTest/_expected-registryApi-full/generated-api/src/main/java/org/example/api/ArtifactsResource.java new file mode 100644 index 000000000..f6079802b --- /dev/null +++ b/back-end/hub-codegen/src/test/resources/OpenApi2JaxRsTest/_expected-registryApi-full/generated-api/src/main/java/org/example/api/ArtifactsResource.java @@ -0,0 +1,370 @@ +package org.example.api; + +import java.lang.Integer; +import java.lang.String; +import java.util.List; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Request; +import org.example.api.beans.ArtifactMetaData; +import org.example.api.beans.EditableMetaData; +import org.example.api.beans.Rule; +import org.example.api.beans.VersionMetaData; + +/** + * A JAX-RS interface. An implementation of this interface must be provided. + */ +@Path("/artifacts") +public interface ArtifactsResource { + /** + * Creates a new artifact by POSTing the artifact content. The body of the request should + * be the raw content of the artifact. This will typically be in JSON format for *most* + * of the supported types, but may be in another format for a few (e.g. Protobuff). + * + * The registry will attempt to figure out what kind of artifact is being added from the + * following supported list: + * + * * Avro (avro) + * * Protobuff (protobuff) + * * JSON Schema (json) + * * OpenAPI (openapi) + * * AsyncAPI (asyncapi) + * + * Alternatively, the artifact type can be indicated by either explicitly specifying the + * type via the `X-Registry-ArtifactType` HTTP Request Header or by including a hint in the + * Request's `Content-Type`. + * + * For example: + * + * ``` + * Content-Type: application/json+avro + * ``` + * + */ + @POST + @Produces("application/json") + @Consumes({"application/json", "application/x-yaml"}) + ArtifactMetaData createArtifact( + @HeaderParam("X-Registry-ArtifactType") String xRegistryArtifactType, + @HeaderParam("X-Registry-ArtifactId") String xRegistryArtifactId, Request data); + + /** + * Returns the latest version of the artifact in its raw form. The `Content-Type` of the + * response will depend on what type of artifact it is. In most cases this will be + * `application/json` but for some types it may be different (e.g. *avro*). + * + * This operation may fail for one of the following reasons: + * + * * No artifact with this `artifactId` exists (HTTP error `404`) + * * A server error occurred (HTTP error `500`) + * + */ + @Path("/{artifactId}") + @GET + @Produces({"application/json", "application/x-yaml"}) + void getLatestArtifact(@PathParam("artifactId") String artifactId); + + /** + * Updates an artifact by uploading new content. The update could fail for a number + * of reasons including: + * + * * No artifact with the `artifactId` exists (HTTP error `404`) + * * The new content violates one of the rules configured for the artifact (HTTP error `400`) + * * A server error occurred (HTTP error `500`) + * + * When successful, this creates a new version of the artifact, making it the most recent + * (and therefore official) version of the artifact. + */ + @Path("/{artifactId}") + @PUT + @Produces("application/json") + @Consumes({"application/json", "application/x-yaml"}) + ArtifactMetaData updateArtifact(@PathParam("artifactId") String artifactId, Request data); + + /** + * Deletes an artifact completely, resulting in all versions of the artifact also being + * deleted. This may fail for one of the following reasons: + * + * * No artifact with the `artifactId` exists (HTTP error `404`) + * * A server error occurred (HTTP error `500`) + */ + @Path("/{artifactId}") + @DELETE + void deleteArtifact(@PathParam("artifactId") String artifactId); + + /** + * Returns a list of all version numbers for the artifact. + * + * This operation can fail for the following reasons: + * + * * No artifact with this `artifactId` exists (HTTP error `404`) + * * A server error occurred (HTTP error `500`) + * + */ + @Path("/{artifactId}/versions") + @GET + @Produces("application/json") + List listArtifactVersions(@PathParam("artifactId") String artifactId); + + /** + * Creates a new version of the artifact by uploading new content. The configured rules for + * the artifact will be applied, and if they all pass then the new content will be added + * as the most recent version of the artifact. If any of the rules fail then an error + * will be returned. + * + * The body of the request should be the raw content of the new artifact version. This + * will typically be in JSON format for *most* of the supported types, but may be in another + * format for a few (e.g. Protobuff). + * + * The registry will attempt to figure out what kind of artifact is being added from the + * following supported list: + * + * * Avro (avro) + * * Protobuff (protobuff) + * * JSON Schema (json) + * * OpenAPI (openapi) + * * AsyncAPI (asyncapi) + * + * Alternatively, the artifact type can be indicated by either explicitly specifying the + * type via the `X-Registry-ArtifactType` HTTP Request Header or by including a hint in the + * Request's `Content-Type`. + * + * For example: + * + * ``` + * Content-Type: application/json+avro + * ``` + * + * This operation can fail for the following reasons: + * + * * No artifact with this `artifactId` exists (HTTP error `404`) + * * A server error occurred (HTTP error `500`) + * + */ + @Path("/{artifactId}/versions") + @POST + @Produces("application/json") + @Consumes({"application/json", "application/x-yaml"}) + VersionMetaData createArtifactVersion(@PathParam("artifactId") String artifactId, + @HeaderParam("X-Registry-ArtifactType") String xRegistryArtifactType, Request data); + + /** + * Retrieves a single version of the artifact content. Both the `artifactId` and the + * unique `version` number must be provided. The `Content-Type` of the + * response will depend on what type of artifact it is. In most cases this will be + * `application/json` but for some types it may be different (e.g. *avro*). + * + * This operation can fail for the following reasons: + * + * * No artifact with this `artifactId` exists (HTTP error `404`) + * * No version with this `version` exists (HTTP error `404`) + * * A server error occurred (HTTP error `500`) + * + */ + @Path("/{artifactId}/versions/{version}") + @GET + @Produces({"application/json", "application/x-yaml"}) + void getArtifactVersion(@PathParam("version") Integer version, + @PathParam("artifactId") String artifactId); + + /** + * Deletes a single version of the artifact. Both the `artifactId` and the unique `version` + * are needed. If this is the only version of the artifact, then this operation is the same + * as deleting the entire artifact. + * + * This operation can fail for the following reasons: + * + * * No artifact with this `artifactId` exists (HTTP error `404`) + * * No version with this `version` exists (HTTP error `404`) + * * A server error occurred (HTTP error `500`) + * + */ + @Path("/{artifactId}/versions/{version}") + @DELETE + void deleteArtifactVersion(@PathParam("version") Integer version, + @PathParam("artifactId") String artifactId); + + /** + * Returns a list of all rules configured for the artifact. The set of rules determines + * how the content of an artifact can evolve over time. If no rules are configured for + * an artifact, then the set of globally configured rules will be used. If no global + * rules are defined then there are no restrictions on content evolution. + * + * This operation can fail for the following reasons: + * + * * No artifact with this `artifactId` exists (HTTP error `404`) + * * A server error occurred (HTTP error `500`) + */ + @Path("/{artifactId}/rules") + @GET + @Produces("application/json") + List listArtifactRules(@PathParam("artifactId") String artifactId); + + /** + * Adds a rule to the list of rules that get applied to the artifact when adding new + * versions. All configured rules must pass in order to successfully add a new artifact + * version. + * + * This operation can fail for the following reasons: + * + * * No artifact with this `artifactId` exists (HTTP error `404`) + * * Rule (named in the request body) not found (HTTP error `400`) + * * A server error occurred (HTTP error `500`) + */ + @Path("/{artifactId}/rules") + @POST + @Consumes("application/json") + void createArtifactRule(@PathParam("artifactId") String artifactId, Rule data); + + /** + * Deletes all of the rules configured for the artifact. After this is done, the global + * rules will once again apply to the artifact. + * + * This operation can fail for the following reasons: + * + * * No artifact with this `artifactId` exists (HTTP error `404`) + * * A server error occurred (HTTP error `500`) + */ + @Path("/{artifactId}/rules") + @DELETE + void deleteArtifactRules(@PathParam("artifactId") String artifactId); + + /** + * Returns information about a single rule configured for an artifact. This is useful + * when you want to know what the current configuration settings are for a specific rule. + * + * This operation can fail for the following reasons: + * + * * No artifact with this `artifactId` exists (HTTP error `404`) + * * No rule with this name is configured for this artifact (HTTP error `404`) + * * A server error occurred (HTTP error `500`) + */ + @Path("/{artifactId}/rules/{rule}") + @GET + @Produces("application/json") + Rule getArtifactRuleConfig(@PathParam("rule") String rule, + @PathParam("artifactId") String artifactId); + + /** + * Updates the configuration of a single rule for the artifact. The configuration data + * is specific to each rule type, so the configuration of the **Compatibility** rule + * will be of a different format than the configuration of the **Validation** rule. + * + * This operation can fail for the following reasons: + * + * * No artifact with this `artifactId` exists (HTTP error `404`) + * * No rule with this name is configured for this artifact (HTTP error `404`) + * * A server error occurred (HTTP error `500`) + * + */ + @Path("/{artifactId}/rules/{rule}") + @PUT + @Produces("application/json") + @Consumes("application/json") + Rule updateArtifactRuleConfig(@PathParam("rule") String rule, + @PathParam("artifactId") String artifactId, Rule data); + + /** + * Deletes a rule from the artifact. This results in the rule no longer applying for + * this artifact. If this is the only rule configured for the artifact, then this is + * the same as deleting **all** rules: the globally configured rules will now apply to + * this artifact. + * + * This operation can fail for the following reasons: + * + * * No artifact with this `artifactId` exists (HTTP error `404`) + * * No rule with this name is configured for this artifact (HTTP error `404`) + * * A server error occurred (HTTP error `500`) + */ + @Path("/{artifactId}/rules/{rule}") + @DELETE + void deleteArtifactRule(@PathParam("rule") String rule, + @PathParam("artifactId") String artifactId); + + /** + * Gets the meta-data for an artifact in the registry. The returned meta-data will include + * both generated (read-only) and editable meta-data (such as name and description). + * + * This operation can fail for the following reasons: + * + * * No artifact with this `artifactId` exists (HTTP error `404`) + * * A server error occurred (HTTP error `500`) + */ + @Path("/{artifactId}/meta") + @GET + @Produces("application/json") + ArtifactMetaData getArtifactMetaData(@PathParam("artifactId") String artifactId); + + /** + * Updates the editable parts of the artifact's meta-data. Not all meta-data fields can + * be updated. For example `createdOn` and `createdBy` are both read-only properties. + * + * This operation can fail for the following reasons: + * + * * No artifact with the `artifactId` exists (HTTP error `404`) + * * A server error occurred (HTTP error `500`) + */ + @Path("/{artifactId}/meta") + @PUT + @Consumes("application/json") + void updateArtifactMetaData(@PathParam("artifactId") String artifactId, EditableMetaData data); + + /** + * Retrieves the meta-data for a single version of the artifact. The version meta-data + * is a subset of the artifact meta-data - it is only the meta-data that is specific to + * the version (and so doesn't include e.g. `modifiedOn`). + * + * This operation can fail for the following reasons: + * + * * No artifact with this `artifactId` exists (HTTP error `404`) + * * No version with this `version` exists (HTTP error `404`) + * * A server error occurred (HTTP error `500`) + * + */ + @Path("/{artifactId}/versions/{version}/meta") + @GET + @Produces("application/json") + VersionMetaData getArtifactVersionMetaData(@PathParam("version") Integer version, + @PathParam("artifactId") String artifactId); + + /** + * Updates the user-editable portion of the artifact version's meta-data. Only some of + * the meta-data fields are editable by the user. For example the `description` is editable + * but the `createdOn` is not. + * + * This operation can fail for the following reasons: + * + * * No artifact with this `artifactId` exists (HTTP error `404`) + * * No version with this `version` exists (HTTP error `404`) + * * A server error occurred (HTTP error `500`) + * + */ + @Path("/{artifactId}/versions/{version}/meta") + @PUT + @Consumes("application/json") + void updateArtifactVersionMetaData(@PathParam("version") Integer version, + @PathParam("artifactId") String artifactId, EditableMetaData data); + + /** + * Deletes the user-editable meta-data properties of the artifact version. Any properties + * that are not user-editable will be preserved. + * + * This operation can fail for the following reasons: + * + * * No artifact with this `artifactId` exists (HTTP error `404`) + * * No version with this `version` exists (HTTP error `404`) + * * A server error occurred (HTTP error `500`) + * + */ + @Path("/{artifactId}/versions/{version}/meta") + @DELETE + void deleteArtifactVersionMetaData(@PathParam("version") Integer version, + @PathParam("artifactId") String artifactId); +} diff --git a/back-end/hub-codegen/src/test/resources/OpenApi2JaxRsTest/_expected-registryApi-full/generated-api/src/main/java/org/example/api/JaxRsApplication.java b/back-end/hub-codegen/src/test/resources/OpenApi2JaxRsTest/_expected-registryApi-full/generated-api/src/main/java/org/example/api/JaxRsApplication.java new file mode 100644 index 000000000..f4f11b20c --- /dev/null +++ b/back-end/hub-codegen/src/test/resources/OpenApi2JaxRsTest/_expected-registryApi-full/generated-api/src/main/java/org/example/api/JaxRsApplication.java @@ -0,0 +1,13 @@ +package org.example.api; + +import javax.enterprise.context.ApplicationScoped; +import javax.ws.rs.ApplicationPath; +import javax.ws.rs.core.Application; + +/** + * The JAX-RS application. + */ +@ApplicationScoped +@ApplicationPath("/") +public class JaxRsApplication extends Application { +} diff --git a/back-end/hub-codegen/src/test/resources/OpenApi2JaxRsTest/_expected-registryApi-full/generated-api/src/main/java/org/example/api/RulesResource.java b/back-end/hub-codegen/src/test/resources/OpenApi2JaxRsTest/_expected-registryApi-full/generated-api/src/main/java/org/example/api/RulesResource.java new file mode 100644 index 000000000..695ac5ff4 --- /dev/null +++ b/back-end/hub-codegen/src/test/resources/OpenApi2JaxRsTest/_expected-registryApi-full/generated-api/src/main/java/org/example/api/RulesResource.java @@ -0,0 +1,98 @@ +package org.example.api; + +import java.lang.String; +import java.util.List; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import org.example.api.beans.Rule; + +/** + * A JAX-RS interface. An implementation of this interface must be provided. + */ +@Path("/rules") +public interface RulesResource { + /** + * Gets a list of all the currently configured global rules (if any). + * + * This operation can fail for the following reasons: + * + * * A server error occurred (HTTP error `500`) + * + */ + @GET + @Produces("application/json") + List listGlobalRules(); + + /** + * Adds a rule to the list of globally configured rules. + * + * This operation can fail for the following reasons: + * + * * The rule already exists (HTTP error `409`) + * * A server error occurred (HTTP error `500`) + * + */ + @POST + @Consumes("application/json") + void createGlobalRule(Rule data); + + /** + * Deletes all globally configured rules. + * + * This operation can fail for the following reasons: + * + * * A server error occurred (HTTP error `500`) + * + */ + @DELETE + void deleteAllGlobalRules(); + + /** + * Returns information about the named globally configured rule. + * + * This operation can fail for the following reasons: + * + * * No rule named `rule` exists (HTTP error `404`) + * * A server error occurred (HTTP error `500`) + * + */ + @Path("/{rule}") + @GET + @Produces("application/json") + Rule getGlobalRuleConfig(@PathParam("rule") String rule); + + /** + * Updates the configuration for a globally configured rule. + * + * This operation can fail for the following reasons: + * + * * No rule named `rule` exists (HTTP error `404`) + * * A server error occurred (HTTP error `500`) + * + */ + @Path("/{rule}") + @PUT + @Produces("application/json") + @Consumes("application/json") + Rule updateGlobalRuleConfig(@PathParam("rule") String rule, Rule data); + + /** + * Deletes a single global rule. If this is the only rule configured, this is the same + * as deleting **all** rules. + * + * This operation can fail for the following reasons: + * + * * No rule named `rule` exists (HTTP error `404`) + * * A server error occurred (HTTP error `500`) + * + */ + @Path("/{rule}") + @DELETE + void deleteGlobalRule(@PathParam("rule") String rule); +} diff --git a/back-end/hub-codegen/src/test/resources/OpenApi2JaxRsTest/_expected-registryApi-full/generated-api/src/main/java/org/example/api/beans/ArtifactMetaData.java b/back-end/hub-codegen/src/test/resources/OpenApi2JaxRsTest/_expected-registryApi-full/generated-api/src/main/java/org/example/api/beans/ArtifactMetaData.java new file mode 100644 index 000000000..04a54bb3e --- /dev/null +++ b/back-end/hub-codegen/src/test/resources/OpenApi2JaxRsTest/_expected-registryApi-full/generated-api/src/main/java/org/example/api/beans/ArtifactMetaData.java @@ -0,0 +1,320 @@ + +package org.example.api.beans; + +import java.util.Date; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; + + +/** + * Root Type for ArtifactMetaData + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "name", + "description", + "createdBy", + "createdOn", + "modifiedBy", + "modifiedOn", + "id", + "version", + "type", + "clientId" +}) +public class ArtifactMetaData { + + @JsonProperty("name") + private String name; + @JsonProperty("description") + private String description; + /** + * + * (Required) + * + */ + @JsonProperty("createdBy") + private String createdBy; + /** + * + * (Required) + * + */ + @JsonProperty("createdOn") + private Date createdOn; + /** + * + * (Required) + * + */ + @JsonProperty("modifiedBy") + private String modifiedBy; + /** + * + * (Required) + * + */ + @JsonProperty("modifiedOn") + private Date modifiedOn; + /** + * + * (Required) + * + */ + @JsonProperty("id") + @JsonPropertyDescription("") + private Integer id; + /** + * + * (Required) + * + */ + @JsonProperty("version") + @JsonPropertyDescription("") + private Integer version; + /** + * + * (Required) + * + */ + @JsonProperty("type") + @JsonPropertyDescription("") + private ArtifactMetaData.Type type; + /** + * Identifier provided by the client. Must be globally unique. + * + */ + @JsonProperty("clientId") + @JsonPropertyDescription("Identifier provided by the client. Must be globally unique.") + private String clientId; + + @JsonProperty("name") + public String getName() { + return name; + } + + @JsonProperty("name") + public void setName(String name) { + this.name = name; + } + + @JsonProperty("description") + public String getDescription() { + return description; + } + + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * + * (Required) + * + */ + @JsonProperty("createdBy") + public String getCreatedBy() { + return createdBy; + } + + /** + * + * (Required) + * + */ + @JsonProperty("createdBy") + public void setCreatedBy(String createdBy) { + this.createdBy = createdBy; + } + + /** + * + * (Required) + * + */ + @JsonProperty("createdOn") + public Date getCreatedOn() { + return createdOn; + } + + /** + * + * (Required) + * + */ + @JsonProperty("createdOn") + public void setCreatedOn(Date createdOn) { + this.createdOn = createdOn; + } + + /** + * + * (Required) + * + */ + @JsonProperty("modifiedBy") + public String getModifiedBy() { + return modifiedBy; + } + + /** + * + * (Required) + * + */ + @JsonProperty("modifiedBy") + public void setModifiedBy(String modifiedBy) { + this.modifiedBy = modifiedBy; + } + + /** + * + * (Required) + * + */ + @JsonProperty("modifiedOn") + public Date getModifiedOn() { + return modifiedOn; + } + + /** + * + * (Required) + * + */ + @JsonProperty("modifiedOn") + public void setModifiedOn(Date modifiedOn) { + this.modifiedOn = modifiedOn; + } + + /** + * + * (Required) + * + */ + @JsonProperty("id") + public Integer getId() { + return id; + } + + /** + * + * (Required) + * + */ + @JsonProperty("id") + public void setId(Integer id) { + this.id = id; + } + + /** + * + * (Required) + * + */ + @JsonProperty("version") + public Integer getVersion() { + return version; + } + + /** + * + * (Required) + * + */ + @JsonProperty("version") + public void setVersion(Integer version) { + this.version = version; + } + + /** + * + * (Required) + * + */ + @JsonProperty("type") + public ArtifactMetaData.Type getType() { + return type; + } + + /** + * + * (Required) + * + */ + @JsonProperty("type") + public void setType(ArtifactMetaData.Type type) { + this.type = type; + } + + /** + * Identifier provided by the client. Must be globally unique. + * + */ + @JsonProperty("clientId") + public String getClientId() { + return clientId; + } + + /** + * Identifier provided by the client. Must be globally unique. + * + */ + @JsonProperty("clientId") + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public enum Type { + + AVRO("avro"), + PROTOBUFF("protobuff"), + JSON("json"), + OPENAPI("openapi"), + ASYNCAPI("asyncapi"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (ArtifactMetaData.Type c: values()) { + CONSTANTS.put(c.value, c); + } + } + + private Type(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @JsonValue + public String value() { + return this.value; + } + + @JsonCreator + public static ArtifactMetaData.Type fromValue(String value) { + ArtifactMetaData.Type constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/back-end/hub-codegen/src/test/resources/OpenApi2JaxRsTest/_expected-registryApi-full/generated-api/src/main/java/org/example/api/beans/EditableMetaData.java b/back-end/hub-codegen/src/test/resources/OpenApi2JaxRsTest/_expected-registryApi-full/generated-api/src/main/java/org/example/api/beans/EditableMetaData.java new file mode 100644 index 000000000..33b5a7607 --- /dev/null +++ b/back-end/hub-codegen/src/test/resources/OpenApi2JaxRsTest/_expected-registryApi-full/generated-api/src/main/java/org/example/api/beans/EditableMetaData.java @@ -0,0 +1,47 @@ + +package org.example.api.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +/** + * Root Type for EditableArtifactMetaData + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "name", + "description" +}) +public class EditableMetaData { + + @JsonProperty("name") + private String name; + @JsonProperty("description") + private String description; + + @JsonProperty("name") + public String getName() { + return name; + } + + @JsonProperty("name") + public void setName(String name) { + this.name = name; + } + + @JsonProperty("description") + public String getDescription() { + return description; + } + + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + +} diff --git a/back-end/hub-codegen/src/test/resources/OpenApi2JaxRsTest/_expected-registryApi-full/generated-api/src/main/java/org/example/api/beans/Rule.java b/back-end/hub-codegen/src/test/resources/OpenApi2JaxRsTest/_expected-registryApi-full/generated-api/src/main/java/org/example/api/beans/Rule.java new file mode 100644 index 000000000..7f7fd76db --- /dev/null +++ b/back-end/hub-codegen/src/test/resources/OpenApi2JaxRsTest/_expected-registryApi-full/generated-api/src/main/java/org/example/api/beans/Rule.java @@ -0,0 +1,62 @@ + +package org.example.api.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +/** + * Root Type for Rule + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "name", + "config" +}) +public class Rule { + + @JsonProperty("name") + private String name; + /** + * + * (Required) + * + */ + @JsonProperty("config") + private String config; + + @JsonProperty("name") + public String getName() { + return name; + } + + @JsonProperty("name") + public void setName(String name) { + this.name = name; + } + + /** + * + * (Required) + * + */ + @JsonProperty("config") + public String getConfig() { + return config; + } + + /** + * + * (Required) + * + */ + @JsonProperty("config") + public void setConfig(String config) { + this.config = config; + } + +} diff --git a/back-end/hub-codegen/src/test/resources/OpenApi2JaxRsTest/_expected-registryApi-full/generated-api/src/main/java/org/example/api/beans/VersionMetaData.java b/back-end/hub-codegen/src/test/resources/OpenApi2JaxRsTest/_expected-registryApi-full/generated-api/src/main/java/org/example/api/beans/VersionMetaData.java new file mode 100644 index 000000000..6d761bf95 --- /dev/null +++ b/back-end/hub-codegen/src/test/resources/OpenApi2JaxRsTest/_expected-registryApi-full/generated-api/src/main/java/org/example/api/beans/VersionMetaData.java @@ -0,0 +1,162 @@ + +package org.example.api.beans; + +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +/** + * Root Type for ArtifactVersionMetaData + *

+ * + * + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "version", + "name", + "description", + "createdBy", + "createdOn", + "id" +}) +public class VersionMetaData { + + /** + * + * (Required) + * + */ + @JsonProperty("version") + private Integer version; + @JsonProperty("name") + private String name; + @JsonProperty("description") + private String description; + /** + * + * (Required) + * + */ + @JsonProperty("createdBy") + private String createdBy; + /** + * + * (Required) + * + */ + @JsonProperty("createdOn") + private Date createdOn; + /** + * + * (Required) + * + */ + @JsonProperty("id") + @JsonPropertyDescription("") + private Integer id; + + /** + * + * (Required) + * + */ + @JsonProperty("version") + public Integer getVersion() { + return version; + } + + /** + * + * (Required) + * + */ + @JsonProperty("version") + public void setVersion(Integer version) { + this.version = version; + } + + @JsonProperty("name") + public String getName() { + return name; + } + + @JsonProperty("name") + public void setName(String name) { + this.name = name; + } + + @JsonProperty("description") + public String getDescription() { + return description; + } + + @JsonProperty("description") + public void setDescription(String description) { + this.description = description; + } + + /** + * + * (Required) + * + */ + @JsonProperty("createdBy") + public String getCreatedBy() { + return createdBy; + } + + /** + * + * (Required) + * + */ + @JsonProperty("createdBy") + public void setCreatedBy(String createdBy) { + this.createdBy = createdBy; + } + + /** + * + * (Required) + * + */ + @JsonProperty("createdOn") + public Date getCreatedOn() { + return createdOn; + } + + /** + * + * (Required) + * + */ + @JsonProperty("createdOn") + public void setCreatedOn(Date createdOn) { + this.createdOn = createdOn; + } + + /** + * + * (Required) + * + */ + @JsonProperty("id") + public Integer getId() { + return id; + } + + /** + * + * (Required) + * + */ + @JsonProperty("id") + public void setId(Integer id) { + this.id = id; + } + +} diff --git a/back-end/hub-codegen/src/test/resources/OpenApi2JaxRsTest/_expected-registryApi-full/generated-api/src/main/resources/META-INF/openapi.json b/back-end/hub-codegen/src/test/resources/OpenApi2JaxRsTest/_expected-registryApi-full/generated-api/src/main/resources/META-INF/openapi.json new file mode 100644 index 000000000..9e2725ad2 --- /dev/null +++ b/back-end/hub-codegen/src/test/resources/OpenApi2JaxRsTest/_expected-registryApi-full/generated-api/src/main/resources/META-INF/openapi.json @@ -0,0 +1,913 @@ +{ + "openapi": "3.0.2", + "info": { + "title": "Apicurio Registry API", + "version": "1.0.0", + "description": "The Apicurio Registry project's primary REST API - used by clients to add and remove APIs and Schemas to the registry.", + "contact": { + "name": "Apicurio", + "url": "https://github.com/apicurio/apicurio-registry", + "email": "apicurio@lists.jboss.org" + }, + "license": { + "name": "Apache 2.0", + "url": "https://www.apache.org/licenses/LICENSE-2.0" + } + }, + "paths": { + "/artifacts": { + "summary": "Manage the collection of artifacts in the registry.", + "post": { + "requestBody": { + "description": "The content of the artifact being created - this is often, but not always, JSON data\nrepresenting one of the supported artifact types:\n\n* Avro\n* Protobuff\n* JSON Schema\n* OpenAPI\n* AsyncAPI", + "content": { + "application/json": {}, + "application/x-yaml": {} + }, + "required": true + }, + "tags": [ + "artifacts" + ], + "parameters": [ + { + "name": "X-Registry-ArtifactType", + "description": "This header parameter can be used to indicate the type of the artifact being added. Possible\nvalues include:\n\n* avro\n* protobuff\n* json\n* openapi\n* asyncapi", + "schema": { + "enum": [ + "avro", + "protobuff", + "json", + "openapi", + "asyncapi" + ], + "type": "string" + }, + "in": "header" + }, + { + "name": "X-Registry-ArtifactId", + "description": "Used to pass in a client-provided, globally unique identifier for the new artifact.", + "schema": { + "type": "string" + }, + "in": "header" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ArtifactMetaData" + } + } + }, + "description": "Artifact was successfully created." + } + }, + "operationId": "createArtifact", + "summary": "Create Artifact", + "description": "Creates a new artifact by POSTing the artifact content. The body of the request should\nbe the raw content of the artifact. This will typically be in JSON format for *most*\nof the supported types, but may be in another format for a few (e.g. Protobuff).\n\nThe registry will attempt to figure out what kind of artifact is being added from the\nfollowing supported list:\n\n* Avro (avro)\n* Protobuff (protobuff)\n* JSON Schema (json)\n* OpenAPI (openapi)\n* AsyncAPI (asyncapi)\n\nAlternatively, the artifact type can be indicated by either explicitly specifying the \ntype via the `X-Registry-ArtifactType` HTTP Request Header or by including a hint in the \nRequest's `Content-Type`.\n\nFor example:\n\n```\nContent-Type: application/json+avro\n```\n" + } + }, + "/artifacts/{artifactId}": { + "summary": "Manage a single artifact.", + "get": { + "tags": [ + "artifacts" + ], + "responses": { + "200": { + "content": { + "application/json": {}, + "application/x-yaml": {} + }, + "description": "The most recent version of the artifact." + } + }, + "operationId": "getLatestArtifact", + "summary": "Get Latest Artifact", + "description": "Returns the latest version of the artifact in its raw form. The `Content-Type` of the\nresponse will depend on what type of artifact it is. In most cases this will be\n`application/json` but for some types it may be different (e.g. *avro*).\n\nThis operation may fail for one of the following reasons:\n\n* No artifact with this `artifactId` exists (HTTP error `404`)\n* A server error occurred (HTTP error `500`)\n" + }, + "put": { + "requestBody": { + "content": { + "application/json": {}, + "application/x-yaml": {} + }, + "required": true + }, + "tags": [ + "artifacts" + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ArtifactMetaData" + } + } + }, + "description": "When successful, returns the updated artifact meta-data." + } + }, + "operationId": "updateArtifact", + "summary": "Update Artifact", + "description": "Updates an artifact by uploading new content. The update could fail for a number\nof reasons including:\n\n* No artifact with the `artifactId` exists (HTTP error `404`)\n* The new content violates one of the rules configured for the artifact (HTTP error `400`)\n* A server error occurred (HTTP error `500`)\n\nWhen successful, this creates a new version of the artifact, making it the most recent\n(and therefore official) version of the artifact." + }, + "delete": { + "tags": [ + "artifacts" + ], + "responses": { + "204": { + "description": "Returned when the artifact was successfully deleted." + } + }, + "operationId": "deleteArtifact", + "summary": "Delete Artifact", + "description": "Deletes an artifact completely, resulting in all versions of the artifact also being\ndeleted. This may fail for one of the following reasons:\n\n* No artifact with the `artifactId` exists (HTTP error `404`)\n* A server error occurred (HTTP error `500`)" + }, + "parameters": [ + { + "name": "artifactId", + "description": "The artifact ID. Can be a string (client provided) or integer (server generated) representing the unique artifact identifier.", + "schema": { + "type": "string" + }, + "in": "path", + "required": true + } + ] + }, + "/artifacts/{artifactId}/versions": { + "summary": "Manage all the versions of an artifact in the registry.", + "get": { + "tags": [ + "versions" + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "type": "integer" + } + }, + "examples": { + "All Versions": { + "value": [ + 5, + 6, + 10, + 103 + ] + } + } + } + }, + "description": "List of all artifact versions (just the version IDs)." + } + }, + "operationId": "listArtifactVersions", + "summary": "List Artifact Versions", + "description": "Returns a list of all version numbers for the artifact.\n\nThis operation can fail for the following reasons:\n\n* No artifact with this `artifactId` exists (HTTP error `404`)\n* A server error occurred (HTTP error `500`)\n" + }, + "post": { + "requestBody": { + "description": "The content of the artifact version being created - this is often, but not always, JSON data\nrepresenting one of the supported artifact types:\n\n* Avro\n* Protobuff\n* JSON Schema\n* OpenAPI\n* AsyncAPI", + "content": { + "application/json": {}, + "application/x-yaml": {} + }, + "required": true + }, + "tags": [ + "versions" + ], + "parameters": [ + { + "name": "X-Registry-ArtifactType", + "description": "This header parameter can be used to indicate the type of the artifact being added. Possible\nvalues include:\n\n* avro\n* protobuff\n* json\n* openapi\n* asyncapi", + "schema": { + "enum": [ + "avro", + "protobuff", + "json", + "openapi", + "asyncapi" + ], + "type": "string" + }, + "in": "header" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/VersionMetaData" + } + } + }, + "description": "The artifact version was successfully created." + } + }, + "operationId": "createArtifactVersion", + "summary": "Create Artifact Version", + "description": "Creates a new version of the artifact by uploading new content. The configured rules for\nthe artifact will be applied, and if they all pass then the new content will be added\nas the most recent version of the artifact. If any of the rules fail then an error \nwill be returned.\n\nThe body of the request should be the raw content of the new artifact version. This \nwill typically be in JSON format for *most* of the supported types, but may be in another \nformat for a few (e.g. Protobuff).\n\nThe registry will attempt to figure out what kind of artifact is being added from the\nfollowing supported list:\n\n* Avro (avro)\n* Protobuff (protobuff)\n* JSON Schema (json)\n* OpenAPI (openapi)\n* AsyncAPI (asyncapi)\n\nAlternatively, the artifact type can be indicated by either explicitly specifying the \ntype via the `X-Registry-ArtifactType` HTTP Request Header or by including a hint in the \nRequest's `Content-Type`.\n\nFor example:\n\n```\nContent-Type: application/json+avro\n```\n\nThis operation can fail for the following reasons:\n\n* No artifact with this `artifactId` exists (HTTP error `404`)\n* A server error occurred (HTTP error `500`)\n" + }, + "parameters": [ + { + "name": "artifactId", + "description": "The artifact ID. Can be a string (client provided) or integer (server generated) representing the unique artifact identifier.", + "schema": { + "type": "string" + }, + "in": "path", + "required": true + } + ] + }, + "/artifacts/{artifactId}/versions/{version}": { + "summary": "Manage a single version of a single artifact in the registry.", + "get": { + "tags": [ + "versions" + ], + "responses": { + "200": { + "content": { + "application/json": {}, + "application/x-yaml": {} + }, + "description": "The content of the artifact version." + } + }, + "operationId": "getArtifactVersion", + "summary": "Get Artifact Version", + "description": "Retrieves a single version of the artifact content. Both the `artifactId` and the\nunique `version` number must be provided. The `Content-Type` of the\nresponse will depend on what type of artifact it is. In most cases this will be\n`application/json` but for some types it may be different (e.g. *avro*).\n\nThis operation can fail for the following reasons:\n\n* No artifact with this `artifactId` exists (HTTP error `404`)\n* No version with this `version` exists (HTTP error `404`)\n* A server error occurred (HTTP error `500`)\n" + }, + "delete": { + "tags": [ + "versions" + ], + "responses": { + "204": { + "description": "The artifact version was successfully deleted." + } + }, + "operationId": "deleteArtifactVersion", + "summary": "Delete Artifact Version", + "description": "Deletes a single version of the artifact. Both the `artifactId` and the unique `version`\nare needed. If this is the only version of the artifact, then this operation is the same\nas deleting the entire artifact.\n\nThis operation can fail for the following reasons:\n\n* No artifact with this `artifactId` exists (HTTP error `404`)\n* No version with this `version` exists (HTTP error `404`)\n* A server error occurred (HTTP error `500`)\n" + }, + "parameters": [ + { + "name": "version", + "description": "The unique identifier of a specific version of the artifact content.", + "schema": { + "type": "integer" + }, + "in": "path", + "required": true + }, + { + "name": "artifactId", + "description": "The artifact ID. Can be a string (client provided) or integer (server generated) representing the unique artifact identifier.", + "schema": { + "type": "string" + }, + "in": "path", + "required": true + } + ] + }, + "/artifacts/{artifactId}/rules": { + "summary": "Manage the rules for a single artifact.", + "get": { + "tags": [ + "rules" + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Rule" + } + } + } + }, + "description": "Returns the rules configured for the artifact." + } + }, + "operationId": "listArtifactRules", + "summary": "List Artifact Rules", + "description": "Returns a list of all rules configured for the artifact. The set of rules determines\nhow the content of an artifact can evolve over time. If no rules are configured for\nan artifact, then the set of globally configured rules will be used. If no global\nrules are defined then there are no restrictions on content evolution.\n\nThis operation can fail for the following reasons:\n\n* No artifact with this `artifactId` exists (HTTP error `404`)\n* A server error occurred (HTTP error `500`)" + }, + "post": { + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Rule" + } + } + }, + "required": true + }, + "tags": [ + "rules" + ], + "responses": { + "201": { + "description": "The rule was added. A URI to the new rule can be found in the `Location` response header." + } + }, + "operationId": "createArtifactRule", + "summary": "Create Artifact Rule", + "description": "Adds a rule to the list of rules that get applied to the artifact when adding new\nversions. All configured rules must pass in order to successfully add a new artifact\nversion.\n\nThis operation can fail for the following reasons:\n\n* No artifact with this `artifactId` exists (HTTP error `404`)\n* Rule (named in the request body) not found (HTTP error `400`)\n* A server error occurred (HTTP error `500`)" + }, + "delete": { + "tags": [ + "rules" + ], + "responses": { + "204": { + "description": "The rules were successfully deleted." + } + }, + "operationId": "deleteArtifactRules", + "summary": "Delete Artifact Rules", + "description": "Deletes all of the rules configured for the artifact. After this is done, the global\nrules will once again apply to the artifact.\n\nThis operation can fail for the following reasons:\n\n* No artifact with this `artifactId` exists (HTTP error `404`)\n* A server error occurred (HTTP error `500`)" + }, + "parameters": [ + { + "name": "artifactId", + "description": "The artifact ID. Can be a string (client provided) or integer (server generated) representing the unique artifact identifier.", + "schema": { + "type": "string" + }, + "in": "path", + "required": true + } + ] + }, + "/artifacts/{artifactId}/rules/{rule}": { + "summary": "Manage the configuration of a single artifact rule.", + "get": { + "tags": [ + "rules" + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Rule" + } + } + }, + "description": "Information about a rule." + } + }, + "operationId": "getArtifactRuleConfig", + "summary": "Get Artifact Rule Config", + "description": "Returns information about a single rule configured for an artifact. This is useful\nwhen you want to know what the current configuration settings are for a specific rule.\n\nThis operation can fail for the following reasons:\n\n* No artifact with this `artifactId` exists (HTTP error `404`)\n* No rule with this name is configured for this artifact (HTTP error `404`)\n* A server error occurred (HTTP error `500`)" + }, + "put": { + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Rule" + } + } + }, + "required": true + }, + "tags": [ + "rules" + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Rule" + } + } + }, + "description": "Rule configuration was updated." + } + }, + "operationId": "updateArtifactRuleConfig", + "summary": "Update Artifact Rule Config", + "description": "Updates the configuration of a single rule for the artifact. The configuration data\nis specific to each rule type, so the configuration of the **Compatibility** rule \nwill be of a different format than the configuration of the **Validation** rule.\n\nThis operation can fail for the following reasons:\n\n* No artifact with this `artifactId` exists (HTTP error `404`)\n* No rule with this name is configured for this artifact (HTTP error `404`)\n* A server error occurred (HTTP error `500`)\n" + }, + "delete": { + "tags": [ + "rules" + ], + "responses": { + "204": { + "description": "The rule was successfully deleted." + } + }, + "operationId": "deleteArtifactRule", + "summary": "Delete Artifact Rule", + "description": "Deletes a rule from the artifact. This results in the rule no longer applying for\nthis artifact. If this is the only rule configured for the artifact, then this is\nthe same as deleting **all** rules: the globally configured rules will now apply to\nthis artifact.\n\nThis operation can fail for the following reasons:\n\n* No artifact with this `artifactId` exists (HTTP error `404`)\n* No rule with this name is configured for this artifact (HTTP error `404`)\n* A server error occurred (HTTP error `500`)" + }, + "parameters": [ + { + "name": "rule", + "description": "The unique name of a rule.", + "schema": { + "type": "string" + }, + "in": "path", + "required": true + }, + { + "name": "artifactId", + "description": "The artifact ID. Can be a string (client provided) or integer (server generated) representing the unique artifact identifier.", + "schema": { + "type": "string" + }, + "in": "path", + "required": true + } + ] + }, + "/rules": { + "summary": "Manage the global rules that apply to all artifacts if not otherwise configured.", + "get": { + "tags": [ + "rules", + "global rules" + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Rule" + } + } + } + }, + "description": "The list of globally configured rules." + } + }, + "operationId": "listGlobalRules", + "summary": "List Global Rules", + "description": "Gets a list of all the currently configured global rules (if any).\n\nThis operation can fail for the following reasons:\n\n* A server error occurred (HTTP error `500`)\n" + }, + "post": { + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Rule" + } + } + }, + "required": true + }, + "tags": [ + "rules", + "global rules" + ], + "responses": { + "201": { + "description": "The global rule was added. A URI to the new rule can be found in the `Location` response header." + } + }, + "operationId": "createGlobalRule", + "summary": "Create Global Rule", + "description": "Adds a rule to the list of globally configured rules.\n\nThis operation can fail for the following reasons:\n\n* The rule already exists (HTTP error `409`)\n* A server error occurred (HTTP error `500`)\n" + }, + "delete": { + "tags": [ + "rules", + "global rules" + ], + "responses": { + "204": { + "description": "All global rules have been removed successfully." + } + }, + "operationId": "deleteAllGlobalRules", + "summary": "Delete All Global Rules", + "description": "Deletes all globally configured rules.\n\nThis operation can fail for the following reasons:\n\n* A server error occurred (HTTP error `500`)\n" + } + }, + "/artifacts/{artifactId}/meta": { + "summary": "Manage the meta-data of a single artifact.", + "get": { + "tags": [ + "meta-data" + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ArtifactMetaData" + } + } + }, + "description": "The artifact's meta-data." + } + }, + "operationId": "getArtifactMetaData", + "summary": "Get Artifact Meta-Data", + "description": "Gets the meta-data for an artifact in the registry. The returned meta-data will include\nboth generated (read-only) and editable meta-data (such as name and description).\n\nThis operation can fail for the following reasons:\n\n* No artifact with this `artifactId` exists (HTTP error `404`)\n* A server error occurred (HTTP error `500`)" + }, + "put": { + "requestBody": { + "description": "Updated artifact meta-data.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/EditableMetaData" + } + } + }, + "required": true + }, + "tags": [ + "meta-data" + ], + "responses": { + "204": { + "description": "The artifact's meta-data was updated." + } + }, + "operationId": "updateArtifactMetaData", + "summary": "Update Artifact Meta-Data", + "description": "Updates the editable parts of the artifact's meta-data. Not all meta-data fields can\nbe updated. For example `createdOn` and `createdBy` are both read-only properties.\n\nThis operation can fail for the following reasons:\n\n* No artifact with the `artifactId` exists (HTTP error `404`)\n* A server error occurred (HTTP error `500`)" + }, + "parameters": [ + { + "name": "artifactId", + "description": "The artifact ID. Can be a string (client provided) or integer (server generated) representing the unique artifact identifier.", + "schema": { + "type": "string" + }, + "in": "path", + "required": true + } + ] + }, + "/artifacts/{artifactId}/versions/{version}/meta": { + "summary": "Manage the meta-data for a single version of an artifact in the registry.", + "get": { + "tags": [ + "versions", + "meta-data" + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/VersionMetaData" + } + } + }, + "description": "The artifact version's meta-data." + } + }, + "operationId": "getArtifactVersionMetaData", + "summary": "Get Artifact Version Meta-Data", + "description": "Retrieves the meta-data for a single version of the artifact. The version meta-data\nis a subset of the artifact meta-data - it is only the meta-data that is specific to\nthe version (and so doesn't include e.g. `modifiedOn`).\n\nThis operation can fail for the following reasons:\n\n* No artifact with this `artifactId` exists (HTTP error `404`)\n* No version with this `version` exists (HTTP error `404`)\n* A server error occurred (HTTP error `500`)\n" + }, + "put": { + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/EditableMetaData" + } + } + }, + "required": true + }, + "tags": [ + "versions", + "meta-data" + ], + "responses": { + "204": { + "description": "The artifact version's meta-data was successfully updated." + } + }, + "operationId": "updateArtifactVersionMetaData", + "summary": "Update Artifact Version Meta-Data", + "description": "Updates the user-editable portion of the artifact version's meta-data. Only some of \nthe meta-data fields are editable by the user. For example the `description` is editable\nbut the `createdOn` is not.\n\nThis operation can fail for the following reasons:\n\n* No artifact with this `artifactId` exists (HTTP error `404`)\n* No version with this `version` exists (HTTP error `404`)\n* A server error occurred (HTTP error `500`)\n" + }, + "delete": { + "tags": [ + "versions", + "meta-data" + ], + "responses": { + "204": { + "description": "The artifact version's user-editable meta-data was successfully deleted." + } + }, + "operationId": "deleteArtifactVersionMetaData", + "summary": "Delete Artifact Version Meta-Data", + "description": "Deletes the user-editable meta-data properties of the artifact version. Any properties\nthat are not user-editable will be preserved.\n\nThis operation can fail for the following reasons:\n\n* No artifact with this `artifactId` exists (HTTP error `404`)\n* No version with this `version` exists (HTTP error `404`)\n* A server error occurred (HTTP error `500`)\n" + }, + "parameters": [ + { + "name": "version", + "description": "The unique identifier of a specific version of the artifact content.", + "schema": { + "type": "integer" + }, + "in": "path", + "required": true + }, + { + "name": "artifactId", + "description": "The artifact ID. Can be a string (client provided) or integer (server generated) representing the unique artifact identifier.", + "schema": { + "type": "string" + }, + "in": "path", + "required": true + } + ] + }, + "/rules/{rule}": { + "summary": "Manage the configuration of a single global artifact rule.", + "get": { + "tags": [ + "rules", + "global rules" + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Rule" + } + } + }, + "description": "The global rule's configuration." + } + }, + "operationId": "getGlobalRuleConfig", + "summary": "Get Global Rule Config", + "description": "Returns information about the named globally configured rule.\n\nThis operation can fail for the following reasons:\n\n* No rule named `rule` exists (HTTP error `404`)\n* A server error occurred (HTTP error `500`)\n" + }, + "put": { + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Rule" + } + } + }, + "required": true + }, + "tags": [ + "rules", + "global rules" + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Rule" + } + } + }, + "description": "The global rule's configuration was successfully updated." + } + }, + "operationId": "updateGlobalRuleConfig", + "summary": "Update Global Rule Config", + "description": "Updates the configuration for a globally configured rule.\n\nThis operation can fail for the following reasons:\n\n* No rule named `rule` exists (HTTP error `404`)\n* A server error occurred (HTTP error `500`)\n" + }, + "delete": { + "tags": [ + "rules", + "global rules" + ], + "responses": { + "204": { + "description": "The global rule was successfully deleted." + } + }, + "operationId": "deleteGlobalRule", + "summary": "Delete Global Rule", + "description": "Deletes a single global rule. If this is the only rule configured, this is the same\nas deleting **all** rules.\n\nThis operation can fail for the following reasons:\n\n* No rule named `rule` exists (HTTP error `404`)\n* A server error occurred (HTTP error `500`)\n" + }, + "parameters": [ + { + "name": "rule", + "description": "The unique name of a rule.", + "schema": { + "type": "string" + }, + "in": "path", + "required": true + } + ] + } + }, + "components": { + "schemas": { + "EditableMetaData": { + "title": "Root Type for EditableArtifactMetaData", + "description": "", + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "description": { + "type": "string" + } + }, + "example": { + "name": "Artifact Name", + "description": "The description of the artifact." + } + }, + "VersionMetaData": { + "title": "Root Type for ArtifactVersionMetaData", + "description": "", + "required": [ + "createdOn", + "createdBy", + "version", + "id" + ], + "type": "object", + "properties": { + "version": { + "format": "int64", + "type": "integer" + }, + "name": { + "type": "string" + }, + "description": { + "type": "string" + }, + "createdBy": { + "type": "string" + }, + "createdOn": { + "format": "date-time", + "type": "string" + }, + "id": { + "format": "int64", + "description": "", + "type": "integer" + } + }, + "example": { + "id": 12938472, + "version": 12, + "name": "Artifact Name", + "description": "The description of the artifact", + "createdBy": "user1", + "createdOn": "2019-05-17T12:00:00Z" + } + }, + "ArtifactMetaData": { + "title": "Root Type for ArtifactMetaData", + "description": "", + "required": [ + "id", + "createdBy", + "createdOn", + "modifiedBy", + "modifiedOn", + "version", + "type" + ], + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "description": { + "type": "string" + }, + "createdBy": { + "type": "string" + }, + "createdOn": { + "format": "date-time", + "type": "string" + }, + "modifiedBy": { + "type": "string" + }, + "modifiedOn": { + "format": "date-time", + "type": "string" + }, + "id": { + "format": "int64", + "description": "", + "type": "integer" + }, + "version": { + "description": "", + "type": "integer" + }, + "type": { + "description": "", + "enum": [ + "avro", + "protobuff", + "json", + "openapi", + "asyncapi" + ], + "type": "string" + }, + "clientId": { + "description": "Identifier provided by the client. Must be globally unique.", + "type": "string" + } + }, + "example": { + "id": 19847289, + "clientId": "Procurement-Invoice", + "name": "Artifact Name", + "description": "Description of the artifact", + "type": "avro", + "version": 18, + "createdBy": "user1", + "createdOn": "2019-03-22T12:51:19Z", + "modifiedBy": "user2", + "modifiedOn": "2019-07-19T15:09:00Z" + } + }, + "Rule": { + "title": "Root Type for Rule", + "description": "", + "required": [ + "config" + ], + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "config": { + "type": "string" + } + }, + "example": { + "name": "UniqueRuleName", + "config": "configuration_of_rule" + } + } + } + }, + "tags": [ + { + "name": "artifacts", + "description": "" + }, + { + "name": "meta-data", + "description": "" + }, + { + "name": "versions", + "description": "" + }, + { + "name": "rules", + "description": "" + }, + { + "name": "global rules", + "description": "" + } + ] +} \ No newline at end of file diff --git a/back-end/hub-codegen/src/test/resources/OpenApi2JaxRsTest/registry-api.json b/back-end/hub-codegen/src/test/resources/OpenApi2JaxRsTest/registry-api.json new file mode 100644 index 000000000..9e2725ad2 --- /dev/null +++ b/back-end/hub-codegen/src/test/resources/OpenApi2JaxRsTest/registry-api.json @@ -0,0 +1,913 @@ +{ + "openapi": "3.0.2", + "info": { + "title": "Apicurio Registry API", + "version": "1.0.0", + "description": "The Apicurio Registry project's primary REST API - used by clients to add and remove APIs and Schemas to the registry.", + "contact": { + "name": "Apicurio", + "url": "https://github.com/apicurio/apicurio-registry", + "email": "apicurio@lists.jboss.org" + }, + "license": { + "name": "Apache 2.0", + "url": "https://www.apache.org/licenses/LICENSE-2.0" + } + }, + "paths": { + "/artifacts": { + "summary": "Manage the collection of artifacts in the registry.", + "post": { + "requestBody": { + "description": "The content of the artifact being created - this is often, but not always, JSON data\nrepresenting one of the supported artifact types:\n\n* Avro\n* Protobuff\n* JSON Schema\n* OpenAPI\n* AsyncAPI", + "content": { + "application/json": {}, + "application/x-yaml": {} + }, + "required": true + }, + "tags": [ + "artifacts" + ], + "parameters": [ + { + "name": "X-Registry-ArtifactType", + "description": "This header parameter can be used to indicate the type of the artifact being added. Possible\nvalues include:\n\n* avro\n* protobuff\n* json\n* openapi\n* asyncapi", + "schema": { + "enum": [ + "avro", + "protobuff", + "json", + "openapi", + "asyncapi" + ], + "type": "string" + }, + "in": "header" + }, + { + "name": "X-Registry-ArtifactId", + "description": "Used to pass in a client-provided, globally unique identifier for the new artifact.", + "schema": { + "type": "string" + }, + "in": "header" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ArtifactMetaData" + } + } + }, + "description": "Artifact was successfully created." + } + }, + "operationId": "createArtifact", + "summary": "Create Artifact", + "description": "Creates a new artifact by POSTing the artifact content. The body of the request should\nbe the raw content of the artifact. This will typically be in JSON format for *most*\nof the supported types, but may be in another format for a few (e.g. Protobuff).\n\nThe registry will attempt to figure out what kind of artifact is being added from the\nfollowing supported list:\n\n* Avro (avro)\n* Protobuff (protobuff)\n* JSON Schema (json)\n* OpenAPI (openapi)\n* AsyncAPI (asyncapi)\n\nAlternatively, the artifact type can be indicated by either explicitly specifying the \ntype via the `X-Registry-ArtifactType` HTTP Request Header or by including a hint in the \nRequest's `Content-Type`.\n\nFor example:\n\n```\nContent-Type: application/json+avro\n```\n" + } + }, + "/artifacts/{artifactId}": { + "summary": "Manage a single artifact.", + "get": { + "tags": [ + "artifacts" + ], + "responses": { + "200": { + "content": { + "application/json": {}, + "application/x-yaml": {} + }, + "description": "The most recent version of the artifact." + } + }, + "operationId": "getLatestArtifact", + "summary": "Get Latest Artifact", + "description": "Returns the latest version of the artifact in its raw form. The `Content-Type` of the\nresponse will depend on what type of artifact it is. In most cases this will be\n`application/json` but for some types it may be different (e.g. *avro*).\n\nThis operation may fail for one of the following reasons:\n\n* No artifact with this `artifactId` exists (HTTP error `404`)\n* A server error occurred (HTTP error `500`)\n" + }, + "put": { + "requestBody": { + "content": { + "application/json": {}, + "application/x-yaml": {} + }, + "required": true + }, + "tags": [ + "artifacts" + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ArtifactMetaData" + } + } + }, + "description": "When successful, returns the updated artifact meta-data." + } + }, + "operationId": "updateArtifact", + "summary": "Update Artifact", + "description": "Updates an artifact by uploading new content. The update could fail for a number\nof reasons including:\n\n* No artifact with the `artifactId` exists (HTTP error `404`)\n* The new content violates one of the rules configured for the artifact (HTTP error `400`)\n* A server error occurred (HTTP error `500`)\n\nWhen successful, this creates a new version of the artifact, making it the most recent\n(and therefore official) version of the artifact." + }, + "delete": { + "tags": [ + "artifacts" + ], + "responses": { + "204": { + "description": "Returned when the artifact was successfully deleted." + } + }, + "operationId": "deleteArtifact", + "summary": "Delete Artifact", + "description": "Deletes an artifact completely, resulting in all versions of the artifact also being\ndeleted. This may fail for one of the following reasons:\n\n* No artifact with the `artifactId` exists (HTTP error `404`)\n* A server error occurred (HTTP error `500`)" + }, + "parameters": [ + { + "name": "artifactId", + "description": "The artifact ID. Can be a string (client provided) or integer (server generated) representing the unique artifact identifier.", + "schema": { + "type": "string" + }, + "in": "path", + "required": true + } + ] + }, + "/artifacts/{artifactId}/versions": { + "summary": "Manage all the versions of an artifact in the registry.", + "get": { + "tags": [ + "versions" + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "type": "integer" + } + }, + "examples": { + "All Versions": { + "value": [ + 5, + 6, + 10, + 103 + ] + } + } + } + }, + "description": "List of all artifact versions (just the version IDs)." + } + }, + "operationId": "listArtifactVersions", + "summary": "List Artifact Versions", + "description": "Returns a list of all version numbers for the artifact.\n\nThis operation can fail for the following reasons:\n\n* No artifact with this `artifactId` exists (HTTP error `404`)\n* A server error occurred (HTTP error `500`)\n" + }, + "post": { + "requestBody": { + "description": "The content of the artifact version being created - this is often, but not always, JSON data\nrepresenting one of the supported artifact types:\n\n* Avro\n* Protobuff\n* JSON Schema\n* OpenAPI\n* AsyncAPI", + "content": { + "application/json": {}, + "application/x-yaml": {} + }, + "required": true + }, + "tags": [ + "versions" + ], + "parameters": [ + { + "name": "X-Registry-ArtifactType", + "description": "This header parameter can be used to indicate the type of the artifact being added. Possible\nvalues include:\n\n* avro\n* protobuff\n* json\n* openapi\n* asyncapi", + "schema": { + "enum": [ + "avro", + "protobuff", + "json", + "openapi", + "asyncapi" + ], + "type": "string" + }, + "in": "header" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/VersionMetaData" + } + } + }, + "description": "The artifact version was successfully created." + } + }, + "operationId": "createArtifactVersion", + "summary": "Create Artifact Version", + "description": "Creates a new version of the artifact by uploading new content. The configured rules for\nthe artifact will be applied, and if they all pass then the new content will be added\nas the most recent version of the artifact. If any of the rules fail then an error \nwill be returned.\n\nThe body of the request should be the raw content of the new artifact version. This \nwill typically be in JSON format for *most* of the supported types, but may be in another \nformat for a few (e.g. Protobuff).\n\nThe registry will attempt to figure out what kind of artifact is being added from the\nfollowing supported list:\n\n* Avro (avro)\n* Protobuff (protobuff)\n* JSON Schema (json)\n* OpenAPI (openapi)\n* AsyncAPI (asyncapi)\n\nAlternatively, the artifact type can be indicated by either explicitly specifying the \ntype via the `X-Registry-ArtifactType` HTTP Request Header or by including a hint in the \nRequest's `Content-Type`.\n\nFor example:\n\n```\nContent-Type: application/json+avro\n```\n\nThis operation can fail for the following reasons:\n\n* No artifact with this `artifactId` exists (HTTP error `404`)\n* A server error occurred (HTTP error `500`)\n" + }, + "parameters": [ + { + "name": "artifactId", + "description": "The artifact ID. Can be a string (client provided) or integer (server generated) representing the unique artifact identifier.", + "schema": { + "type": "string" + }, + "in": "path", + "required": true + } + ] + }, + "/artifacts/{artifactId}/versions/{version}": { + "summary": "Manage a single version of a single artifact in the registry.", + "get": { + "tags": [ + "versions" + ], + "responses": { + "200": { + "content": { + "application/json": {}, + "application/x-yaml": {} + }, + "description": "The content of the artifact version." + } + }, + "operationId": "getArtifactVersion", + "summary": "Get Artifact Version", + "description": "Retrieves a single version of the artifact content. Both the `artifactId` and the\nunique `version` number must be provided. The `Content-Type` of the\nresponse will depend on what type of artifact it is. In most cases this will be\n`application/json` but for some types it may be different (e.g. *avro*).\n\nThis operation can fail for the following reasons:\n\n* No artifact with this `artifactId` exists (HTTP error `404`)\n* No version with this `version` exists (HTTP error `404`)\n* A server error occurred (HTTP error `500`)\n" + }, + "delete": { + "tags": [ + "versions" + ], + "responses": { + "204": { + "description": "The artifact version was successfully deleted." + } + }, + "operationId": "deleteArtifactVersion", + "summary": "Delete Artifact Version", + "description": "Deletes a single version of the artifact. Both the `artifactId` and the unique `version`\nare needed. If this is the only version of the artifact, then this operation is the same\nas deleting the entire artifact.\n\nThis operation can fail for the following reasons:\n\n* No artifact with this `artifactId` exists (HTTP error `404`)\n* No version with this `version` exists (HTTP error `404`)\n* A server error occurred (HTTP error `500`)\n" + }, + "parameters": [ + { + "name": "version", + "description": "The unique identifier of a specific version of the artifact content.", + "schema": { + "type": "integer" + }, + "in": "path", + "required": true + }, + { + "name": "artifactId", + "description": "The artifact ID. Can be a string (client provided) or integer (server generated) representing the unique artifact identifier.", + "schema": { + "type": "string" + }, + "in": "path", + "required": true + } + ] + }, + "/artifacts/{artifactId}/rules": { + "summary": "Manage the rules for a single artifact.", + "get": { + "tags": [ + "rules" + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Rule" + } + } + } + }, + "description": "Returns the rules configured for the artifact." + } + }, + "operationId": "listArtifactRules", + "summary": "List Artifact Rules", + "description": "Returns a list of all rules configured for the artifact. The set of rules determines\nhow the content of an artifact can evolve over time. If no rules are configured for\nan artifact, then the set of globally configured rules will be used. If no global\nrules are defined then there are no restrictions on content evolution.\n\nThis operation can fail for the following reasons:\n\n* No artifact with this `artifactId` exists (HTTP error `404`)\n* A server error occurred (HTTP error `500`)" + }, + "post": { + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Rule" + } + } + }, + "required": true + }, + "tags": [ + "rules" + ], + "responses": { + "201": { + "description": "The rule was added. A URI to the new rule can be found in the `Location` response header." + } + }, + "operationId": "createArtifactRule", + "summary": "Create Artifact Rule", + "description": "Adds a rule to the list of rules that get applied to the artifact when adding new\nversions. All configured rules must pass in order to successfully add a new artifact\nversion.\n\nThis operation can fail for the following reasons:\n\n* No artifact with this `artifactId` exists (HTTP error `404`)\n* Rule (named in the request body) not found (HTTP error `400`)\n* A server error occurred (HTTP error `500`)" + }, + "delete": { + "tags": [ + "rules" + ], + "responses": { + "204": { + "description": "The rules were successfully deleted." + } + }, + "operationId": "deleteArtifactRules", + "summary": "Delete Artifact Rules", + "description": "Deletes all of the rules configured for the artifact. After this is done, the global\nrules will once again apply to the artifact.\n\nThis operation can fail for the following reasons:\n\n* No artifact with this `artifactId` exists (HTTP error `404`)\n* A server error occurred (HTTP error `500`)" + }, + "parameters": [ + { + "name": "artifactId", + "description": "The artifact ID. Can be a string (client provided) or integer (server generated) representing the unique artifact identifier.", + "schema": { + "type": "string" + }, + "in": "path", + "required": true + } + ] + }, + "/artifacts/{artifactId}/rules/{rule}": { + "summary": "Manage the configuration of a single artifact rule.", + "get": { + "tags": [ + "rules" + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Rule" + } + } + }, + "description": "Information about a rule." + } + }, + "operationId": "getArtifactRuleConfig", + "summary": "Get Artifact Rule Config", + "description": "Returns information about a single rule configured for an artifact. This is useful\nwhen you want to know what the current configuration settings are for a specific rule.\n\nThis operation can fail for the following reasons:\n\n* No artifact with this `artifactId` exists (HTTP error `404`)\n* No rule with this name is configured for this artifact (HTTP error `404`)\n* A server error occurred (HTTP error `500`)" + }, + "put": { + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Rule" + } + } + }, + "required": true + }, + "tags": [ + "rules" + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Rule" + } + } + }, + "description": "Rule configuration was updated." + } + }, + "operationId": "updateArtifactRuleConfig", + "summary": "Update Artifact Rule Config", + "description": "Updates the configuration of a single rule for the artifact. The configuration data\nis specific to each rule type, so the configuration of the **Compatibility** rule \nwill be of a different format than the configuration of the **Validation** rule.\n\nThis operation can fail for the following reasons:\n\n* No artifact with this `artifactId` exists (HTTP error `404`)\n* No rule with this name is configured for this artifact (HTTP error `404`)\n* A server error occurred (HTTP error `500`)\n" + }, + "delete": { + "tags": [ + "rules" + ], + "responses": { + "204": { + "description": "The rule was successfully deleted." + } + }, + "operationId": "deleteArtifactRule", + "summary": "Delete Artifact Rule", + "description": "Deletes a rule from the artifact. This results in the rule no longer applying for\nthis artifact. If this is the only rule configured for the artifact, then this is\nthe same as deleting **all** rules: the globally configured rules will now apply to\nthis artifact.\n\nThis operation can fail for the following reasons:\n\n* No artifact with this `artifactId` exists (HTTP error `404`)\n* No rule with this name is configured for this artifact (HTTP error `404`)\n* A server error occurred (HTTP error `500`)" + }, + "parameters": [ + { + "name": "rule", + "description": "The unique name of a rule.", + "schema": { + "type": "string" + }, + "in": "path", + "required": true + }, + { + "name": "artifactId", + "description": "The artifact ID. Can be a string (client provided) or integer (server generated) representing the unique artifact identifier.", + "schema": { + "type": "string" + }, + "in": "path", + "required": true + } + ] + }, + "/rules": { + "summary": "Manage the global rules that apply to all artifacts if not otherwise configured.", + "get": { + "tags": [ + "rules", + "global rules" + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Rule" + } + } + } + }, + "description": "The list of globally configured rules." + } + }, + "operationId": "listGlobalRules", + "summary": "List Global Rules", + "description": "Gets a list of all the currently configured global rules (if any).\n\nThis operation can fail for the following reasons:\n\n* A server error occurred (HTTP error `500`)\n" + }, + "post": { + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Rule" + } + } + }, + "required": true + }, + "tags": [ + "rules", + "global rules" + ], + "responses": { + "201": { + "description": "The global rule was added. A URI to the new rule can be found in the `Location` response header." + } + }, + "operationId": "createGlobalRule", + "summary": "Create Global Rule", + "description": "Adds a rule to the list of globally configured rules.\n\nThis operation can fail for the following reasons:\n\n* The rule already exists (HTTP error `409`)\n* A server error occurred (HTTP error `500`)\n" + }, + "delete": { + "tags": [ + "rules", + "global rules" + ], + "responses": { + "204": { + "description": "All global rules have been removed successfully." + } + }, + "operationId": "deleteAllGlobalRules", + "summary": "Delete All Global Rules", + "description": "Deletes all globally configured rules.\n\nThis operation can fail for the following reasons:\n\n* A server error occurred (HTTP error `500`)\n" + } + }, + "/artifacts/{artifactId}/meta": { + "summary": "Manage the meta-data of a single artifact.", + "get": { + "tags": [ + "meta-data" + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ArtifactMetaData" + } + } + }, + "description": "The artifact's meta-data." + } + }, + "operationId": "getArtifactMetaData", + "summary": "Get Artifact Meta-Data", + "description": "Gets the meta-data for an artifact in the registry. The returned meta-data will include\nboth generated (read-only) and editable meta-data (such as name and description).\n\nThis operation can fail for the following reasons:\n\n* No artifact with this `artifactId` exists (HTTP error `404`)\n* A server error occurred (HTTP error `500`)" + }, + "put": { + "requestBody": { + "description": "Updated artifact meta-data.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/EditableMetaData" + } + } + }, + "required": true + }, + "tags": [ + "meta-data" + ], + "responses": { + "204": { + "description": "The artifact's meta-data was updated." + } + }, + "operationId": "updateArtifactMetaData", + "summary": "Update Artifact Meta-Data", + "description": "Updates the editable parts of the artifact's meta-data. Not all meta-data fields can\nbe updated. For example `createdOn` and `createdBy` are both read-only properties.\n\nThis operation can fail for the following reasons:\n\n* No artifact with the `artifactId` exists (HTTP error `404`)\n* A server error occurred (HTTP error `500`)" + }, + "parameters": [ + { + "name": "artifactId", + "description": "The artifact ID. Can be a string (client provided) or integer (server generated) representing the unique artifact identifier.", + "schema": { + "type": "string" + }, + "in": "path", + "required": true + } + ] + }, + "/artifacts/{artifactId}/versions/{version}/meta": { + "summary": "Manage the meta-data for a single version of an artifact in the registry.", + "get": { + "tags": [ + "versions", + "meta-data" + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/VersionMetaData" + } + } + }, + "description": "The artifact version's meta-data." + } + }, + "operationId": "getArtifactVersionMetaData", + "summary": "Get Artifact Version Meta-Data", + "description": "Retrieves the meta-data for a single version of the artifact. The version meta-data\nis a subset of the artifact meta-data - it is only the meta-data that is specific to\nthe version (and so doesn't include e.g. `modifiedOn`).\n\nThis operation can fail for the following reasons:\n\n* No artifact with this `artifactId` exists (HTTP error `404`)\n* No version with this `version` exists (HTTP error `404`)\n* A server error occurred (HTTP error `500`)\n" + }, + "put": { + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/EditableMetaData" + } + } + }, + "required": true + }, + "tags": [ + "versions", + "meta-data" + ], + "responses": { + "204": { + "description": "The artifact version's meta-data was successfully updated." + } + }, + "operationId": "updateArtifactVersionMetaData", + "summary": "Update Artifact Version Meta-Data", + "description": "Updates the user-editable portion of the artifact version's meta-data. Only some of \nthe meta-data fields are editable by the user. For example the `description` is editable\nbut the `createdOn` is not.\n\nThis operation can fail for the following reasons:\n\n* No artifact with this `artifactId` exists (HTTP error `404`)\n* No version with this `version` exists (HTTP error `404`)\n* A server error occurred (HTTP error `500`)\n" + }, + "delete": { + "tags": [ + "versions", + "meta-data" + ], + "responses": { + "204": { + "description": "The artifact version's user-editable meta-data was successfully deleted." + } + }, + "operationId": "deleteArtifactVersionMetaData", + "summary": "Delete Artifact Version Meta-Data", + "description": "Deletes the user-editable meta-data properties of the artifact version. Any properties\nthat are not user-editable will be preserved.\n\nThis operation can fail for the following reasons:\n\n* No artifact with this `artifactId` exists (HTTP error `404`)\n* No version with this `version` exists (HTTP error `404`)\n* A server error occurred (HTTP error `500`)\n" + }, + "parameters": [ + { + "name": "version", + "description": "The unique identifier of a specific version of the artifact content.", + "schema": { + "type": "integer" + }, + "in": "path", + "required": true + }, + { + "name": "artifactId", + "description": "The artifact ID. Can be a string (client provided) or integer (server generated) representing the unique artifact identifier.", + "schema": { + "type": "string" + }, + "in": "path", + "required": true + } + ] + }, + "/rules/{rule}": { + "summary": "Manage the configuration of a single global artifact rule.", + "get": { + "tags": [ + "rules", + "global rules" + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Rule" + } + } + }, + "description": "The global rule's configuration." + } + }, + "operationId": "getGlobalRuleConfig", + "summary": "Get Global Rule Config", + "description": "Returns information about the named globally configured rule.\n\nThis operation can fail for the following reasons:\n\n* No rule named `rule` exists (HTTP error `404`)\n* A server error occurred (HTTP error `500`)\n" + }, + "put": { + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Rule" + } + } + }, + "required": true + }, + "tags": [ + "rules", + "global rules" + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Rule" + } + } + }, + "description": "The global rule's configuration was successfully updated." + } + }, + "operationId": "updateGlobalRuleConfig", + "summary": "Update Global Rule Config", + "description": "Updates the configuration for a globally configured rule.\n\nThis operation can fail for the following reasons:\n\n* No rule named `rule` exists (HTTP error `404`)\n* A server error occurred (HTTP error `500`)\n" + }, + "delete": { + "tags": [ + "rules", + "global rules" + ], + "responses": { + "204": { + "description": "The global rule was successfully deleted." + } + }, + "operationId": "deleteGlobalRule", + "summary": "Delete Global Rule", + "description": "Deletes a single global rule. If this is the only rule configured, this is the same\nas deleting **all** rules.\n\nThis operation can fail for the following reasons:\n\n* No rule named `rule` exists (HTTP error `404`)\n* A server error occurred (HTTP error `500`)\n" + }, + "parameters": [ + { + "name": "rule", + "description": "The unique name of a rule.", + "schema": { + "type": "string" + }, + "in": "path", + "required": true + } + ] + } + }, + "components": { + "schemas": { + "EditableMetaData": { + "title": "Root Type for EditableArtifactMetaData", + "description": "", + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "description": { + "type": "string" + } + }, + "example": { + "name": "Artifact Name", + "description": "The description of the artifact." + } + }, + "VersionMetaData": { + "title": "Root Type for ArtifactVersionMetaData", + "description": "", + "required": [ + "createdOn", + "createdBy", + "version", + "id" + ], + "type": "object", + "properties": { + "version": { + "format": "int64", + "type": "integer" + }, + "name": { + "type": "string" + }, + "description": { + "type": "string" + }, + "createdBy": { + "type": "string" + }, + "createdOn": { + "format": "date-time", + "type": "string" + }, + "id": { + "format": "int64", + "description": "", + "type": "integer" + } + }, + "example": { + "id": 12938472, + "version": 12, + "name": "Artifact Name", + "description": "The description of the artifact", + "createdBy": "user1", + "createdOn": "2019-05-17T12:00:00Z" + } + }, + "ArtifactMetaData": { + "title": "Root Type for ArtifactMetaData", + "description": "", + "required": [ + "id", + "createdBy", + "createdOn", + "modifiedBy", + "modifiedOn", + "version", + "type" + ], + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "description": { + "type": "string" + }, + "createdBy": { + "type": "string" + }, + "createdOn": { + "format": "date-time", + "type": "string" + }, + "modifiedBy": { + "type": "string" + }, + "modifiedOn": { + "format": "date-time", + "type": "string" + }, + "id": { + "format": "int64", + "description": "", + "type": "integer" + }, + "version": { + "description": "", + "type": "integer" + }, + "type": { + "description": "", + "enum": [ + "avro", + "protobuff", + "json", + "openapi", + "asyncapi" + ], + "type": "string" + }, + "clientId": { + "description": "Identifier provided by the client. Must be globally unique.", + "type": "string" + } + }, + "example": { + "id": 19847289, + "clientId": "Procurement-Invoice", + "name": "Artifact Name", + "description": "Description of the artifact", + "type": "avro", + "version": 18, + "createdBy": "user1", + "createdOn": "2019-03-22T12:51:19Z", + "modifiedBy": "user2", + "modifiedOn": "2019-07-19T15:09:00Z" + } + }, + "Rule": { + "title": "Root Type for Rule", + "description": "", + "required": [ + "config" + ], + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "config": { + "type": "string" + } + }, + "example": { + "name": "UniqueRuleName", + "config": "configuration_of_rule" + } + } + } + }, + "tags": [ + { + "name": "artifacts", + "description": "" + }, + { + "name": "meta-data", + "description": "" + }, + { + "name": "versions", + "description": "" + }, + { + "name": "rules", + "description": "" + }, + { + "name": "global rules", + "description": "" + } + ] +} \ No newline at end of file