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

📐 Commonスキーマ

Commonスキーマは、ページネーション、標準レスポンス、監査、ファイル、連絡先データの再利用可能なJSONスキーマ定義とOpenAPIパラメータを提供します。アドレス固有のスキーマはAddressスキーマで文書化されています。

目録

エクスポートリクエスト場所契約
addressN/Aオプションの文字列住所行の配列。
postalCodeN/Aオプションの文字列郵便番号。
prefectureN/Aオプションの文字列またはnull都道府県。
cityN/Aオプションの文字列市区町村。
countryN/Aオプションの文字列国名。
addressJPSchemaN/Aオプションの日本語住所コンポーネント。
partialPostalCodeQueryParameterクエリ必須の部分または完全な日本郵便番号。
findAddressSchemaクエリ検索リクエストスキーマ。
arrayOfStringsSchemaN/A項目が文字列である必要がある配列。
paginationQueryParametersSchemaクエリオプションの制限付きpagelimitパラメータ。
auditSchemaN/Aアクターメタデータを含むアクションとアクターを持つ監査レコード。
paginationSchemaN/Aページネーションレスポンスメタデータ。
errorSchemaN/A標準エラーレスポンス。
successSchemaN/A標準成功レスポンス。
fileSchemaN/Aアップロードされたファイルのメタデータ。
addressSchemaN/A米国郵便番号形式の必須構造化住所。
contactSchemaN/A必須emailを含む連絡先情報。

詳細

address

定義

追加プロパティなしのオブジェクトで、1つのオプションaddressプロパティを持っています。存在する場合、addressは文字列のみを含む配列である必要があります。

完全なソースを表示
export const address: SchemaDefinition = {
$schema: 'http://json-schema.org/draft-07/schema#',
additionalProperties: false,
properties: {address: {items: {type: 'string'}, type: 'array'}},
type: 'object',
};

postalCode

定義

追加プロパティなしのオブジェクトで、オプションの文字列postalCodeを持っています。郵便番号パターンを強制しません。

完全なソースを表示
export const postalCode: SchemaDefinition = {
$schema: 'http://json-schema.org/draft-07/schema#',
additionalProperties: false,
properties: {postalCode: {type: 'string'}},
type: 'object',
};

prefecture

定義

追加プロパティなしのオブジェクトで、値が文字列またはnullのオプションprefectureを持っています。

完全なソースを表示
export const prefecture: SchemaDefinition = {
$schema: 'http://json-schema.org/draft-07/schema#',
additionalProperties: false,
properties: {
prefecture: {type: ['string', 'null']},
},
type: 'object',
};

city

定義

追加プロパティなしのオブジェクトで、オプションの文字列cityを持っています。

完全なソースを表示
export const city: SchemaDefinition = {
$schema: 'http://json-schema.org/draft-07/schema#',
additionalProperties: false,
properties: {
city: {type: 'string'},
},
type: 'object',
};

country

定義

追加プロパティなしのオブジェクトで、オプションの文字列countryを持っています。

完全なソースを表示
export const country: SchemaDefinition = {
$schema: 'http://json-schema.org/draft-07/schema#',
additionalProperties: false,
properties: {
country: {type: 'string'},
},
type: 'object',
};

addressJPSchema

定義

日本語住所データの厳格なオブジェクト。citycountrypostalCodeprefecturestreetはオプションの文字列です;定義にrequired配列はありません。

完全なソースを表示
export const addressJPSchema: SchemaDefinition = {
$schema: 'http://json-schema.org/draft-07/schema#',
additionalProperties: false,
properties: {
city: {type: 'string'},
country: {type: 'string'},
postalCode: {type: 'string'},
prefecture: {type: 'string'},
street: {type: 'string'},
},
type: 'object',
};

partialPostalCodeQueryParameter

定義

postalCodeという名前の必須クエリパラメータ。文字列パターンは3桁の数字、オプションのハイフン、0〜4桁の追加数字を受け入れます。したがって、部分と完全な日本郵便番号の両方が有効です。

完全なソースを表示
export const partialPostalCodeQueryParameter: OpenAPIParameter = {
in: 'query',
name: 'postalCode',
required: true,
schema: {
pattern: '^\\d{3}-?\\d{0,4}$',
type: 'string',
},
};

findAddressSchema

定義

partialPostalCodeQueryParameterのみを含むパラメータリストを持つwithSchema合成。カスタム住所検索合成によって使用されるクエリ契約を検証します。

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

arrayOfStringsSchema

定義

項目が文字列である必要があるDraft 7配列定義。長さまたは一意性の制約はありません。

