Investigate and chose an API description format
Description
Environment
Activity
Walt Miner August 27, 2020 at 7:37 PM
Re-opened and assigned to Production Readiness Epic. Assigned to for now. Eventually should be assigned to someone in the App FW EG. During the App FW Eg meeting this week we discussed a few possible solutions.

Vincent Rubiolo September 26, 2019 at 8:20 AM
Just for the record as this was mentoned during the Berlin F2F meetings: 'afbidl' stands for 'Application Framework/Binder Interface Description Language'.

Stephane Desneux July 3, 2019 at 1:51 PM
Status updated, posted on the mailing list (https://lists.linuxfoundation.org/pipermail/automotive-discussions/2019-July/007524.html)
There's an ongoing task to specify an API schema (see SAT meeting minutes back
in November 2018 [1] as well as [2])Back in 2018, some people at IoT.bzh investigated on API specification formats
(openAPI, asyncAPI ... and other IDLs). The conclusion at that time was that
none of the existing formats has the required features: some are too
web-centric, others not fitted for describing unattended events, some others too
complex = not human readable/writable.So we decided to create a specific schema 'afbidl' that fits with the concept of
AGL bindings and covers all the features we need:
written in readable YAML or JSON (YAML for human, JSON for machines)
describe APIs in details: verbs, events, datatypes, unit tests + expected
results ... leveraging JsonSchema spec (https://json-schema.org/)having an online editor should be pretty easy (we could imagine something
close to [3])generators can read the API description and produce various outputs:
code skeleton / stubs
API tests for QA
API compliance information (test if a binding complies with the API using
introspection)documentation (markdown for doc site, HTML for local usage, text, pdf ...)
...
For the documentation part, the format we propose includes the "book schema"
already used in repositories to describe the available documentation (example
here[4]).We took the simple GPS API to show what it would look like: see [5] for the API
description and [6] for some generated HTML (formatting is missing).[1]:https://wiki.automotivelinux.org/agl-sat-meetings#november_22_2018
[2]:https://lf-automotivelinux.atlassian.net/browse/SPEC-1903
[3]:http://editor.asyncapi.org/
[4]:https://git.automotivelinux.org/apps/agl-service-can-low-level/tree/docs/api-services-book.yml
[5]:https://git.automotivelinux.org/apps/agl-service-gps/tree/api/gps-service-geolocation.yml?h=sandbox/benierc/newapis
[6]:https://iot.bzh/download/public/tmp/gps-service-geolocation.html

Sebastien Douheret July 3, 2019 at 1:34 PM
Quote of Documentation meeting notes (November 14th 2018) sent by
AsyncAPI 1.2: Stephane studied openAPI and asyncAPI. But none really fits our needs:
openAPI is too web-oriented and asyncAPI only focuses on messages (which is a
part of what we're doing). What we do with binders/bindings is in between both.
So we'll propose a new description format: the name for this new format is not
decided yet (proposals are welcome)... Let's call it "AglAPI" for now:
Intuitive description of an AGL API by a human writer (JSON format supported,
YAML format may be optionally), close to what is developed in a binding: we call
'verbs', we get 'responses', we send 'events'... That's the vocabulary we use
every day: let's adopt it for API description, so people are not lost.
API documentation (metadata available, i18n support in a second phase)
Parameters/objects description using JSONschema, very close to what openAPI does
QA tests description for verbs/events (generate automated QA)
Support for permissions
It should be possible to translate an 'AglAPI' file into an openAPI file.
Similarly, we could probably import existing APIs from openAPI (and other
formats as well)
Tools: some tools similar to swagger or http://editor.asyncapi.org/ should be
quite easy to write
Stay tuned on : See https://lf-automotivelinux.atlassian.net/browse/SPEC-1903?page=com.atlassian.jira.plugin.system.issuetabpanels%3Aall-tabpanel for related JIRA entry. we'll update as soon as we have a proposal.
Details
Details
Assignee

Reporter

On AGL side, we have the following requirements about API description (non exhaustive list):
the API specification may be defined by one person
then it can be implemented and amended by another person [the developer]
some other people from QA would also leverage the API description to write/execute some
automated tests (test the verbs calls with good values, bad values etc. and
check the results)
some technical information could also be used at runtime (APIs dependencies for example)
and at the end, we want also everybody to be able to document the API in the same
file. Typically, we expect a description of each API verb with its parameters,
and the detailed description of the responses (fields, meaning, error cases etc.)
Some background info on the topic:
https://fr.slideshare.net/tedepstein/openapid-vnext-openapi-vnext-events-alternative-schemas-the-road-ahead
The beginning of the presentation shows the history for specifying (web)
APIs. It started by WSDL, then RAML appeared, then Swagger, openAPI etc.
One special thing about the APIs in AGL: the bindings are independent of the
transport mechanism (handled by the binder). So sending a request is just
sending a json object over the wire and get a json result back (whatever the
wire is).
On the other hand, most of the formats we found until recently are related to REST APIs, used
on the web and don't exactly match what we do with bindings: the APIs
description are not independent of the transport. Even openAPI 3.0 which handles
"server messages" (=messages pushed from a webserver to a client through a
websocket) doesn't represent exactly what we do with events in bindings.
We also discovered the emerging specification AsyncAPI 1.2 which is more focused
on messages and doesn't care about the transport. So it's closer to what we do
in AGL but this deserves more investigation to see if it can be used or not.
As a summary, we have at least 2 modern specifications to investigate deeper: openAPI and
asyncAPI.
Links:
openAPI 3.0 : https://www.openapis.org/
asyncAPI 1.2 : https://www.asyncapi.com/
Some background articles on asyncAPI:
https://nordicapis.com/tooling-review-asyncapi/
https://streamdata.io/blog/streamdataio-api-openapi-asyncapi/
Sample generated docsite:
https://mermade.github.io/shins/asyncapi.html#asyncapi-sample-v1-0-0