Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OpenAPI documents for the toolchains and Swift evolution APIs #841

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

czechboy0
Copy link
Member

@czechboy0 czechboy0 commented Oct 29, 2024

Motivation:

Fixes #832.

Swift.org has an undocumented swift.org API that's used by swiftly and other tools to fetch releases, and a download.swift.org API that's used by the Swift Evolution web dashboard.

Modifications:

  • Added an OpenAPI document describing the current v1 of the swift.org and download.swift.org APIs.
  • Added a test project that generates a Swift client and validates that all the content successfully parses, i.e. that the OpenAPI document is in-sync with the returned data.
  • Added a footer item called "API" that points to the docs (see screenshot below).
  • Added a Swagger UI-based preview that has a picked between the two OpenAPI documents (see screenshots below).

Result:

Tools can use the OpenAPI document to generate a client in any language, and more easily keep up with future API evolution.
Screenshot 2024-11-09 at 3 48 17 PM

Screenshot 2024-11-09 at 3 43 34 PM Screenshot 2024-11-09 at 3 43 29 PM

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way we can autogenerate this? Otherwise keeping this up to date with new APIs is going to get out of date pretty quick

Copy link
Member Author

@czechboy0 czechboy0 Nov 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Autogenerate from where? This will be the source of truth, and any generation would happen the other way - from this document, generating clients, and if the API ever becomes a dynamic server (it's static files right now), also generate the server stubs.

This PR contains a CLI that verifies the compliance of the static files with the OpenAPI doc, so keeping things in sync should be easy.

We want changes to be done deliberately, but recently swiftly was broken because of a miscommunication between the two parties. More details on how spec-driven helps avoid similar issues, and allows us to discuss the API without getting bogged down by implementation: https://swiftpackageindex.com/apple/swift-openapi-generator/1.4.0/documentation/swift-openapi-generator/practicing-spec-driven-api-development

@shahmishal shahmishal self-assigned this Nov 5, 2024
@czechboy0
Copy link
Member Author

FYI, I also added an OpenAPI document for the download.swift.org API that vends Swift Evolution metadata.

@czechboy0 czechboy0 changed the title Add a Swift.org API OpenAPI document Add OpenAPI documents for the toolchains and Swift evolution undocumented APIs Nov 9, 2024
@czechboy0 czechboy0 changed the title Add OpenAPI documents for the toolchains and Swift evolution undocumented APIs Add OpenAPI documents for the toolchains and Swift evolution APIs Nov 9, 2024
@czechboy0
Copy link
Member Author

czechboy0 commented Nov 9, 2024

Now, as I was documenting the existing API, I have ideas of what an eventual v2 API could look like (for example, unify them under the same hostname and OpenAPI document). However, I think it's important that we're documenting what we have today, as a starting point for any discussion for changing the API in the future.

In other words, documenting this API does not imply a higher commitment to this API than when it was undocumented - we only make explicit what was already there, to allow for an easier collaboration and consumption of the API. We want to avoid the (sadly) common approach of "we don't want to document this API because we don't want to commit to it" (documented vs undocumented and committed vs uncommitted are completely orthogonal) - thus my disclaimer above 🙂 Documenting these APIs only moves us in the right direction without taking anything away.

@@ -33,3 +33,5 @@
/_posts/* @timsneath @tkremenek @shahmishal

/gsoc*/ @ktoso

/openapi/ @czechboy0
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy to review future changes to the OpenAPI documents, but that'd require me to receive write access - I'll leave that up to the SWWG to decide whether that's valuable for me to have or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Publish an OpenAPI document describing the Swift.org API
3 participants