Skip to content
This repository has been archived by the owner on Jul 23, 2021. It is now read-only.

Support in-line response model #140

Open
lucas-rudd opened this issue Nov 12, 2019 · 1 comment
Open

Support in-line response model #140

lucas-rudd opened this issue Nov 12, 2019 · 1 comment

Comments

@lucas-rudd
Copy link

lucas-rudd commented Nov 12, 2019

Perhaps this is a limitation of AWS API Gateway.

But, I've noticed when doing the following, that I get a CloudFormation template validation error

methodResponses:
  - statusCode: '200'
     responseBody:
      description: Ok
     responseModels:
      application/json:
        additionalProperties: true
        type: object

I get the following error

Template format error: Unresolved resource dependencies [[object Object]Model]

This is due to this line in models.js

resource.DependsOn.add(`${models[contentType]}Model`);

I'm curious as to if the inline response model is an object that we could simply skip adding anything to the resource.DependsOn set.
As there is no external model to depend on, it would seem as if we could simply do something like

addModelDependencies: function addModelDependencies(models, resource) {
    Object.keys(models).forEach(contentType => {
     if(typeof models[contentType] !== 'object') {
       resource.DependsOn.add(`${models[contentType]}Model`);
     }
    });
  },
@lucas-rudd
Copy link
Author

So, I've tested this myself, and it appears as though this is a limitation of API Gateway

When running sls package, my method response looked like this

"MethodResponses": [
          {
            "StatusCode": "200",
            "ResponseModels": {
              "application/json": {
                "additionalProperties": true,
                "type": "object"
              }
            }
          }
        ]
      },
      "DependsOn": []
    },

And I got the following error in the CloudFormation stack

Value of property ResponseModels must be an object with String (or simple type) properties

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant