monarch-initiative / biolink-api

API for linked biological knowledge
https://api.monarchinitiative.org/api/
BSD 3-Clause "New" or "Revised" License
64 stars 25 forks source link

Configuration of endpoints as driven by config.yaml #237

Closed deepakunni3 closed 5 years ago

deepakunni3 commented 5 years ago

This approach is more config.yaml driven.

route_mapping:
  namespace:
    - name: bioentity
      description: Retrieval of domain entities plus associations
      routes:
      - route: /<id>
        resource: biolink.api.bio.endpoints.bioentity.GenericObject
      - route: /<type>/<id>
        resource: biolink.api.bio.endpoints.bioentity.GenericObjectByType
      - route: /<id>/associations
        resource: biolink.api.bio.endpoints.bioentity.GenericAssociations
     ...

The config.yaml allows for a more fine-grained configuration where you define what route maps to which resource. Having all the routing configuration in one place makes it easier than editing all individual endpoints.

If there is an implementation specific resource then all one has to do is change the route to resource mapping in config.yaml and it should be registered during app initialization.

To remove a route from showing up, simply omit it from the config.

I would prefer this approach over https://github.com/biolink/biolink-api/pull/236

If this looks good then I can go ahead and include all the other routes (currently the config.yaml has routes only from bioentity namespace).

deepakunni3 commented 5 years ago

@cmungall @lpalbou I have added configuration for all remaining routes.

If this PR looks good then feel free to merge. After this @lpalbou can trim this config.yaml to set up a GO BioLink API.

deepakunni3 commented 5 years ago

👍

kshefchek commented 5 years ago

We might consider separating a route config and server config, for example I just ran into an issue where we override the default server conf on api-dev, but will also now need to occasionally sync back with master to get new/updated routes.