本文整理匯總了TypeScript中klay-core.defaultModelContext.string方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript defaultModelContext.string方法的具體用法?TypeScript defaultModelContext.string怎麽用?TypeScript defaultModelContext.string使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類klay-core.defaultModelContext
的用法示例。
在下文中一共展示了defaultModelContext.string方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: buildArraySchema
function buildArraySchema(
model: IModel,
cache?: ISwaggerSchemaCache,
name?: string,
): swagger.Schema {
const children = model.spec.children as IModel
const childrenForArray = children || defaultModelContext.string()
return {
type: 'array',
items: getSchema(childrenForArray, cache, `${name}Item`),
}
}
示例2: async
options,
)
return async (username: string, password: string) => {
const user = (await userExecutor.findOne({where: {[usernameField]: username}})) as any
if (!user) return undefined
const passwordsMatch = await doPasswordsMatch(password, user[passwordField], passwordOptions)
if (!passwordsMatch) return undefined
// TODO: limit returned user fields to just those used by auth grants
return user
}
}
// see https://tools.ietf.org/html/rfc6749#section-4.3.1
export const oauthTokenRequestModel: IModel = defaultModelContext.object().children({
// TODO: handle other grant types
grant_type: defaultModelContext
.string()
.required()
.enum(['password']),
username: defaultModelContext.string().required(),
password: defaultModelContext.string().required(),
})
export const oauthTokenResponseModel: IModel = defaultModelContext.object().children({
access_token: defaultModelContext.string().required(),
token_type: defaultModelContext
.string()
.required()
.enum(['bearer']),
expires_in: defaultModelContext.integer().required(),
})