UTF-8
Errata: July 25, 2023

Thank you for purchasing API Design Patterns. Please post errata not listed below in this book's LiveBook Errata thread. We'll update this list as necessary. Corrections are made to all formats during the book's second printing. Thank you!



The following correction needs to be made to the mobile book formats (pBook/eBook are fine).

Chapter 5, Section 5.3.3 Serialization, page 72

Listing 5.5 should be:

const Decimal = require('decimal.js');



function jsonDecimalAddition(): number {

const a = JSON.parse('{"value": "0.1"}');

const b = JSON.parse('{"value": "0.2"}');

return Decimal(a['value']).add(Decimal(b['value']);

}



The following corrections were made during the book's second printing, Winter 2022.

Chapter 1, Section 1.4.2 Expressive, page 10

In Listing 1.1: if (translatedText == inputText) { should be if (translatedText === inputText) {

Chapter 2, Section 2.4.2 Listing messages, page 25

In Listing 2.2: maxPageSize: number?; should be maxPageSize?: number;

Chapter 3, Section 3.2.3 Predictable, page 36

In Listing 3.1:

function handleMessage(message: Message) { should be function handleMessage(message: Message): void {

if (message.topic == "budget.purge") { should be if (message.topic === "budget.purge") {

Chapter 3, Section 3.6 Case study: What happens when you choose bad names?, page 44-5

In Listing 3.6:

CalculateImpulse(CalculateImpulseRequest): should be CalculateImpulse(req: CalculateImpulseRequest):

CalculateManeuver(CalculateManeuverRequest): should be CalculateManeuver(req: CalculateManeuverRequest):

Chapter 5, Section 5.3.3 Serialization, page 72

In Listing 5.3: const compareJsonNumbers(): boolean { should be function compareJsonNumbers(): boolean {

In Listing 5.4: const jsonAddition(): number { should be function jsonAddition(): number {

In Listing 5.5: const jsonDecimalAddition(): number { should be function jsonDecimalAddition(): number {

Chapter 6, Section 6.4.4 Checksum, page 100

In Listing 6.5: == checksumChar); should be === checksumChar);

Chapter 9, Section 9.1.1 Why not just standard methods?, page 144

In Listing 9.2:

CreateEmailDraft(CreateEmailDraftRequest req): EmailDraft; should be CreateEmailDraft(req: CreateEmailDraftRequest): EmailDraft;

CreateEmail(CreateEmailRequest req): Email; should be CreateEmail(req: CreateEmailRequest): Email;

Chapter 9, Section 9.2 Overview, page 146

In Listing 9.3: LaunchRocket(LaunchRocketRequest req): Rocket; should be LaunchRocket(req: LaunchRocketRequest): Rocket;

Chapter 13, Section 13.3.2 Data integrity, page 203

In Listing 13.3:

author = CreateAuthor({ name: "Michelle Obama" }); should be let author = CreateAuthor({ name: "Michelle Obama" });

book = CreateBook({ should be let book = CreateBook({

Chapter 13, Section 13.3.3 Value vs. reference, page 204

In Listing 13.4:

book = GetBook({ should be let book = GetBook({

authorName = GetAuthor({ id: book.authorId }).name; should be let authorName = GetAuthor({ id: book.authorId }).name;

Chapter 13, Section 13.3.3 Value vs. reference, page 205

In Listing 13.6:

author = CreateAuthor({ name: "Michelle Robinson" }); should be let author = CreateAuthor({ name: "Michelle Robinson" });

book = CreateBook({ should be let book = CreateBook({

Chapter 24, Section 24.2.2 Defining backward compatibility, page 343-4

In Listing 24.3: const chatRoom = ChatRoom.get(1234); should be const chatRoom = GetChatRoom(1234);

In Listing 24.4: const chatRoom = ChatRoom.get(1234); should be const chatRoom = GetChatRoom(1234);

Chapter 25, Section 25.3.1 Deleted designation, page 360

In Listing 25.2:

Code line 2: assert chatRoom.deleted == false; should be assert(chatRoom.deleted === false);

Last code line: assert chatRoom.deleted == false; should be assert(chatRoom.deleted === false);

Chapter 25, Section 25.3.2 Modifying standard methods, page 363

In Listing 25.4: softDeletedChatRooms = ListChatRooms({ should be let softDeletedChatRooms = ListChatRooms({

Chapter 28, Section 28.3.3 Retrieving specific revisions, page 397

In Listing 28.4: assert(GetResource({ id: id }).id == id); should be assert(GetResource({ id: id }).id === id);