メインコンテンツまでスキップ
バージョン: 🚧 Canary

📐 Location schemas

Location schemas validate strict location bodies, location ID paths, and public-list pagination.

Inventory​

ExportRequest locationContract
locationSchemaN/AStrict reusable base object.
createLocationSchemaBodyRequired strict creation body.
getLocationSchemaPathRequired location ID.
updateLocationSchemaPath, bodyRequired ID and strict partial body.
deleteLocationSchemaPathRequired location ID.
findLocationsSchemaQueryShared 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.

LocationFieldTypeRequiredConstraints
N/AcodestringNoLocation code.
N/AnamestringNoLocation name.
N/AtypestringNoLocation 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.

LocationFieldTypeRequiredConstraints
BodycodestringYesapplication/json; Location code.
BodynamestringYesapplication/json; Location name.
BodytypestringYesapplication/json; Location type.
BodyparentIdstringNoapplication/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.

LocationFieldTypeRequiredConstraints
PathlocationIdstringYesNo 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.

LocationFieldTypeRequiredConstraints
PathlocationIdstringYesNo format or pattern restriction.
BodycodestringNoapplication/json; Strict base field.
BodynamestringNoapplication/json; Strict base field.
BodytypestringNoapplication/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.

LocationFieldTypeRequiredConstraints
PathlocationIdstringYesNo 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.

LocationFieldTypeRequiredConstraints
QuerypageintegerNo1–1000.
QuerylimitintegerNo1–50.
View complete source
export const findLocationsSchema = withSchema({
parameters: [...paginationQueryParametersSchema],
});