完全なソースを表示
export const arrayOfStringsSchema: SchemaDefinition = {
$schema: 'http://json-schema.org/draft-07/schema#',
items: {type: 'string'},
type: 'array',
};

paginationQueryParametersSchema

定義

2つのオプションの整数クエリパラメータ:page1から1000まで、limit1から50まで範囲指定します。ドメインスキーマはこれを独自のOpenAPIパラメータリストに展開し、Chatスキーマも含みます。

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

auditSchema

定義

UUID形式のidentity_iduser_idを要求し、文字列のentity_typecreate/update/deleteのアクション、日付時刻のcreated_atを必要とする監査レコード。オプションのchangesは任意のプロパティを受け入れます。

完全なソースを表示
export const auditSchema = withSchema({
$schema: 'http://json-schema.org/draft-07/schema#',
properties: {
action: {enum: ['create', 'update', 'delete'], type: 'string'},
changes: {additionalProperties: true, type: 'object'},
created_at: {format: 'date-time', type: 'string'},
entity_id: {format: 'uuid', type: 'string'},
entity_type: {type: 'string'},
id: {format: 'uuid', type: 'string'},
user_id: {format: 'uuid', type: 'string'},
},
required: ['id', 'entity_type', 'entity_id', 'action', 'user_id', 'created_at'],
type: 'object',
});

paginationSchema

定義

数値のpagelimittotaltotal_pagesを必要とするページネーションメタデータオブジェクト。pageとlimitの最小値は1;totalの最小値は0です。

完全なソースを表示
export const paginationSchema = withSchema({
$schema: 'http://json-schema.org/draft-07/schema#',
properties: {
limit: {minimum: 1, type: 'number'},
page: {minimum: 1, type: 'number'},
total: {minimum: 0, type: 'number'},
total_pages: {minimum: 0, type: 'number'},
},
required: ['page', 'limit', 'total', 'total_pages'],
type: 'object',
});

errorSchema

定義

文字列のcodemessageを必要とするエラーオブジェクト。オプションのdetailsは任意のプロパティを受け入れるオブジェクトです。

完全なソースを表示
export const errorSchema = withSchema({
$schema: 'http://json-schema.org/draft-07/schema#',
properties: {
code: {type: 'string'},
details: {additionalProperties: true, type: 'object'},
message: {type: 'string'},
},
required: ['code', 'message'],
type: 'object',
});

successSchema

定義

文字列のmessageを必要とする成功オブジェクト。オプションのdataは任意のプロパティを受け入れるオブジェクトです。

完全なソースを表示
export const successSchema = withSchema({
$schema: 'http://json-schema.org/draft-07/schema#',
properties: {
data: {additionalProperties: true, type: 'object'},
message: {type: 'string'},
},
required: ['message'],
type: 'object',
});

fileSchema

定義

UUIDのid、文字列のfilenamemime_type、非負の数値のsize、URIのurl、日付時刻のcreated_atを必要とするファイルメタデータ。

完全なソースを表示
export const fileSchema = withSchema({
$schema: 'http://json-schema.org/draft-07/schema#',
properties: {
created_at: {format: 'date-time', type: 'string'},
filename: {type: 'string'},
id: {format: 'uuid', type: 'string'},
mime_type: {type: 'string'},
size: {minimum: 0, type: 'number'},
url: {format: 'uri', type: 'string'},
},
required: ['id', 'filename', 'mime_type', 'size', 'url', 'created_at'],
type: 'object',
});

addressSchema

定義

streetcitystatecountrypostal_codeを必要とする構造化住所。すべてのフィールドは文字列で、postal_codeはオプションの4桁拡張子を持つ5桁の米 digit を受け入れます。

完全なソースを表示
export const addressSchema = withSchema({
$schema: 'http://json-schema.org/draft-07/schema#',
properties: {
city: {type: 'string'},
country: {type: 'string'},
postal_code: {pattern: '^[0-9]{5}(-[0-9]{4})?$', type: 'string'},
state: {type: 'string'},
street: {type: 'string'},
},
required: ['street', 'city', 'state', 'country', 'postal_code'],
type: 'object',
});

contactSchema

定義

フォーマット検証済みemailを必要とする連絡先オブジェクト。オプションのphoneは文字列で、オプションのaddressは任意のプロパティを持つオブジェクトを受け入れます。

完全なソースを表示
export const contactSchema = withSchema({
$schema: 'http://json-schema.org/draft-07/schema#',
properties: {
address: {additionalProperties: true, type: 'object'},
email: {format: 'email', type: 'string'},
phone: {type: 'string'},
},
required: ['email'],
type: 'object',
});