Hello all,
In an attempt to follow Mike Amundsen's advice in "Restful Web APIs," I'm trying to design an API that uses existing profiles for application semantics, as opposed to making up my own taxonomy. For people familiar with the book, chapters 8, 9, and 10 are relevant to this question.
I've found a few formats that come close but don't cover everything I need. Ideally I could combine the handful of profiles that each partially fit my domain, but I'm not sure how to do that, especially not in the same document.
Furthermore, some of my needed semantics are not covered by any of these profiles. It's not feasible for me to create a formal profile that encompasses all my semantics - I don't have the resources to register/extend profiles published by IANA,
schema.org, and the like. Therefore I'll need to have fields in my API that aren't covered by a profile.
I'm curious if any of you have dealt with situations like this and how you proceeded.
1. How have you combined multiple semantic profiles in an API? Or do you avoid doing so?
2. How do you treat un-profiled fields?
3. How do you merge domain specific formats with pure hypermedia formats like HTML, HAL, JSON-API, UBER, etc.?
To make this more concrete I'll give a summary of my domain and the profiles:
I'm designing an API related to bus transit. The goal is to show bus routes, stop locations, arrival times, alerts about changes and disruptions in service, and other related information. Many people have put thought into this domain already and there are several existing profiles:
-- Formatted as a collection of CSV files, intended for infrequently updated service info, like a public transit agencies quarterly schedules.
-- Uses google protocol buffers, intended to pass timely info to clients, like the fact that a bus is 3 minutes away from a stop right now.
-- The documentation encourages embedding the
schema.org semantics within JSON-LD documents, although they also have some microdata/RDFa examples.
Again I also have semantics specific to other aspects of a user's interaction with our business, and aren't covered in these existing transit profiles. Those are the un-profiled semantics I mentioned above. I'm not sure how to include those attributes in my API along with the profiled data.
Finally, the profiles above do not directly support hypermedia (aside from JSON-LD in
schema.org). Therefore I would like to embed them within a media type like vnd.api+json or application/vnd.amundsen-uber+json. The problem however is that by cramming the domain-specific schemas inside the schema defined by a media type, I may undermine clients' ability to parse the domain specific profile. For example, existing GTFS parsers that expect CSV will not be able to parse a JSON translation of the GTFS schema that's embedded inside the `data` element of an UBER or JSON-API document.
I'm wondering if it's even helpful to make the effort to "reconcile names" to these domain specific schemas, given that we'll need to create custom clients to parse the combined profiles anyway.
Thanks in advance for any input you all have on these topics.
Stephen