Skip to main content
Version: 0.13.0 (Previous)

📐 Attribute schemas

Attribute schemas define the reusable group shape and the body, path, and query contracts consumed by Attribute routes.

Inventory

ExportRequest locationContract
attributesSchemaN/AOptional name and non-empty items; top-level additional properties are rejected.
createAttributesSchemaBodyname and items required.
updateAttributesSchemaPath, bodyOptional name only; additional properties rejected.
getAttributeSchemaPathString attribute-group ID.
deleteAttributeSchemaPathString attribute-group ID.
findAttributesSchemaQueryString name filter plus shared pagination parameters.
View shared source context
const attributeIdPathParameter: OpenAPIParameter = {
in: 'path',
name: 'attributeId',
required: true,
schema: {
type: 'string',
},
};

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

attributesSchema

Definition

Reusable stored/request shape. The top-level object has additionalProperties: false; its nested items objects do not declare that restriction in source.

LocationFieldTypeRequiredConstraints
N/AnamestringNo
N/AitemsarrayNominItems: 1
ItemkeystringYes
ItemvaluestringYes

Used by feature: N/A — reusable schema.

Used by route: N/A — reused by createAttributesSchema.

Composed by: createAttributesSchema.

View complete source
export const attributesSchema: SchemaDefinition = {
$schema: 'http://json-schema.org/draft-07/schema#',
additionalProperties: false,
properties: {
items: {
items: {
properties: {
key: { type: 'string' },
value: { type: 'string' },
},
required: ['key', 'value'],
type: 'object',
},
minItems: 1,
type: 'array',
},
name: { type: 'string' },
},
type: 'object',
};

createAttributesSchema

Definition

Required JSON body using the reusable shape. name and items are required; top-level additional properties are rejected.

LocationFieldTypeRequiredConstraints
BodynamestringYes
BodyitemsarrayYesAt least one item
Body itemkeystringYes
Body itemvaluestringYes

Used by feature: createAttributeFeature.

Used by route: createAttributeRoute.

View complete source
export const createAttributesSchema = withSchema({
requestBody: {
content: {
'application/json': {
schema: {
...attributesSchema,
required: ['name', 'items'],
},
},
},
required: true,
},
});

updateAttributesSchema

Definition

Requires a string attributeId path parameter and a JSON body. The schema permits {} because it declares no required body field, but updateAttributeGroup rejects an empty body with 400.

LocationFieldTypeRequiredConstraints
PathattributeIdstringYes
BodynamestringNoNo additional body properties

Used by feature: updateAttributeFeature.

Used by route: updateAttributeRoute.

View complete source
export const updateAttributesSchema = withSchema({
parameters: [{ ...attributeIdPathParameter }],
requestBody: {
content: {
'application/json': {
schema: {
$schema: 'http://json-schema.org/draft-07/schema#',
additionalProperties: false,
properties: {
name: { type: 'string' },
},
type: 'object',
},
},
},
required: true,
},
});

getAttributeSchema

Definition

Requires the string attributeId path parameter.

LocationFieldTypeRequiredConstraints
PathattributeIdstringYes

Used by feature: getAttributeFeature.

Used by route: getAttributeRoute.

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

deleteAttributeSchema

Definition

Requires the string attributeId path parameter.

LocationFieldTypeRequiredConstraints
PathattributeIdstringYes

Used by feature: deleteAttributeFeature.

Used by route: deleteAttributeRoute.

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

findAttributesSchema

Definition

Optional query contract. name is an Attribute-specific string filter; pagination fields come from paginationQueryParametersSchema.

LocationFieldTypeRequiredConstraints
QuerynamestringNo
QuerypageintegerNoMinimum 1, maximum 1000
QuerylimitintegerNoMinimum 1, maximum 50

Used by feature: findAttributesFeature.

Used by route: findAttributesRoute.

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