From 5a8d259a24571b3f4cb8c0bf6fc93aa090994477 Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Wed, 25 Sep 2024 16:31:41 -0400 Subject: [PATCH 1/3] Remove dangling commas & add proof to UnsecuredCredential. --- components/Credential.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/components/Credential.yml b/components/Credential.yml index 30ec1f2..50fb409 100644 --- a/components/Credential.yml +++ b/components/Credential.yml @@ -58,8 +58,8 @@ components: { "type": "BachelorDegree", "name": "Bachelor of Science and Arts", - }, - }, + } + } } UnsecuredCredential: type: object @@ -89,6 +89,11 @@ components: "credentialSubject": type: object description: The subject + "proof": + description: An optional proof for credentials that are secured using proof sets or chains. + oneOf: + - type: object + - type: array example: { "@context": @@ -107,6 +112,6 @@ components: { "type": "BachelorDegree", "name": "Bachelor of Science and Arts", - }, - }, + } + } } From 3592e9881c54bd9ac5b00744ae0e47bc83606412 Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Wed, 25 Sep 2024 16:32:22 -0400 Subject: [PATCH 2/3] Improve definition of UnsecuredCredential. --- components/Credential.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/Credential.yml b/components/Credential.yml index 50fb409..f6a4711 100644 --- a/components/Credential.yml +++ b/components/Credential.yml @@ -63,7 +63,7 @@ components: } UnsecuredCredential: type: object - description: A W3C Verifiable Credential without a proof. + description: A W3C Verifiable Credential intended for issuance. properties: "@context": type: array From fe8e72209cc6598bfa5fd43d8000c92f36133309 Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Wed, 25 Sep 2024 17:20:38 -0400 Subject: [PATCH 3/3] Improve respec-oas with support for array types in oneOf. --- components/Credential.yml | 3 +++ respec-oas.js | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/components/Credential.yml b/components/Credential.yml index f6a4711..fab6ed5 100644 --- a/components/Credential.yml +++ b/components/Credential.yml @@ -90,10 +90,13 @@ components: type: object description: The subject "proof": + type: object description: An optional proof for credentials that are secured using proof sets or chains. oneOf: - type: object - type: array + items: + type: object example: { "@context": diff --git a/respec-oas.js b/respec-oas.js index 61d33a2..eec80da 100644 --- a/respec-oas.js +++ b/respec-oas.js @@ -285,11 +285,16 @@ function renderJsonSchemaObject(schema) { } else if(schema.oneOf) { objectRendering += ' either '; let itemCount = 0; - for(item of schema.oneOf) { + for(const item of schema.oneOf) { if(item.type === 'string') { objectRendering += 'a string'; } else if(item.type === 'object') { objectRendering += renderJsonSchemaObject(item); + } else if(item.type === 'array') { + objectRendering += 'an array'; + if(item.items) { + objectRendering += ` of ${item.items.type}(s)`; + } } itemCount += 1; @@ -307,7 +312,7 @@ function renderJsonSchemaObject(schema) { } } else { objectRendering += 'an object of the following form:
'; - for(property in schema.properties) { + for(const property in schema.properties) { const value = schema.properties[property]; objectRendering += renderJsonSchemaProperty(property, value); }