Skip to content

Commit

Permalink
More improvements to OpenAPI specs
Browse files Browse the repository at this point in the history
  • Loading branch information
peacekeeper committed Apr 9, 2024
1 parent d67384f commit 91943c3
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 21 deletions.
45 changes: 24 additions & 21 deletions openapi/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -199,25 +199,27 @@ components:
type: string
example: 6d85bcd0-2ea3-4288-ab00-15afadd8a156
options:
description: This input field contains an object with various options for
the DID operation, such as the network where the DID operation should be executed.
See <a href="https://identity.foundation/did-registration/#options">https://identity.foundation/did-registration/#options</a>.
type: object
properties:
clientSecretMode:
$ref: "#/components/schemas/Boolean"
storeSecrets:
$ref: "#/components/schemas/Boolean"
returnSecrets:
$ref: "#/components/schemas/Boolean"
requestVerificationMethod:
$ref: "#/components/schemas/RegistrarRequestOptionsRequestVerificationMethod"
additionalProperties: { }
example:
network: testnet
$ref: "#/components/schemas/RequestOptions"
secret:
$ref: "#/components/schemas/RequestSecret"
RegistrarRequestOptionsRequestVerificationMethod:
RequestOptions:
description: This input field contains an object with various options for
the DID operation, such as the network where the DID operation should be executed.
See <a href="https://identity.foundation/did-registration/#options">https://identity.foundation/did-registration/#options</a>.
type: object
properties:
clientSecretMode:
$ref: "#/components/schemas/Boolean"
storeSecrets:
$ref: "#/components/schemas/Boolean"
returnSecrets:
$ref: "#/components/schemas/Boolean"
requestVerificationMethod:
$ref: "#/components/schemas/RequestOptionsRequestVerificationMethod"
additionalProperties: { }
example:
network: testnet
RequestOptionsRequestVerificationMethod:
type: array
items:
$ref: "#/components/schemas/VerificationMethodTemplate"
Expand Down Expand Up @@ -420,10 +422,11 @@ components:
oneOf:
- $ref: "#/components/schemas/VerificationMethodPublicData"
- $ref: "#/components/schemas/VerificationMethodPrivateData"
- type:
array
items:
$ref: "#/components/schemas/VerificationMethodTemplate"
- $ref: "#/components/schemas/SecretVerificationMethodVerificationMethodTemplate"
SecretVerificationMethodVerificationMethodTemplate:
type: array
items:
$ref: "#/components/schemas/VerificationMethodTemplate"
RequestSecret:
description: This input field contains an object with DID controller keys
and other secrets needed for performing the DID operation. See
Expand Down
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
<maven-install-plugin.version>3.1.1</maven-install-plugin.version>
<maven-deploy-plugin.version>3.1.1</maven-deploy-plugin.version>
<maven-release-plugin.version>3.0.1</maven-release-plugin.version>
<maven-patch-plugin.version>1.2</maven-patch-plugin.version>

<!-- Testing Versions -->

