SmartDocs - Security grant type accessCode is not a valid type for OAuth

Does the SmartDocs Beta work with Swagger 2.0 JSON?

I am trying the SmartDocs beta on dev portal with the following Swagger 2.0 JSON

{
    "swagger": "2.0",
    "info": {
        "version": "2.0.0",
        "title": "company XYZ API",
        "termsOfService": "https://www.company.com/legal",
        "contact": {
            "name": "apiteam@company.com"
        },
        "license": {
            "name": "TBD",
            "url": "https://www.company.com/legal"
        }
    },
    "host": "server.company.com",
    "basePath": "/v2",
    "schemes": [
        "https"
    ],
    "paths": {
        "/res/{res_id}/resx": {
            "get": {
                "description": "Gets a list of all res",
                "operationId": "get_res",
                "security": [
                    {
                        "xxAuthCode": []
                    }
                ],
                "parameters": [
                    {
                        "name": "id",
                        "type": "integer",
                        "description": "ID of res",
                        "in": "path",
                        "required": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "schema": {
                            "type": "array",
                            "$ref": "#/definitions/Res"
                        }
                    }
                }
            }
        }
    },
    "securityDefinitions": {
        "xxAuthCode": {
            "type": "oauth2",
            "flow": "accessCode",
            "authorizationUrl": "https://server.company.com/v2/oauth/authorize",
            "tokenUrl": "https://server.company.com/v2/oauth/token"
        }
    },
    "definitions": {
        "Document": {
          "properties": {
                "id": {
                    "type": "integer"
                },
                "name": {
                    "type": "string",
                    "description": "Name of the Res"
                }
            }
        }
    }
}

I am getting below error in the console logs

>>>>>>>>
POST /v1/o/userid/apimodels/xxApi/revisions?action=import&format=swagger HTTP/1.1
Host: api.enterprise.apigee.com
accept: application/json; charset=utf-8
Content-Type: text/plain; charset=utf-8
User-Agent: DevPortal/15.03.18.00 Guzzle/3.9.3 curl/7.32.0 PHP/5.3.29
Referer: http://dev-userid.devportal.apigee.com/admin/smartdocs/models/xxApi/import
Authorization: Basic [**masked**]
Content-Length: 72
URL=http://dev-userid.devportal.apigee.com/sites/default/files/test.txt
<<<<<<<<
HTTP/1.1 400 Bad Request
Content-Type: application/json
Date: Thu, 09 Apr 2015 14:02:41 GMT
Content-Length: 541
Connection: keep-alive
{
  "code" : "apimodel.InvalidGrantType",
  "message" : "Security grant type accessCode is not a valid type for OAuth. Security - com.apigee.apimodel.repo.persistence.beans.SecurityBean{ securityId=null, name=xxAuthCode, apiRevisionId=null, type=OAUTH2, grantType=accessCode, authorizationUrl=https://server.company.com/v2/oauth/authorize, authorizationVerb=null, accessTokenUrl=https://server.company.com/v2/oauth/token, accessTokenParamName=null, scopes=null, paramName=null, tokenType=null, tokenMap=null, in=null} ",
  "contexts" : [ ]
}
--------
Solved Solved
0 3 552
1 ACCEPTED SOLUTION

Hi @Vineet Bhatia,

We only recently released the first beta support for Swagger 2.0 imports, and this was a known issue with validating the security attributes in our internal representation. Swagger 2.0 is a priority for general availability of SmartDocs, so you can expect it to over the next few releases (standard software-is-a-fickle-beast caveats apply). For now, Swagger 1.2 is safer, but a bunch of good things are coming soon.

Thanks, Marsh

View solution in original post

3 REPLIES 3

I tried with Swagger spec ver 1.2 and I was able to import the swagger json. When will SmartDocs support Swagger ver 2.0?

Hi @Vineet Bhatia,

We only recently released the first beta support for Swagger 2.0 imports, and this was a known issue with validating the security attributes in our internal representation. Swagger 2.0 is a priority for general availability of SmartDocs, so you can expect it to over the next few releases (standard software-is-a-fickle-beast caveats apply). For now, Swagger 1.2 is safer, but a bunch of good things are coming soon.

Thanks, Marsh

Thanks @Marsh Gardiner Looking forward to Swagger 2.0 support in SmartDocs.