How to define POST parameter in serverless.yml

Hi,

We want to define POST parameter in the serverless.yml file so that the definition in yml file can used to create model and update the method request body during

sls deploy.

With following post value,

{servicename: “someserver”, userID: “some_user_id”, username: “username1”, requestedOn: “date”, request: {HTTPVerb: “sometext”}}

We want to create model with name auditLog and following schema,

{
“title”: “auditLog”,
“type”: “object”,
“properties”: {
“serviceName”: {
“type”: “string”
},
“userID”: {
“type”: “string”,
“format”: “email”
},
“username”: {
“type”: “string”
},
“requestedOn”: {
“type”: “string”
},
“request”: {
“type”: “object”,
“properties”: {
“HTTPVerb”: {
“type”: “string”
}
}
}
}

update the model in method request body model.

Thank
Satheesh

Sorry not following you here.

What is the question? =)

Hi David,

I want to define something similar below in serverless.yml, so that when I execute “serverless deploy”. The deploy should generate the following structure in API gateway.

Something like this in the definition, (But the definition wrong).

   functions:
      health:
        handler: handler.health
        description: Stores the log details
        Type: "AWS::ApiGateway::RestApi"
        events:
          - http:
              path: health
              method: post
              cors: true
              authorizer: apiAuth
              request:
                parameters: 
                  application/json: '{"title":"auditLog","type":"object","properties":{"serviceName":{"type":"string"},"userID":{"type":"string","format":"email"}}}'

Should generate the model with the following definition.

api_model_def

The generated model should be assigned to the request body of the method POST.
(APIs → dev-audit-api → Resource → health > POST)

Please let me know, if you can help.

Thank you,

Satheesh

Hi,

On to my future investigation and googling through I found the Serverless AWS Documentation plugin which helps in deploying model from yml as well as documentation.

You can find the more on there,

Thanks,

Satheesh