OpenSourceFellows / amplify

Open Source Fellow Sandbox
https://amplify-app-production.herokuapp.com/
MIT License
86 stars 61 forks source link

Epic 3: Document API with an OpenAPI schema #125

Open JamesMGreene opened 2 years ago

JamesMGreene commented 2 years ago

Description

Mission statement: Users can read the “raw” OpenAPI docs since they’re written in YAML, but for a better experience, we want to build a Pages site that intakes the raw files and outputs formatted, easy-to-read information.

Context We currently document our API with manually updating Wiki pages, which are prone to inaccuracy and to becoming outdated. 😕

One alternative to consider would be documenting the API with a central OpenAPI schema file.

Side benefit: if desired, we can also then use additional Express middleware tooling for request validation. I have mixed feelings about this in practice based on past experiences but it is not unlikely that there are better tools available these days than a few years back. 🤷🏻‍♂️

With either of those approaches, we can then generate the documentation for it using the existing OpenAPI/Swagger tooling (see example demo page).

Spec

SMART exit criteria:

Links/Attachments for Reference

Considerations

Exit Criteria Implementation notes

Hack out Tasks (9:15-10:30):

manishapriya94 commented 2 years ago

@JaymePerlman @momartinjazz for visibility

manishapriya94 commented 2 years ago

@JaymePerlman: API in Wikis is very complete

Clarify: Which APIs are they going to use? What are parameters you can modify? Are new APIs anticipated to be added?

Potential videos:

JaymePerlman commented 2 years ago

Capturing notes here.

Mission statement

Users can read the “raw” OpenAPI docs since they’re written in YAML, but for a better experience, we want to build a human-readable set of docs. There are tools that consume the raw files and output formatted, easy-to-read information.

Documentation should cover any HTTP error responses that are likely to happen and include instructions on how to remedy it. And some kind of message for the “200 success” code.

Potential jump-start

As I suspected, we’re far from the first to try and solve this problem. For initial setup, we can just use the steps contained in this repo to generate and publish our “pretty” documentation on a GitHub Pages site. However, this site contains only one specification file, and we might end up needing more than one.

As a bonus, it even contains a publish Action that we can modify to suit. Right now it runs an update every 10 hours (cron job) but we can probably change that to have it run when triggered instead of on a regular cadence. We could also change it to run more frequently, or hey, worst case it’s completely functional as-is.

Having this basic infrastructure already in place frees up the hackathon to work on other things.

Technical References

If folks are working in a codespace they can add the OpenAPI plugin.

Here’s a good basic structure documentation site, but the official specification is pretty easy to follow.

The root file must contain a few objects:

We probably want to have as many re-usable parts as possible. We should define a list of them, but there are definitely a few that leap to mind:

I don’t know enough to know if we need to define a security scheme (authentication/authorization), or if we’re even using any - that might be handled completely elsewhere, like by GitHub itself.

Thoughts and TBDs

Can we / do we document APIs we are using, not writing? If so, they may have their own OpenAPI files already available, so we can potentially copy their stuff into our stuff rather than write it all up from scratch. Not sure what the plan is to keep all that up to date, though. If they change stuff that we rely on, how do we know?

Regarding API testing, we have a responsibility to document how to do it. But that's outside the scope of the API specifications, so where are we putting the SBS procedures for testing, and how are we getting it there? We only had API documentation before, so we've been solving for that problem, but now we have different kinds.

OpenAPI is a specification for writing APIs, not just documenting them; are the devs on board with writing to this specification?

Most parsers can handle one root file, and if we only document the APIs we write, we should only have one root file. If we decide to / can include APIs that have different root server sources, we'll need different files to capture them all. There are multiple documentation-generation tools available, but installing/configuring them may require some expert/developer time. The only one that seems to work with Jekyll, which means it's compatible with GH Pages, is jekyll-openapi But there are much more advanced options such as API explorer which includes an interactive API explorer. Awesome, if we can get it to work, but overkill?

momartinjazz commented 2 years ago

Epic Notes

Introductions and setting expectations

@JaymePerlman introduced her research around this Epic 3

Actions or impacts

Actions to get started

Next steps

References