小编Ted*_*ein的帖子

如何在Swagger UI中发送带有请求的自定义标头?

我在API中有一些端点 - /user/login, /products.

在扬鞭UI我张贴email,并password/user/login和我收到的响应token串.

然后,我可以从响应中复制令牌,并希望将其用作Authorization对所有URL的请求中的标头值(如果它存在),并/products作为示例.

我应该在Swagger UI页面上的某处手动创建文本输入,然后将令牌放在那里并以某种方式注入请求或是否有工具以更好的方式管理它?

api authorization swagger swagger-ui

56
推荐指数
6
解决办法
9万
查看次数

在对象属性内重用架构定义

问题:我想重用定义。一次直接进入,一次进入一个物体。以下代码有效,但是来自http://editor.swagger.io/#/的验证器说“无效的响应定义”并指向行“ 200”。

我真的必须两次定义“帐户”吗?还是验证者有问题?

 *     responses:
 *       200: <---- ERROR POINTING HERE
 *         description: Updated account
 *         schema:
 *           type: object
 *           properties:
 *             data:
 *               type: object
 *               properties:
 *                 account:
 *                   schema:
 *                     $ref: '#/definitions/Account'
Run Code Online (Sandbox Code Playgroud)

定义本身:

 "Account" : {
    "type" : "object",
    "required": [
        "id", "username", "lastname", "firstname", "traderid", "customerid", "company", "validated"
    ],
    "properties": {
        "id": {
            "type": "string"
        },
        "username" : {
            "type": "string"
        },
        "lastname" : {
            "type": "string"
        },
        "firstname" : {
            "type": "string" …
Run Code Online (Sandbox Code Playgroud)

swagger swagger-2.0

2
推荐指数
1
解决办法
2360
查看次数

路径项上的Swagger验证错误:"不允许其他属性"

我正在使用https://www.npmjs.com/package/swagger,我正在尝试创建配置.我有swagger.js的这一部分

       "dummy\/{id}\/related_dummies": {
            "get": {
                "tags": [
                    "RelatedDummy"
                ],
                "operationId": "get_by_parentRelatedDummyCollection",
                "produces": [
                    "application\/ld+json",
                    "application\/hal+json",
                    "application\/xml",
                    "text\/xml",
                    "application\/json",
                    "text\/html"
                ],
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "type": "integer"
                    }
                ],
                "summary": "Retrieves the collection of RelatedDummy resources.",
                "responses": {
                    "200": {
                        "description": "RelatedDummy collection response",
                        "schema": {
                            "type": "array",
                            "items": {
                                "$ref": "#\/definitions\/RelatedDummy"
                            }
                        }
                    }
                }
            }
Run Code Online (Sandbox Code Playgroud)

但是,当我运行swagger验证swagger.js时,我不断收到此错误:

Project Errors
--------------
#/paths: Additional properties not allowed: dummy/{id}/related_dummies
Results: 1 errors, 0 warnings
Run Code Online (Sandbox Code Playgroud)

可能是错误的原因是什么?谢谢

symfony swagger

1
推荐指数
1
解决办法
6406
查看次数

标签 统计

swagger ×3

api ×1

authorization ×1

swagger-2.0 ×1

swagger-ui ×1

symfony ×1