microsoft-graph-api - 如何在 OpenAPI 中指定将用户添加到组?
问题描述
我正在尝试为 MS Flow\Logic Apps 创建一个自定义连接器,该连接器使用一些属于 microsoft graph 的 REST 端点,但在理解如何在 OpenAPI 2.0 规范中记录 API 时遇到了麻烦
质谱文档
https://docs.microsoft.com/en-us/graph/api/group-post-owners?view=graph-rest-1.0#example
说包括
"@odata.id": "https://graph.microsoft.com/v1.0/users/{id}"
作为请求正文的一部分的 $ref 参数
但是如何在 OpenAPI 2.0 规范中记录这一点?
这是我到目前为止所得到的......
'/groups/{team-id}/owners':
post:
tags:
- teams.team
summary: Add a new owner to the team
operationId: teams.AddOwner
consumes:
- application/json
parameters:
- name: team-id
in: path
required: true
type: string
description: Id of the MS team
x-ms-summary: Team Id
x-ms-visibility: important
- name: body
in: body
required: true
schema:
type: object
properties:
userId:
type: string
description: Id of the user to be added as an owner to the team
x-ms-summary: User Id
x-ms-visibility: important
'@odata.id':
default: https://graph.microsoft.com/v1.0/users/{userId}
responses:
'204':
description: Success
default:
$ref: '#/responses/error'
x-ms-docs-operation-type: operation
当我提交上述内容以创建自定义连接器时,出现以下错误
指定的文件与 OpenAPI 2.0 规范不匹配:'JSON 对来自 'oneOf' 的无模式有效。路径'paths./groups/{team-id}/owners.post.parameters[1]'。
编辑
我已将 OpenAPI 更新为如下所示
这意味着我可以导入和使用它……但我必须在工作流程中手动构造 @odata.id 参数的 URL!
"@odata.id": "https://graph.microsoft.com/v1.0/users/{id}"
'/groups/{team-id}/owners/$ref':
post:
tags:
- teams.team
summary: Add a new owner to the team
operationId: teams.AddOwner
consumes:
- application/json
parameters:
- name: team-id
in: path
required: true
type: string
description: Id of the MS team
x-ms-summary: Team Id
x-ms-visibility: important
- name: body
in: body
required: true
schema:
type: object
properties:
'@odata.id':
title: User Id
type: string
x-ms-summary: User Id
x-ms-visibility: important
responses:
'204':
description: Success
default:
$ref: '#/responses/error'
x-ms-docs-operation-type: operation
编辑
我应该如何指定它来获取userId?
如何正确指定 body 参数?
有没有关于如何做到这一点的文档\示例?
任何帮助将非常感激
提前致谢
皮特
解决方案
我发现创建 PowerApps 自定义连接器的最简单方法之一是:
使用 Postman 制作工作请求
从空白构建自定义连接器
在自定义连接器“测试”区域进行测试
然后,如果需要,您可以下载 Swagger 文件。基本上,让 PowerApps 为您构建 Swagger 文件,而不是相反。
这是我喜欢使用的方法的 YouTube 视频。
推荐阅读
- http - 哪个 414 状态行是正确的?
- android - 当键盘向上或向下颤动时重建页面
- javascript - 在laravel中将两个选定的框onchange相加
- angular - 离子角度表单生成器没有获得表单控制值
- html - 为什么我的引导轮播滑块无法移动?
- laravel - Laravel 自动设置与预加载的反比关系
- jquery - 如何使用 Bootstrap 4 将主选项卡重定向到嵌套选项卡?
- class - Kotlin:如何在主函数中调用类属性并打印结果?
- javascript - 返回响应而不是 PHP 中的源代码
- typescript - 如何在 localhost 中打开静态网站,但使用 Vite 生成且不运行服务器?