From 97dd52a36fed231d1aa96732decbf8b2f84e7f03 Mon Sep 17 00:00:00 2001 From: BigBlueHat Date: Wed, 8 Jan 2020 10:07:36 -0500 Subject: [PATCH] Fix failure when response object lacks content The `content` property is optional or may be a string in Response Objects: https://spec.openapis.org/oas/v3.0.2#response-object --- templates/openapi3/responses.def | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/openapi3/responses.def b/templates/openapi3/responses.def index ac9679ef..6f4165f0 100644 --- a/templates/openapi3/responses.def +++ b/templates/openapi3/responses.def @@ -28,7 +28,7 @@ {{? response.content && !response.$ref && !data.utils.isPrimitive(response.type)}} {{? Object.keys(response.content).length }} {{ var responseKey = Object.keys(response.content)[0]; }} -{{ var responseSchema = response.content[responseKey].schema; }} +{{ var responseSchema = 'content' in response && responseKey in response.content && 'schema' in response.content[responseKey] ? response.content[responseKey].schema : {}; }} {{ var enums = []; }} {{ var blocks = data.utils.schemaToArray(responseSchema,0,{trim:true,join:true},data); }} {{ for (var block of blocks) {