Model definitions

First, let's define the models that we require the API gateway to receive. The following contents go in the /resources/api/api.yml file. With this, the serverless-aws-documentation plugin generates the models for use in the API gateway:

      api:        info:          version: '2'          title: Lets Poll API Documentation          description: Documentation to support the Lets Poll API and generate its models.        tags:          -            name: Name            description: Lets Poll API               # Now we describe all the models that we use      models:        -          name: Poll          contentType: "application/json"          schema :              type: "object"              required:              - "pollOptions"              - "pollQuestion"              - "pollTitle"              properties:                pollId:                  type: "string"                pollTitle:                  type: "string"                pollQuestion:                  type: "string"                pollOptions:                  type: "array"                  items: type: ...

Get Hands-On Serverless Applications with Kotlin now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.