Skip to content

Commit

Permalink
improvement, oas: do not require schema to be present to parse respon…
Browse files Browse the repository at this point in the history
…se objects (#3438)
  • Loading branch information
armandobelardo authored Apr 23, 2024
1 parent c522c3f commit 15e024f
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14089,6 +14089,23 @@ exports[`open api parser aries simple 1`] = `
"type": "file",
},
},
"download_tails_file_sparse": {
"auth": true,
"display-name": "Download tails file",
"docs": undefined,
"method": "GET",
"path": "/revocation/registry/{rev_reg_id}/tails-file-less-deets",
"path-parameters": {
"rev_reg_id": {
"docs": "Revocation Registry identifier",
"type": "string",
},
},
"response": {
"docs": "tails file",
"type": "file",
},
},
"get_active_registry_for_cred_def_id": {
"auth": true,
"display-name": "Get current active revocation registry by credential definition id",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4295,6 +4295,27 @@ paths:
summary: Set revocation registry state manually
tags:
- revocation
/revocation/registry/{rev_reg_id}/tails-file-less-deets:
get:
operationId: download_tails_file_sparse
parameters:
- description: Revocation Registry identifier
explode: false
in: path
name: rev_reg_id
required: true
schema:
pattern: "^([123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{21,22}):4:([123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{21,22}):3:CL:(([1-9][0-9]*)|([123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{21,22}:2:.+:[0-9.]+))(:.+)?:CL_ACCUM:(.+$)"
type: string
style: simple
responses:
"200":
content:
application/octet-stream: {}
description: tails file
summary: Download tails file
tags:
- revocation
/revocation/registry/{rev_reg_id}/tails-file:
get:
operationId: download_tails_file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58289,6 +58289,52 @@ exports[`open api parser aries parse open api 1`] = `
"revocation",
],
},
{
"audiences": [],
"authed": true,
"availability": null,
"description": null,
"errorStatusCode": [],
"examples": [],
"generatedRequestName": "DownloadTailsFileSparseRequest",
"headers": [],
"internal": null,
"method": "GET",
"operationId": "download_tails_file_sparse",
"path": "/revocation/registry/{rev_reg_id}/tails-file-less-deets",
"pathParameters": [
{
"description": "Revocation Registry identifier",
"name": "rev_reg_id",
"schema": {
"description": null,
"generatedName": "DownloadTailsFileSparseRequestRevRegId",
"groupName": null,
"nameOverride": null,
"schema": {
"maxLength": null,
"minLength": null,
"type": "string",
},
"type": "primitive",
},
"variableReference": null,
},
],
"queryParameters": [],
"request": null,
"requestNameOverride": null,
"response": {
"description": "tails file",
"type": "file",
},
"sdkName": null,
"server": [],
"summary": "Download tails file",
"tags": [
"revocation",
],
},
{
"audiences": [],
"authed": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4295,6 +4295,27 @@ paths:
summary: Set revocation registry state manually
tags:
- revocation
/revocation/registry/{rev_reg_id}/tails-file-less-deets:
get:
operationId: download_tails_file_sparse
parameters:
- description: Revocation Registry identifier
explode: false
in: path
name: rev_reg_id
required: true
schema:
pattern: "^([123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{21,22}):4:([123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{21,22}):3:CL:(([1-9][0-9]*)|([123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{21,22}:2:.+:[0-9.]+))(:.+)?:CL_ACCUM:(.+$)"
type: string
style: simple
responses:
"200":
content:
application/octet-stream: {}
description: tails file
summary: Download tails file
tags:
- revocation
/revocation/registry/{rev_reg_id}/tails-file:
get:
operationId: download_tails_file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ export function convertResponse({
};
}

function isOctetStreamResponse(response: OpenAPIV3.ResponseObject): boolean {
return response?.content?.[APPLICATION_OCTET_STREAM_CONTENT] != null;
}

function convertResolvedResponse({
operationContext,
streamFormat,
Expand Down Expand Up @@ -149,15 +153,15 @@ function convertResolvedResponse({
});
}

if (resolvedResponse.content?.[APPLICATION_OCTET_STREAM_CONTENT]?.schema != null) {
if (resolvedResponse.content?.[APPLICATION_OCTET_STREAM_CONTENT] != null) {
return ResponseWithExample.file({ description: resolvedResponse.description });
}

if (resolvedResponse.content?.[APPLICATION_PDF]?.schema != null) {
if (resolvedResponse.content?.[APPLICATION_PDF] != null) {
return ResponseWithExample.file({ description: resolvedResponse.description });
}

if (resolvedResponse.content?.[TEXT_PLAIN_CONTENT]?.schema != null) {
if (resolvedResponse.content?.[TEXT_PLAIN_CONTENT] != null) {
const textPlainSchema = resolvedResponse.content[TEXT_PLAIN_CONTENT]?.schema;
if (textPlainSchema == null) {
return ResponseWithExample.text({ description: resolvedResponse.description });
Expand Down

0 comments on commit 15e024f

Please sign in to comment.