20 Advanced web service features

 

This chapter covers

  • Managing related data in web service results
  • Supporting the PATCH method to make selective changes
  • Formatting content produced by web services
  • Caching the output from web services
  • Generating documentation that describes a web service

In this chapter, I describe advanced features that can be used to create RESTful web services. I explain how to deal with related data in Entity Framework Core queries, how to add support for the HTTP PATCH method, how to use content negotiations, and how to use OpenAPI to describe your web services. Table 20.1 puts this chapter in context.

20.1 Preparing for this chapter

20.1.1 Dropping the database

20.1.2 Running the example application

20.2 Dealing with related data

20.2.1 Breaking circular references in related data

20.3 Supporting the HTTP PATCH method

20.3.1 Understanding JSON Patch

20.3.2 Installing and configuring the JSON Patch package

20.3.3 Defining the action method

20.4 Understanding content formatting

20.4.1 Understanding the default content policy

20.4.2 Understanding content negotiation

20.4.3 Specifying an action result format

20.4.4 Requesting a format in the URL

20.4.5 Restricting the formats received by an action method

20.4.6 Caching output

20.5 Documenting and exploring web services

20.5.1 Resolving action conflicts

20.5.2 Installing and configuring the Swashbuckle package

20.5.3 Fine-Tuning the API description

Summary