📐 Order schemas
Order schemas define the strict stored-order shape and attach request validation to the Order feature routes.
Inventory
| Export | Request location | Contract |
|---|---|---|
orderSchema | N/A | Strict reusable order object. |
createOrderSchema | Body | Required JSON order body. |
updateOrderSchema | Path, body | Order ID plus required JSON body. |
getOrderSchema | Path | Required string order ID. |
deleteOrderSchema | Path | Required string order ID. |
findOrdersSchema | Query | Optional filters plus bounded pagination. |
View shared source context
const orderIdPathParameter: OpenAPIParameter = {
in: 'path',
name: 'orderId',
required: true,
schema: {
type: 'string',
},
};
Details
orderSchema
Definition
The reusable strict JSON Schema shape that createOrderSchema and updateOrderSchema spread. It is not itself attached to a route. Stored documents may also have source-generated base-entity fields and MongoDB _id; _id is not part of this schema and is removed by Order response terminators.
| Location | Field | Type | Required | Constraints |
|---|---|---|---|---|
| Body | currency | string | No | No format or enum. |
| Body | identityId | string | No | UUID format. |
| Body | items | array | No | Each item is the strict nested object below. |
Body / items[] | price | number | Yes | Minimum 0; no additional properties in an item. |
Body / items[] | productId | string | Yes | UUID format. |
Body / items[] | quantity | number | Yes | Minimum 1. |
| Body | organizationId | string | No | UUID format. |
| Body | status | string | No | No enum. |
| Body | subtotal | number | No | Minimum 0. |
| Body | tax | number | No | Minimum 0. |
| Body | total | number | No | Minimum 0. |
The outer object and each items[] object have additionalProperties: false.
Used by route: Indirectly through createOrderRoute and updateOrderRoute. Used by feature: Indirectly through createOrderFeature and updateOrderFeature.View complete source
createOrderSchema
Definition
Validates the required application/json body for createOrderRoute, composed by createOrderFeature. It spreads orderSchema, so the body is strict.
| Location | Field | Type | Required | Constraints |
|---|---|---|---|---|
| Body | identityId | string | Yes | UUID format. |
| Body | items | array | Yes | Strict item objects; each requires UUID productId, number quantity ≥ 1, and number price ≥ 0. |
| Body | total | number | Yes | Minimum 0. |
| Body | currency, organizationId, status, subtotal, tax | As in orderSchema | No | The spread schema defines the exact formats and minimums. |
Used by route: createOrderRoute. Used by feature: createOrderFeature.View complete source
updateOrderSchema
Definition
Validates updateOrderRoute, composed by updateOrderFeature. The JSON body is required but its spread schema has required: []; runtime updateOrder additionally rejects an empty object.
| Location | Field | Type | Required | Constraints |
|---|---|---|---|---|
| Path | orderId | string | Yes | No format or pattern. |
| Body | All orderSchema fields | As in reusable schema | No | application/json; strict outer/nested objects; no body property is schema-required. |
Used by route: updateOrderRoute. Used by feature: updateOrderFeature.View complete source
getOrderSchema
Definition
Validates the path for getOrderRoute, composed by getOrderFeature. It has no query or request body.
| Location | Field | Type | Required | Constraints |
|---|---|---|---|---|
| Path | orderId | string | Yes | No format or pattern. |
Used by route: getOrderRoute. Used by feature: getOrderFeature.View complete source
deleteOrderSchema
Definition
Validates the path for deleteOrderRoute, composed by deleteOrderFeature. It has no query or request body.
| Location | Field | Type | Required | Constraints |
|---|---|---|---|---|
| Path | orderId | string | Yes | No format or pattern. |
Used by route: deleteOrderRoute. Used by feature: deleteOrderFeature.View complete source
findOrdersSchema
Definition
Validates query inputs for findOrdersRoute, composed by findOrdersFeature. It has no path parameter or body. withPagination consumes page and limit before findOrders receives the remaining query as its Mongo filter.
| Location | Field | Type | Required | Constraints |
|---|---|---|---|---|
| Query | currency | string | No | No format or enum. |
| Query | organizationId | string | No | No format or pattern. |
| Query | status | string | No | No enum. |
| Query | subtotal | number | No | Minimum 0. |
| Query | tax | number | No | Minimum 0. |
| Query | total | number | No | Minimum 0. |
| Query | identityId | string | No | No format or pattern. |
| Query | page | integer | No | Shared pagination; minimum 1, maximum 1000. |
| Query | limit | integer | No | Shared pagination; minimum 1, maximum 50. |
Used by route: findOrdersRoute. Used by feature: findOrdersFeature.View complete source