77 lines
2.3 KiB
Plaintext
77 lines
2.3 KiB
Plaintext
// Licensed to the .NET Foundation under one or more agreements.
|
|
// The .NET Foundation licenses this file to you under the MIT license.
|
|
|
|
/*
|
|
* Copyright (c) 杭州颉创科技有限公司 2025. All rights reserved.
|
|
* This source file is licensed under the MIT License found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
package simcu::simapi.openapi.models
|
|
|
|
/**
|
|
* @brief 表示 OpenAPI 安全方案对象。
|
|
*/
|
|
public class OpenApiSecurityScheme <: IOpenApiSerializable {
|
|
/**
|
|
* @brief 表示安全方案类型(apiKey/http/oauth2/openIdConnect)。
|
|
*/
|
|
public var schemeType: String = "apiKey"
|
|
/**
|
|
* @brief 表示用于安全方案的参数名称(apiKey 时有效)。
|
|
*/
|
|
public var name: ?String = None
|
|
/**
|
|
* @brief 表示 apiKey 参数所在位置(header/query/cookie)。
|
|
*/
|
|
public var location: ?String = None
|
|
/**
|
|
* @brief 表示 HTTP 认证方案名称(http 时有效,如 bearer)。
|
|
*/
|
|
public var scheme: ?String = None
|
|
/**
|
|
* @brief 表示安全方案的描述信息。
|
|
*/
|
|
public var description: ?String = None
|
|
/**
|
|
* @brief 表示 bearer 令牌的格式提示(http+bearer 时有效)。
|
|
*/
|
|
public var bearerFormat: ?String = None
|
|
|
|
/**
|
|
* @brief 创建 OpenAPI 安全方案对象。
|
|
*/
|
|
public init() {
|
|
}
|
|
|
|
/**
|
|
* @brief 按 OpenAPI V3 格式写出当前安全方案对象。
|
|
* @param writer OpenAPI 写入器。
|
|
*/
|
|
public func serializeAsV3(writer: IOpenApiWriter): Unit {
|
|
writer.startObject()
|
|
writer.writeName("type")
|
|
writer.writeValue(schemeType)
|
|
if (let Some(value) <- description) {
|
|
writer.writeName("description")
|
|
writer.writeValue(value)
|
|
}
|
|
if (let Some(value) <- name) {
|
|
writer.writeName("name")
|
|
writer.writeValue(value)
|
|
}
|
|
if (let Some(value) <- location) {
|
|
writer.writeName("in")
|
|
writer.writeValue(value)
|
|
}
|
|
if (let Some(value) <- scheme) {
|
|
writer.writeName("scheme")
|
|
writer.writeValue(value)
|
|
}
|
|
if (let Some(value) <- bearerFormat) {
|
|
writer.writeName("bearerFormat")
|
|
writer.writeValue(value)
|
|
}
|
|
writer.endObject()
|
|
}
|
|
} |