192
CHAPTER 6 | Tackle Business Complexity in a Microservice with DDD and CQRS Patterns
o.[OrderDate]
as
[date],os.[Name]
as
[status],
SUM
(oi.
units
*oi.
unitprice
)
as
total
FROM [ordering].[Orders] o
LEFT JOIN[ordering].[orderitems] oi ON o.
Id
= oi.
orderid
LEFT JOIN[ordering].[orderstatus] os on o.
OrderStatusId
= os.
Id
GROUP BY o.[Id], o.[OrderDate], os.[Name]
ORDER BY o.[Id]
");
}
}
}
Describe response types of Web APIs
Developers consuming web APIs and microservices are most concerned with
what is returned
—
specifically response types and error codes (if not standard). The response types
are handled in the
XML comments and data annotations.
Without proper documentation in the Swagger UI, the consumer lacks
knowledge of what types are
being returned or what HTTP codes can be returned. That problem is fixed by adding the
Microsoft.AspNetCore.Mvc.ProducesResponseTypeAttribute
, so Swashbuckle can generate richer
information about the API
return model and values, as shown in the following code:
namespace
Microsoft.
eShopOnContainers
.
Services
.
Ordering
.
API
.
Controllers
{
[
Route
(
"api/v1/[controller]"
)]
[Authorize]
Dostları ilə paylaş: