Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,21 @@ Unit tests are an essential part of the development process. To run the unit tes
```
This command will run all the tests in the project and provide a summary of the results.

## Generate Keria models from OpenAPI
The Gradle `openApiGenerate` task can build Java model classes directly from the Keria OpenAPI spec.

By default it uses `http://localhost:3902/spec.yaml` (or the `SPEC_URL` you set):
```bash
./gradlew openApiGenerate
```

To point at another Keria instance, override `SPEC_URL`:
```bash
SPEC_URL=http://localhost:3902/spec.yaml ./gradlew openApiGenerate
```

The generated sources are placed under `build/generated/src/main/java` and are automatically added to the `main` source set.

## Build Docker when run E2E tests
The integration tests depends on a local instance of KERIA, vLEI-Server and Witness Demo. These are specified in the [Docker Compose](./docker-compose.yaml) file. To start the dependencies, use docker compose:

Expand Down Expand Up @@ -83,4 +98,4 @@ Use the gradlew script "test E2E" to run all E2E tests in sequence:
Use the gradlew script "Allure Serve" to view the test result report:
```bash
./gradlew allureServe
```
```
60 changes: 60 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ plugins {
id 'io.qameta.allure' version '2.11.2'
id 'org.ajoberstar.grgit' version '5.2.0'
id 'org.jreleaser' version '1.19.0'
id("org.openapi.generator") version "7.16.0"
}

repositories {
Expand Down Expand Up @@ -36,6 +37,8 @@ def jacksonVersion = '2.18.1'
def bouncycastleVersion = '1.79'
def jsonVersion = '20240303'
def structuredFieldsVersion = '0.4'
def jakartaAnnotationVersion = '2.1.1'
def jacksonNullableVersion = '0.2.6'

// test dependencies
def testngVersion = '7.7.0'
Expand All @@ -56,6 +59,8 @@ dependencies {
implementation "org.bouncycastle:bcprov-jdk18on:${bouncycastleVersion}"
implementation "org.json:json:${jsonVersion}"
implementation "org.greenbytes.http:structured-fields:${structuredFieldsVersion}"
implementation "jakarta.annotation:jakarta.annotation-api:${jakartaAnnotationVersion}"
implementation "org.openapitools:jackson-databind-nullable:${jacksonNullableVersion}"

testImplementation platform("org.junit:junit-bom:${junitVersion}")
testImplementation "org.junit.jupiter:junit-jupiter:${junitVersion}"
Expand Down Expand Up @@ -187,3 +192,58 @@ tasks.register('allureE2ETestReport') {
tasks.named('allureReport') {
enabled = false
}

tasks.openApiGenerate {
generatorName.set("java")
def generatedSpec = layout.buildDirectory.file("generated/spec/keria-openapi.yaml")
inputSpec.set(generatedSpec.map { it.asFile.absolutePath })
outputDir.set("$rootDir".toString())
validateSpec.set(false)
skipValidateSpec.set(true)
modelPackage.set("org.cardanofoundation.signify.generated.keria.model")
invokerPackage.set("org.cardanofoundation.signify.generated.keria.model")

globalProperties.set([
models : "", // generate models only
modelDocs : "false",
modelTests : "false",
])

configOptions = [
library : "resttemplate",
serializationLibrary : "jackson",
useJakartaEe : "true",
dateLibrary : "java21",
sourceFolder : "src/main/java"
]

nameMappings.put("A", "AUpper")
}

tasks.register("prepareOpenApiSpec") {
group = "openapi"
description = "Fetches keria OpenAPI spec from SPEC_URL"

def generatedSpec = layout.buildDirectory.file("generated/spec/keria-openapi.yaml")
outputs.file(generatedSpec)

doLast {
def specUrl = System.getenv("SPEC_URL") ?: "http://localhost:3902/spec.yaml"
def target = generatedSpec.get().asFile
target.parentFile.mkdirs()

logger.lifecycle("Downloading OpenAPI spec from ${specUrl}")
try {
target.withOutputStream { out ->
new URL(specUrl).withInputStream { input -> out << input }
}
} catch (Exception ex) {
throw new GradleException("Failed to download spec from ${specUrl}. Set SPEC_URL to a reachable spec endpoint.", ex)
}
logger.lifecycle("Spec available at ${target}")
}
}

tasks.named("openApiGenerate") {
dependsOn("prepareOpenApiSpec")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
/*
* KERIA Interactive Web Interface API
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 1.0.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/


package org.cardanofoundation.signify.generated.keria.model;

import java.util.Map;
import java.util.HashMap;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import java.util.Objects;
import java.util.Arrays;
import java.util.Locale;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.fasterxml.jackson.annotation.JsonValue;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.annotation.JsonTypeName;

/**
* ACDCAttributes
*/
@JsonPropertyOrder({
ACDCAttributes.JSON_PROPERTY_DT,
ACDCAttributes.JSON_PROPERTY_I,
ACDCAttributes.JSON_PROPERTY_U
})
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-11-27T15:07:13.177027+07:00[Asia/Ho_Chi_Minh]", comments = "Generator version: 7.16.0")
public class ACDCAttributes {
public static final String JSON_PROPERTY_DT = "dt";
@jakarta.annotation.Nullable
private String dt;

public static final String JSON_PROPERTY_I = "i";
@jakarta.annotation.Nullable
private String i;

public static final String JSON_PROPERTY_U = "u";
@jakarta.annotation.Nullable
private String u;

public ACDCAttributes() {
}

public ACDCAttributes dt(@jakarta.annotation.Nullable String dt) {

this.dt = dt;
return this;
}

/**
* Get dt
* @return dt
*/
@jakarta.annotation.Nullable
@JsonProperty(value = JSON_PROPERTY_DT, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)

public String getDt() {
return dt;
}


@JsonProperty(value = JSON_PROPERTY_DT, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setDt(@jakarta.annotation.Nullable String dt) {
this.dt = dt;
}

public ACDCAttributes i(@jakarta.annotation.Nullable String i) {

this.i = i;
return this;
}

/**
* Get i
* @return i
*/
@jakarta.annotation.Nullable
@JsonProperty(value = JSON_PROPERTY_I, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)

public String getI() {
return i;
}


@JsonProperty(value = JSON_PROPERTY_I, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setI(@jakarta.annotation.Nullable String i) {
this.i = i;
}

public ACDCAttributes u(@jakarta.annotation.Nullable String u) {

this.u = u;
return this;
}

/**
* Get u
* @return u
*/
@jakarta.annotation.Nullable
@JsonProperty(value = JSON_PROPERTY_U, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)

public String getU() {
return u;
}


@JsonProperty(value = JSON_PROPERTY_U, required = false)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setU(@jakarta.annotation.Nullable String u) {
this.u = u;
}

/**
* A container for additional, undeclared properties.
* This is a holder for any undeclared properties as specified with
* the 'additionalProperties' keyword in the OAS document.
*/
private Map<String, Object> additionalProperties;

/**
* Set the additional (undeclared) property with the specified name and value.
* If the property does not already exist, create it otherwise replace it.
* @param key the name of the property
* @param value the value of the property
* @return self reference
*/
@JsonAnySetter
public ACDCAttributes putAdditionalProperty(String key, Object value) {
if (this.additionalProperties == null) {
this.additionalProperties = new HashMap<String, Object>();
}
this.additionalProperties.put(key, value);
return this;
}

/**
* Return the additional (undeclared) properties.
* @return the additional (undeclared) properties
*/
@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return additionalProperties;
}

/**
* Return the additional (undeclared) property with the specified name.
* @param key the name of the property
* @return the additional (undeclared) property with the specified name
*/
public Object getAdditionalProperty(String key) {
if (this.additionalProperties == null) {
return null;
}
return this.additionalProperties.get(key);
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ACDCAttributes acDCAttributes = (ACDCAttributes) o;
return Objects.equals(this.dt, acDCAttributes.dt) &&
Objects.equals(this.i, acDCAttributes.i) &&
Objects.equals(this.u, acDCAttributes.u) &&
Objects.equals(this.additionalProperties, acDCAttributes.additionalProperties);
}

@Override
public int hashCode() {
return Objects.hash(dt, i, u, additionalProperties);
}

@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class ACDCAttributes {\n");
sb.append(" dt: ").append(toIndentedString(dt)).append("\n");
sb.append(" i: ").append(toIndentedString(i)).append("\n");
sb.append(" u: ").append(toIndentedString(u)).append("\n");
sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n");
sb.append("}");
return sb.toString();
}

/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}

}

Loading
Loading