メインコンテンツまでスキップ
バージョン: 0.14.0 (最新)

📐 カテゴリスキーマ

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

インベントリ

エクスポートリクエスト場所契約
categorySchemaN/Aオプションの descriptionnameparentstatus 文字列;追加プロパティを拒否。
createCategorySchemaボディ必須 namedescriptionstatus を持つベースオブジェクト。
updateCategorySchemaパス、ボディcategoryId に加えてオプションの descriptionnameparent
getCategorySchemaパス必須文字列 categoryId
deleteCategorySchemaパス必須文字列 categoryId
enableCategorySchemaパス必須文字列 categoryId
disableCategorySchemaパス必須文字列 categoryId
findCategoriesSchemaクエリオプションのカテゴリフィルターと pagelimit
共有ソースコンテキストを表示
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

定義

文字列 categoryIdapplication/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

定義

すべてのフィルターはオプションの文字列クエリパラメータです。共有ページネーションパラメータを展開します:pagelimit はそれぞれ 1 から 10001 から 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,
],
});