learningtapestry / metadataregistry

DEPRECATED - THIS CODE BASE IS NO LONGER MAINTAINED. Metadata Registry
Apache License 2.0
7 stars 5 forks source link

Create documentation APIs #25

Closed science closed 7 years ago

science commented 8 years ago

We need APIs that provide inventories and metadata about system. For example:

/api/info gives metadata about the /api endpoint:

{
  "metadata_communities": ["http://#{servername}/api/learningregistry/","http://#{servername}/api/credentialregistry/"],
  "specification": "http://#{servername}/api/swagger#api"
}

/api/credentialregistry/envelope/info:

{
  "POST": {
    "accepted_schemas": ["http://{server}/api/credentialregistry/schemas/cti-credential-schema.json", "http://{server}/api/credentialregistry/schemas/cti-organization-schema.json"]
  },
  "DELETE": {
    "accepted_schemas": ["http://{server}/api/credentialregistry/schemas/envelope-delete-schema.json"] 
  }
}
aspino commented 8 years ago

Isn't this the same as what's implemented in #18? At least the first part about communities and documentation. Check this out: http://lr-staging.learningtapestry.com/api/

science commented 8 years ago

Indeed - sorry I missed that you implemented that! I'm adding a few additional features to that info system with the second part: the schema documentation. But yes @aspino it's pretty much the same.

How do you feel about using GET as the info source? Is that better than appending "./info" to the request to get information? I'm worried that some apis will rely on GET and so we won't have a good way of returning information consistently on various endpoints.. Thoughts?

aspino commented 8 years ago

I feel appending /info is a little bit redundant, because issuing a GET to a resource clearly reveals the intention that you want to retrieve information about that resource. But, as always, it's just a matter of preference. If you want to always use /info to be more consistent because other endpoints may use the resource's root path to return other, more important representations, then I guess it's fine.

andersoncardoso commented 8 years ago

I guess using GET directly on the resources would introduce some consistency issues as aforementioned.

To circumvent this, we could use a specific Content-type (something like application/vnd.learningregistry.apidoc+json). But on that case, we would be returning different information depending on the Content-type (instead just different representations of the same resource), which might not be good. Besides there is the overhead of changing headers etc.

Using */info might be better since it provides different data for different endpoints, and is easily 'browseable'.

We already do something similiar for json-schemas. Instead using "application/schema+json" on the same resource endpoints, we use /api/schemas/<something>

Just to illustrate the 3 cases:

1st case:

2nd case (same endpoint, different header, different info):

3rd case (different endpoints, different info):

ps: info on this case is: accepted json-schemas, links for docs on swagger, metadata like counts and etc

If I missed some point or mistaken something let me know, tks

science commented 8 years ago

I'd say the inconsistent availability of GET requests (sometimes they perform a "real" api function sometime they return information) is the main problem.

I'll vote for 3rd case with one addendum. "/api" (the root) should probably return an HTML page - maybe the readme file, with maybe a link to /api/info. "/api/info" would return communities list and other root api data. And the rest of your suggestion for option 3 as listed.

That's my vote - I'll be curious if @aspino cares much (or @andersoncardoso if you have a preferred approach?).

Thanks for writing it up!