Expand Down Expand Up @@ -175,6 +176,11 @@
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>${openapi-generator.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-patch-plugin</artifactId>
<version>${maven-patch-plugin.version}</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
Expand Down
17 changes: 17 additions & 0 deletions uni-registrar-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,23 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-patch-plugin</artifactId>
<configuration>
<patchFile>src/main/patches/uniregistrar/openapi/model/SecretVerificationMethodInner.patch</patchFile>
<targetDirectory>openapi/java-client-generated/</targetDirectory>
</configuration>
<executions>
<execution>
<id>patch</id>
<phase>process-sources</phase>
<goals>
<goal>apply</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
--- src/main/java/uniregistrar/openapi/model/SecretVerificationMethodInner.java 2023-11-05 20:15:11.061198670 +0100
+++ src/main/java/uniregistrar/openapi/model/SecretVerificationMethodInner.java.patched 2023-11-05 20:15:04.869182118 +0100
@@ -17,6 +17,7 @@
import java.nio.charset.StandardCharsets;
import java.util.StringJoiner;
import java.util.Objects;
+import java.util.List;
import java.util.Map;
import java.util.HashMap;
import com.fasterxml.jackson.annotation.JsonInclude;
@@ -99,17 +100,17 @@
try {
boolean attemptParsing = true;
// ensure that we respect type coercion as set on the client ObjectMapper
- if (List<@Valid VerificationMethodTemplate>.class.equals(Integer.class) || List<@Valid VerificationMethodTemplate>.class.equals(Long.class) || List<@Valid VerificationMethodTemplate>.class.equals(Float.class) || List<@Valid VerificationMethodTemplate>.class.equals(Double.class) || List<@Valid VerificationMethodTemplate>.class.equals(Boolean.class) || List<@Valid VerificationMethodTemplate>.class.equals(String.class)) {
+ if (List.class.equals(Integer.class) || List.class.equals(Long.class) || List.class.equals(Float.class) || List.class.equals(Double.class) || List.class.equals(Boolean.class) || List.class.equals(String.class)) {
attemptParsing = typeCoercion;
if (!attemptParsing) {
- attemptParsing |= ((List<@Valid VerificationMethodTemplate>.class.equals(Integer.class) || List<@Valid VerificationMethodTemplate>.class.equals(Long.class)) && token == JsonToken.VALUE_NUMBER_INT);
- attemptParsing |= ((List<@Valid VerificationMethodTemplate>.class.equals(Float.class) || List<@Valid VerificationMethodTemplate>.class.equals(Double.class)) && token == JsonToken.VALUE_NUMBER_FLOAT);
- attemptParsing |= (List<@Valid VerificationMethodTemplate>.class.equals(Boolean.class) && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE));
- attemptParsing |= (List<@Valid VerificationMethodTemplate>.class.equals(String.class) && token == JsonToken.VALUE_STRING);
+ attemptParsing |= ((List.class.equals(Integer.class) || List.class.equals(Long.class)) && token == JsonToken.VALUE_NUMBER_INT);
+ attemptParsing |= ((List.class.equals(Float.class) || List.class.equals(Double.class)) && token == JsonToken.VALUE_NUMBER_FLOAT);
+ attemptParsing |= (List.class.equals(Boolean.class) && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE));
+ attemptParsing |= (List.class.equals(String.class) && token == JsonToken.VALUE_STRING);
}
}
if (attemptParsing) {
- deserialized = tree.traverse(jp.getCodec()).readValueAs(List<@Valid VerificationMethodTemplate>.class);
+ deserialized = tree.traverse(jp.getCodec()).readValueAs(List.class);
// TODO: there is no validation against JSON schema constraints
// (min, max, enum, pattern...), this does not perform a strict JSON
// validation, which means the 'match' count may be higher than it should be.
@@ -213,7 +214,7 @@
}

static {
- schemas.put("List<@Valid VerificationMethodTemplate>", List<@Valid VerificationMethodTemplate>.class);
+ schemas.put("List<@Valid VerificationMethodTemplate>", List.class);
schemas.put("VerificationMethodPrivateData", VerificationMethodPrivateData.class);
schemas.put("VerificationMethodPublicData", VerificationMethodPublicData.class);
JSON.registerDescendants(SecretVerificationMethodInner.class, Collections.unmodifiableMap(schemas));
@@ -234,7 +235,7 @@
*/
@Override
public void setActualInstance(Object instance) {
- if (JSON.isInstanceOf(List<@Valid VerificationMethodTemplate>.class, instance, new HashSet<Class<?>>())) {
+ if (JSON.isInstanceOf(List.class, instance, new HashSet<Class<?>>())) {
super.setActualInstance(instance);
return;
}
@@ -270,7 +271,7 @@
* @return The actual instance of `List<@Valid VerificationMethodTemplate>`
* @throws ClassCastException if the instance is not `List<@Valid VerificationMethodTemplate>`
*/
- public List<@Valid VerificationMethodTemplate> getList<@Valid VerificationMethodTemplate>() throws ClassCastException {
+ public List<@Valid VerificationMethodTemplate> getListVerificationMethodTemplate() throws ClassCastException {
return (List<@Valid VerificationMethodTemplate>)super.getActualInstance();
}

@@ -342,11 +343,11 @@
}
return joiner.toString();
}
- if (getActualInstance() instanceof List<@Valid VerificationMethodTemplate>) {
+ if (getActualInstance() instanceof List<?>) {
if (getActualInstance() != null) {
for (int i = 0; i < ((List<@Valid VerificationMethodTemplate>)getActualInstance()).size(); i++) {
if (((List<@Valid VerificationMethodTemplate>)getActualInstance()).get(i) != null) {
- joiner.add(((VerificationMethodTemplate)getActualInstance()).get(i).toUrlQueryString(String.format("%sone_of_2%s%s", prefix, suffix,
+ joiner.add(((List<@Valid VerificationMethodTemplate>)getActualInstance()).get(i).toUrlQueryString(String.format("%sone_of_2%s%s", prefix, suffix,
"".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix))));
}
}

0 comments on commit 91943c3

Please sign in to comment.