Most end points you write will provide some type of output back to the user. The metadata around output entity definitions is very similar to input entity definitions. Output entity definitions are flat structures that cannot contain complex types like other objects. The framework always takes the last piece output returned by the business logic of the end point and maps it into your output entity definition. This is a core feature of the framework. Mapping business logic output to output entity objects is handled by implementations of Endpoints.IOutputMapper
. Out of the box, we support mapping DataTables and GEs into the output for an end pointendpoint.
The output entity definition can have the following properties:
Info | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| |||||||||||||||
TODO double check the input entity definition fields against the interface, I think im missing some items.
|
Info | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||
The fields field's property on the output entity definition should be an object value. Each property on the object should be the expected output field name. That property's value should be an object with the following properties:
|
...
Code Block | ||
---|---|---|
| ||
{ "endpoints": { "ExamplesGetSingleProduct": { "outputEntityDefinition": { "name": "ExampleProductOutput", "fields": { "id": { "type": "long" }, "name": { "type": "string" }, "description": { "type": "string", "description": "A plain text description of the product." }, "hasComplexPricing": { "type": "boolean", "description": "If true, this indicates you must add the product to the cart in order to get an accurate price." }, "defaultPrice": { "type": "decimal" } } //remaining metadata omitted } } } |
If our end point endpoint was to get a collection of products, such as GET /examples/products/
, we could define the output this way instead:
...
Often you will want to define a collection based end point endpoint like GET /examples/products
and a singular resource end point endpoint like GET /examples/products/{productId
}. It is possible to avoid duplicating most of the output entity definition metadata using references.
...