📐 Location schemas
Location schemas validate strict location bodies, location ID paths, and public-list pagination.
Inventory
| Export | Request location | Contract |
|---|---|---|
locationSchema | N/A | Strict reusable base object. |
createLocationSchema | Body | Required strict creation body. |
getLocationSchema | Path | Required location ID. |
updateLocationSchema | Path, body | Required ID and strict partial body. |
deleteLocationSchema | Path | Required location ID. |
findLocationsSchema | Query | Shared pagination only. |
Shared path-parameter definition
const locationIdPathParameter: OpenAPIParameter = {
in: 'path',
name: 'locationId',
required: true,
schema: {
type: 'string',
},
};
findLocationsSchema is the only Location schema that spreads the shared paginationQueryParametersSchema.
Shared pagination-query definition
export const paginationQueryParametersSchema: OpenAPIParameter[] = [
{
in: 'query',
name: 'page',
required: false,
schema: {
maximum: 1000,
minimum: 1,
type: 'integer',
},
},
{
in: 'query',
name: 'limit',
required: false,
schema: {
maximum: 50,
minimum: 1,
type: 'integer',
},
},
];
Details
locationSchema
Definition
Reusable strict base input object (additionalProperties: false). Creation adds hierarchy and base-entity fields to the stored entity. createLocationSchema and updateLocationSchema spread this definition; routes and features do not compose it directly.
| Location | Field | Type | Required | Constraints |
|---|---|---|---|---|
| N/A | code | string | No | Location code. |
| N/A | name | string | No | Location name. |
| N/A | type | string | No | Location type. |
View complete source
export const locationSchema: SchemaDefinition = {
$schema: 'http://json-schema.org/draft-07/schema#',
additionalProperties: false,
properties: {
code: {type: 'string'},
name: {type: 'string'},
type: {type: 'string'},
},
type: 'object',
};
createLocationSchema
Definition
Required OpenAPI application/json body that spreads locationSchema, preserves strictness, adds parentId, and requires the three base fields.Used by route: createLocationRoute.Used by feature: createLocationFeature.
| Location | Field | Type | Required | Constraints |
|---|---|---|---|---|
| Body | code | string | Yes | application/json; Location code. |
| Body | name | string | Yes | application/json; Location name. |
| Body | type | string | Yes | application/json; Location type. |
| Body | parentId | string | No | application/json; Existing parent ID when supplied. |
View complete source
export const createLocationSchema = withSchema({
requestBody: {
content: {
'application/json': {
schema: {
...locationSchema,
properties: {
...locationSchema.properties,
parentId: {type: 'string'},
},
required: ['name', 'code', 'type'],
},
},
},
required: true,
},
});
getLocationSchema
Definition
Validates the location path ID.Used by route: getLocationRoute.Used by feature: getLocationFeature.
| Location | Field | Type | Required | Constraints |
|---|---|---|---|---|
| Path | locationId | string | Yes | No format or pattern restriction. |
View complete source
export const getLocationSchema = withSchema({
parameters: [{...locationIdPathParameter}],
});
updateLocationSchema
Definition
Requires the path ID and an application/json body. All base fields are optional (required: []), so {} is schema-valid; updates do not allow parentId.Used by route: updateLocationRoute.Used by feature: updateLocationFeature.
| Location | Field | Type | Required | Constraints |
|---|---|---|---|---|
| Path | locationId | string | Yes | No format or pattern restriction. |
| Body | code | string | No | application/json; Strict base field. |
| Body | name | string | No | application/json; Strict base field. |
| Body | type | string | No | application/json; Strict base field. |
View complete source
export const updateLocationSchema = withSchema({
parameters: [{...locationIdPathParameter}],
requestBody: {
content: {
'application/json': {
schema: {
...locationSchema,
required: [],
},
},
},
required: true,
},
});
deleteLocationSchema
Definition
Validates the location path ID.Used by route: deleteLocationRoute.Used by feature: deleteLocationFeature.
| Location | Field | Type | Required | Constraints |
|---|---|---|---|---|
| Path | locationId | string | Yes | No format or pattern restriction. |
View complete source
export const deleteLocationSchema = withSchema({
parameters: [{...locationIdPathParameter}],
});
findLocationsSchema
Definition
Spreads the shared pagination query parameters; defines no location filters.Used by route: findLocationsRoute.Used by feature: findLocationsFeature.
| Location | Field | Type | Required | Constraints |
|---|---|---|---|---|
| Query | page | integer | No | 1–1000. |
| Query | limit | integer | No | 1–50. |
View complete source
export const findLocationsSchema = withSchema({
parameters: [...paginationQueryParametersSchema],
});