Skip to main content
Version: 0.14.0 (Latest)

📐 Category schemas

Category schemas validate reusable category data and each Category route's path, body, or query inputs.

Inventory

ExportRequest locationContract
categorySchemaN/AOptional description, name, parent, and status strings; rejects additional properties.
createCategorySchemaBodyBase object with required name, description, and status.
updateCategorySchemaPath, bodycategoryId plus optional description, name, and parent.
getCategorySchemaPathRequired string categoryId.
deleteCategorySchemaPathRequired string categoryId.
enableCategorySchemaPathRequired string categoryId.
disableCategorySchemaPathRequired string categoryId.
findCategoriesSchemaQueryOptional category filters plus page and limit.
View shared source context
const categoryIdPathParameter: OpenAPIParameter = {
in: 'path',
name: 'categoryId',
required: true,
schema: {
type: 'string',
},
};

Details

categorySchema

Definition

Reusable stored/request shape. It accepts no extra properties; creation spreads this shape, while update has a narrower inline body shape.

LocationFieldTypeRequiredConstraints
N/AdescriptionstringNo
N/AnamestringNo
N/AparentstringNo
N/AstatusstringNo

Used by route: indirectly createCategoryRoute. Used by feature: indirectly createCategoryFeature.

View complete source
export const categorySchema: SchemaDefinition = {
$schema: 'http://json-schema.org/draft-07/schema#',
additionalProperties: false,
properties: {
description: { type: 'string' },
name: { type: 'string' },
parent: { type: 'string' },
status: { type: 'string' },
},
type: 'object',
};

createCategorySchema

Definition

Requires an application/json body. It spreads categorySchema, so additional properties are rejected; parent is optional.

LocationFieldTypeRequiredConstraints
BodydescriptionstringYesapplication/json
BodynamestringYesapplication/json
BodyparentstringNoapplication/json
BodystatusstringYesapplication/json

Used by route: createCategoryRoute. Used by feature: createCategoryFeature.

View complete source
export const createCategorySchema = withSchema({
requestBody: {
content: {
'application/json': {
schema: {
...categorySchema,
required: ['name', 'description', 'status'],
},
},
},
required: true,
},
});

updateCategorySchema

Definition

Requires a string categoryId and an application/json body. The body itself is required, but every permitted field is optional; status is not accepted and is changed through the status routes.

LocationFieldTypeRequiredConstraints
PathcategoryIdstringYes
BodydescriptionstringNoapplication/json; no additional properties
BodynamestringNoapplication/json; no additional properties
BodyparentstringNoapplication/json; no additional properties

Used by route: updateCategoryRoute. Used by feature: editCategoryFeatures.

View complete source
export const updateCategorySchema = withSchema({
parameters: [{ ...categoryIdPathParameter }],
requestBody: {
content: {
'application/json': {
schema: {
additionalProperties: false,
properties: {
description: { type: 'string' },
name: { type: 'string' },
parent: { type: 'string' },
},
required: [],
type: 'object',
},
},
},
required: true,
},
});

getCategorySchema

Definition

Requires the shared string categoryId path parameter.

LocationFieldTypeRequiredConstraints
PathcategoryIdstringYes

Used by route: getCategoryRoute. Used by feature: getCategoryFeatures.

View complete source
export const getCategorySchema = withSchema({
parameters: [{ ...categoryIdPathParameter }],
});

deleteCategorySchema

Definition

Requires the shared string categoryId path parameter; it has no request body.

LocationFieldTypeRequiredConstraints
PathcategoryIdstringYes

Used by route: deleteCategoryRoute. Used by feature: deleteCategoryFeatures.

View complete source
export const deleteCategorySchema = withSchema({
parameters: [{ ...categoryIdPathParameter }],
});

enableCategorySchema

Definition

Requires the shared string categoryId path parameter; it has no request body.

LocationFieldTypeRequiredConstraints
PathcategoryIdstringYes

Used by route: enableCategoryRoute. Used by feature: enableCategoryStatusFeatures.

View complete source
export const enableCategorySchema = withSchema({
parameters: [{ ...categoryIdPathParameter }],
});

disableCategorySchema

Definition

Requires the shared string categoryId path parameter; it has no request body.

LocationFieldTypeRequiredConstraints
PathcategoryIdstringYes

Used by route: disableCategoryRoute. Used by feature: disableCategoryStatusFeatures.

View complete source
export const disableCategorySchema = withSchema({
parameters: [{ ...categoryIdPathParameter }],
});

findCategoriesSchema

Definition

All filters are optional string query parameters. It spreads the shared pagination parameters: page and limit are optional integers from 1 through 1000 and 1 through 50, respectively. At runtime, withPagination defaults them to page 1 and limit 10, removes both fields from the MongoDB filter, and the normalizer preserves the resulting metadata.

LocationFieldTypeRequiredConstraints
QuerydescriptionstringNo
QuerynamestringNo
QueryparentstringNo
QuerystatusstringNo
QuerypageintegerNominimum 1, maximum 1000; runtime default 1
QuerylimitintegerNominimum 1, maximum 50; runtime default 10

Used by route: findCategoriesRoute. Used by feature: findCategoriesFeatures.

View complete source
export const findCategoriesSchema = withSchema({
parameters: [
{
in: 'query',
name: 'description',
required: false,
schema: {
type: 'string',
},
},
{
in: 'query',
name: 'name',
required: false,
schema: {
type: 'string',
},
},
{
in: 'query',
name: 'parent',
required: false,
schema: {
type: 'string',
},
},
{
in: 'query',
name: 'status',
required: false,
schema: {
type: 'string',
},
},
...paginationQueryParametersSchema,
],
});