メインコンテンツまでスキップ
バージョン: 0.13.0 (Previous)

📐 カテゴリスキーマ

カテゴリスキーマは再利用可能なカテゴリデータを検証し、各カテゴリルートのパス、ボディ、またはクエリ入力を検証します。

インベントリ​

エクスポートリクエスト場所契約
categorySchemaN/Aオプションの description、name、parent、status 文字列;追加プロパティを拒否。
createCategorySchemaボディ必須 name、description、status を持つベースオブジェクト。
updateCategorySchemaパス、ボディcategoryId に加えてオプションの description、name、parent。
getCategorySchemaパス必須文字列 categoryId。
deleteCategorySchemaパス必須文字列 categoryId。
enableCategorySchemaパス必須文字列 categoryId。
disableCategorySchemaパス必須文字列 categoryId。
findCategoriesSchemaクエリオプションのカテゴリフィルターと page、limit。
共有ソースコンテキストを表示
const categoryIdPathParameter: OpenAPIParameter = {
in: 'path',
name: 'categoryId',
required: true,
schema: {
type: 'string',
},
};

詳細​

categorySchema​

定義

再利用可能な保存/リクエスト形状。追加プロパティを受け付けません;作成はこの形状を展開し、更新は narrower なインラインボディ形状を持ちます。

場所フィールド型必須制約
N/Adescriptionstringいいえ—
N/Anamestringいいえ—
N/Aparentstringいいえ—
N/Astatusstringいいえ—

ルートで使用: 間接的 createCategoryRoute。フィーチャーで使用: 間接的 createCategoryFeature。

完全なソースを表示
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​

定義

application/json ボディを要求します。categorySchema を展開するため、追加プロパティは拒否されます;parent はオプションです。

場所フィールド型必須制約
ボディdescriptionstringはいapplication/json
ボディnamestringはいapplication/json
ボディparentstringいいえapplication/json
ボディstatusstringはいapplication/json

ルートで使用: createCategoryRoute。フィーチャーで使用: createCategoryFeature。

完全なソースを表示
export const createCategorySchema = withSchema({
requestBody: {
content: {
'application/json': {
schema: {
...categorySchema,
required: ['name', 'description', 'status'],
},
},
},
required: true,
},
});

updateCategorySchema​

定義

文字列 categoryId と application/json ボディを要求します。ボディ自体は必須ですが、許可されたすべてのフィールドはオプションです;status は受け付けられず、ステータスルートを通じて変更されます。

場所フィールド型必須制約
パスcategoryIdstringはい—
ボディdescriptionstringいいえapplication/json;追加プロパティなし
ボディnamestringいいえapplication/json;追加プロパティなし
ボディparentstringいいえapplication/json;追加プロパティなし

ルートで使用: updateCategoryRoute。フィーチャーで使用: editCategoryFeatures。

完全なソースを表示
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​

定義

共有文字列 categoryId パスパラメータを要求します。

場所フィールド型必須制約
パスcategoryIdstringはい—

ルートで使用: getCategoryRoute。フィーチャーで使用: getCategoryFeatures。

完全なソースを表示
export const getCategorySchema = withSchema({
parameters: [{ ...categoryIdPathParameter }],
});

deleteCategorySchema​

定義

共有文字列 categoryId パスパラメータを要求します;リクエストボディはありません。

場所フィールド型必須制約
パスcategoryIdstringはい—

ルートで使用: deleteCategoryRoute。フィーチャーで使用: deleteCategoryFeatures。

完全なソースを表示
export const deleteCategorySchema = withSchema({
parameters: [{ ...categoryIdPathParameter }],
});

enableCategorySchema​

定義

共有文字列 categoryId パスパラメータを要求します;リクエストボディはありません。

場所フィールド型必須制約
パスcategoryIdstringはい—

ルートで使用: enableCategoryRoute。フィーチャーで使用: enableCategoryStatusFeatures。

完全なソースを表示
export const enableCategorySchema = withSchema({
parameters: [{ ...categoryIdPathParameter }],
});

disableCategorySchema​

定義

共有文字列 categoryId パスパラメータを要求します;リクエストボディはありません。

場所フィールド型必須制約
パスcategoryIdstringはい—

ルートで使用: disableCategoryRoute。フィーチャーで使用: disableCategoryStatusFeatures。

完全なソースを表示
export const disableCategorySchema = withSchema({
parameters: [{ ...categoryIdPathParameter }],
});

findCategoriesSchema​

定義

すべてのフィルターはオプションの文字列クエリパラメータです。共有ページネーションパラメータを展開します:page と limit はそれぞれ 1 から 1000、1 から 50 のオプション整数です。実行時、withPagination はこれらをページ 1 とリミット 10 にデフォルトし、MongoDB フィルターから両方のフィールドを削除し、ノーマライザーは結果のメタデータを保持します。

場所フィールド型必須制約
クエリdescriptionstringいいえ—
クエリnamestringいいえ—
クエリparentstringいいえ—
クエリstatusstringいいえ—
クエリpageintegerいいえ最小値 1、最大値 1000;実行時デフォルト 1
クエリlimitintegerいいえ最小値 1、最大値 50;実行時デフォルト 10

ルートで使用: findCategoriesRoute。フィーチャーで使用: findCategoriesFeatures。

完全なソースを表示
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,
],
});