Lesson 7 - Applying what we've learned - Implement a model

Title: Implement a model

Time: 10-30 minutes

Purpose: To practice our skills at creating models, and modifying them for our needs.

Introduction:
At the end of Lesson 7 I challenged you to implement a model, either for your own API at work, or for Restful Booker.

Activity:

  • Choose a request or response model to implement
  • Decide on a method to create the model
    • Paste JSON/XML As Classes feature in Visual Studio
    • Hand-writing the model
  • Implement the model (this can be in the codebase we have for this class, it won’t hurt anything!)
  • Make any required changes to the model
    • adding a Required attribute, or default value - based on what you know about the API
  • Share here how you implemented it, and if you found anything weird or confusing with your API

I didn’t come as far as implementing my own model, but I can think of a situation where I would want this.

I decided to look at my own team’s application. We maintain two applications, where application A calls the API of application B. Application A and Application B are in different repos.

A nice project for me would be to write tests for those endpoints of application B that application A depends on. I might then make a model of those endpoints.

1 Like