greenelab / django-genes

A Django package to represent genes
BSD 3-Clause "New" or "Revised" License
2 stars 3 forks source link

bitbucket: API exposes both `id` and `pk` #11

Open rzelayafavila opened 6 years ago

rzelayafavila commented 6 years ago

Copied from bitbucket issue #13: (priority: minor) https://bitbucket.org/greenelab/django-genes/issues/13/api-exposes-both-id-and-pk

@mhuyck commented: """ The API for django-genes can be inspected via Tastypie at, e.g.:

http://hostname/api/v0/gene/schema/?format=json

When I do this for the installation we have on adage-server, I get the following:

{
  "allowed_detail_http_methods": [
    "get"
  ],
  "allowed_list_http_methods": [
    "get"
  ],
  "default_format": "application/json",
  "default_limit": 50,
  "fields": {
    "aliases": {…},
    "description": {…},
    "entrezid": {…},
    "id": {…},
    "obsolete": {…},
    "pk": {…},
    "resource_uri": {…},
    "standard_name": {…},
    "systematic_name": {…},
    "weight": {…},
    "xrids": {…}
  },
  "filtering": {
    "entrezid": 1,
    "pk": 1,
    "symbol": 1
  }
}

It seems from the code (and the API itself, see "filtering" section) that the intent was to expose pk in place of the internal id, but we are getting both. This is because GeneResource automatically picks up all of the fields from the Gene model backing it and Gene extends model.Model, which includes an auto-generated id.

This is a minor issue, but it does create a bit of confusion when using the API as to which field should be used as an identifier.

"""