Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SwaggerOperation resource_list is missing path. #103

Open
Galaf opened this issue Jul 7, 2015 · 1 comment
Open

SwaggerOperation resource_list is missing path. #103

Galaf opened this issue Jul 7, 2015 · 1 comment

Comments

@Galaf
Copy link

Galaf commented Jul 7, 2015

Hello,

First of all, I'm using:

django-tastypie-swagger (0.1.4)
django-tastypie (0.12.1)

Up until now, I didn't have any problem with this package, and it used to work perfectly but this morning, when I fired it, I had some problems.

My resources don't have paths and as such, Swagger UI is just breaking.

Here is just a small excerpt of what is in the console:

["SwaggerOperation alert_list is missing path."]
swagger.js:274 Uncaught SwaggerOperation alert_list is missing path.
(index):67 Unable to Load SwaggerUI
(index):68 ["SwaggerOperation client_list is missing path."]
swagger.js:274 Uncaught SwaggerOperation client_list is missing path.
(index):67 Unable to Load SwaggerUI
(index):68 ["SwaggerOperation connection_list is missing path."]
swagger.js:274 Uncaught SwaggerOperation connection_list is missing path.

Indeed, when I look at the resource, the path attribute is just an empty string:

{
  "resource": "client",
  "swaggerVersion": "1.2",
  "apis": [{
    "operations": [{
      "parameters": [{
        "dataType": "int",
        "paramType": "query",
        "required": false,
        "name": "limit",
        "description": "Specify the number of element to display per page."
      }, {
        "dataType": "int",
        "paramType": "query",
        "required": false,
        "name": "offset",
        "description": "Specify the offset to start displaying element on a page."
      }, {
        "dataType": "integer",
        "paramType": "query",
        "required": false,
        "name": "id",
        "description": "Integer data. Ex: 2673"
      }, {
        "dataType": "string",
        "paramType": "query",
        "required": false,
        "name": "name",
        "description": "\u304a\u5ba2\u69d8\u306e\u540d\u524d"
      }, {
        "dataType": "string",
        "paramType": "query",
        "required": false,
        "name": "name__iexact",
        "description": "\u304a\u5ba2\u69d8\u306e\u540d\u524d"
      }],
      "responseClass": "ListView",
      "notes": null,
      "summary": "Retrieve a list of clients",
      "httpMethod": "GET",
      "nickname": "client_list"
    }],
    "path": ""
  }, {
    "operations": [{
      "parameters": [{
        "dataType": "integer",
        "paramType": "path",
        "required": true,
        "name": "id",
        "description": "Primary key of resource"
      }],
      "responseClass": "client",
      "notes": null,
      "summary": "Retrieve a single client by ID",
      "httpMethod": "GET",
      "nickname": "client_detail"
    }],
    "path": "/{id}/"
  }],
  "models": {
    "client": {
      "properties": {
        "updated": {
          "type": "datetime",
          "description": "\u66f4\u65b0\u6642\u523b"
        },
        "warning_threshold": {
          "type": "integer",
          "description": "\u3082\u3057\u30a2\u30e9\u30fc\u30c8\u306e\u70b9\u6570\u306f\u3053\u306e\u5e73\u5747\u4ee5\u4e0a\u3060\u3063\u305f\u3089\u3001\u304a\u5ba2\u69d8\u306e\u30b9\u30c6\u30fc\u30bf\u30b9\u306f\u300cWARNING\u300d\u306b\u306a\u308a\u307e\u3059\u3002"
        },
        "critical_threshold": {
          "type": "integer",
          "description": "\u3082\u3057\u30a2\u30e9\u30fc\u30c8\u306e\u70b9\u6570\u306f\u3053\u306e\u5e73\u5747\u4ee5\u4e0a\u3060\u3063\u305f\u3089\u3001\u304a\u5ba2\u69d8\u306e\u30b9\u30c6\u30fc\u30bf\u30b9\u306f\u300cCRITICAL\u300d\u306b\u306a\u308a\u307e\u3059\u3002"
        },
        "created": {
          "type": "datetime",
          "description": "\u4f5c\u6210\u6642\u523b"
        },
        "alert_mark": {
          "type": "integer",
          "description": "\u30a2\u30e9\u30fc\u30c8\u306e\u70b9\u6570\u3002"
        },
        "id": {
          "type": "integer",
          "description": "Integer data. Ex: 2673"
        },
        "resource_uri": {
          "type": "string",
          "description": "Unicode string data. Ex: \"Hello World\""
        },
        "state": {
          "type": "integer",
          "description": "\u304a\u5ba2\u69d8\u306e\u30b9\u30c6\u30fc\u30bf\u30b9"
        },
        "name": {
          "type": "string",
          "description": "\u304a\u5ba2\u69d8\u306e\u540d\u524d"
        }
      },
      "id": "client"
    },
    "ListView": {
      "properties": {
        "meta": {
          "type": "Meta",
          "description": ""
        },
        "objects": {
          "type": "Objects",
          "description": ""
        }
      },
      "id": "ListView"
    },
    "Objects": {
      "properties": {
        "client": {
          "items": {
            "$ref": "client"
          },
          "type": "List",
          "description": ""
        }
      },
      "id": "Objects"
    },
    "Meta": {
      "properties": {
        "previous": {
          "type": "string",
          "description": "Uri of the previous page relative to the current page settings."
        },
        "total_count": {
          "type": "int",
          "description": "Total items count for the all collection"
        },
        "offset": {
          "type": "int",
          "description": "Specify the offset to start displaying element on a page."
        },
        "limit": {
          "type": "int",
          "description": "Specify the number of element to display per page."
        },
        "next": {
          "type": "string",
          "description": "Uri of the next page relative to the current page settings."
        }
      },
      "id": "Meta"
    }
  },
  "basePath": "/",
  "namespace": "tastypie_swagger",
  "resourcePath": "/client",
  "apiVersion": "1",
  "version": "1"
}

I have absolutely no idea why.
I configured it the same way it is shown in the documentation.

Is it Tastypie related?

Thank you for your time.

@aropan
Copy link

aropan commented Oct 15, 2015

I had same problem. And because of the inexperience I spent a lot of time to solve until read the source code. Problem maybe in settings, recheck django-tastypie/django-tastypie#24 (function get_resource_uri return empty string). Helped removal namespaces for api urls. But will also work fine with NatespasedApi and NamespacedModelResource.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants