精简了openapi相关
This commit is contained in:
1 parent
eed230aab0
commit
06884a920c
73 files changed
+465
-1214
No files matched your search
@@ -0,0 +1,61 @@
|
||||
// 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
|
||||
|
||||
import std.collection.*
|
||||
|
||||
/**
|
||||
* @brief 表示 OpenAPI 安全需求对象。
|
||||
*
|
||||
* 每个实例对应一个安全需求条目,例如 {"Token": []}。
|
||||
*/
|
||||
public class OpenApiSecurityRequirement <: IOpenApiSerializable {
|
||||
private let _requirements = ArrayList<(String, ArrayList<String>)>()
|
||||
|
||||
/**
|
||||
* @brief 创建 OpenAPI 安全需求对象。
|
||||
*/
|
||||
public init() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 添加一个安全方案需求。
|
||||
* @param schemeName 安全方案名称。
|
||||
*/
|
||||
public func addScheme(schemeName: String): Unit {
|
||||
_requirements.add((schemeName, ArrayList<String>()))
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 添加一个带授权范围的安全方案需求。
|
||||
* @param schemeName 安全方案名称。
|
||||
* @param scopes 该方案要求的授权范围集合(OAuth2 场景)。
|
||||
*/
|
||||
public func addScheme(schemeName: String, scopes: ArrayList<String>): Unit {
|
||||
_requirements.add((schemeName, scopes))
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 按 OpenAPI V3 格式写出当前安全需求对象。
|
||||
* @param writer OpenAPI 写入器。
|
||||
*/
|
||||
public func serializeAsV3(writer: IOpenApiWriter): Unit {
|
||||
writer.startObject()
|
||||
for ((schemeName, scopes) in _requirements) {
|
||||
writer.writeName(schemeName)
|
||||
writer.startArray()
|
||||
for (scope in scopes) {
|
||||
writer.writeValue(scope)
|
||||
}
|
||||
writer.endArray()
|
||||
}
|
||||
writer.endObject()
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user