c# - 无效的 Swagger 安全定义

标签 c# swagger swashbuckle

有人可以帮我定义 swagger 吗? 它由 swashbuckle (C#) 创建,但安全定义部分有问题

`"securityDefinitions": {
"oauth2": {
"type":"oauth2",
"flow":"implicit",
"authorizationUrl":"https://myserver/core/connect/authorize",
"tokenUrl":"https://myserver/core/connect/token",
"scopes":{ 
"scopeOne":"Allows access to the service",
"scopeTwo":"Allows access to the service"
}
},
"apiKey":{
"name":"ApiKey",
"in":"header",
"type":"apiKey"
}
}`

验证错误是:

Error: Swagger schema validation failed. Data does not match any schemas from 'oneOf' at #/securityDefinitions/oauth2

Additional properties not allowed: scopes,tokenUrl,authorizationUrl,flow at #/securityDefinitions/oauth2

Missing required property: in at #/securityDefinitions/oauth2

Additional properties not allowed: tokenUrl at #/securityDefinitions/oauth2

Additional properties not allowed: authorizationUrl at #/securityDefinitions/oauth2

Additional properties not allowed: authorizationUrl at #/securityDefinitions/oauth2

No enum match for: implicit at #/securityDefinitions/oauth2/flow

最佳答案

tokenUrl 似乎是一个无效参数..

关于c# - 无效的 Swagger 安全定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42439849/

相关文章:

php - 如何将 ref 用于示例 Swagger?

swagger - 无法在 Swagger 中注入(inject) Javascript

swagger - Swashbuckle ASP.NET Core 消费 application/x-www-form-urlencoded

c# - 文本框以更好的方式删除前导空格和尾随空格以及空行

C# - 向下舍入到最接近的整数

asp.net-core - 如何在 ASP.NET Core 3 和 Swashbuckle 5 中为问题详细信息编写 ISchemaFilter?

java - Swagger 阅读器抛出 java.lang.NoSuchMethodError

asp.net-core - 如何使用 Swashbuckle.AspNetCore v5.0.0-rc2 记录 API key 身份验证

c# - 如何在 winform 中显示 DataGridViewComboBoxCell 值的设置默认值?

c# - 无论属性值如何,WPF 动画都会触发