Input models

The input models will take in all the information we need to process a request. We only need three models:

  • AddressInput: When passing along address information.
  • NewUserInput: When registering a new user.
  • EditUserInput: When editing an existing user.
  • LoginInput: When logging in.

Go through the following steps to create the models:

  1. Create an AddressInput.swift file in Sources/App/Models/Inputs/ and insert the first model, as follows:
import Vaporstruct AddressInput: Content {    let street: String    let city: String    let zip: String}

The model only reflects the properties that we need from the model. It conforms to the Content protocol.

  1. Create a new NewUserInput.swift file, as follows:
import Vaporstruct NewUserInput: Content ...

Get Hands-On Swift 5 Microservices Development now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.