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

Tips for (XR) API design #564

Open
negz opened this issue Oct 3, 2023 · 3 comments
Open

Tips for (XR) API design #564

negz opened this issue Oct 3, 2023 · 3 comments

Comments

@negz
Copy link
Member

negz commented Oct 3, 2023

What's Missing?

One challenge folks getting started with Crossplane have is how to design their custom APIs - i.e. how to design XR OpenAPI schemas. It's hard to go from nothing to a serviceable API that can evolve over time without breaking changes.

I think the Crossplane maintainers will have some useful tips for this. A lot of our job is designing new APIs for Crossplane, and we've certainly made and learned mistakes with Crossplane's APIs. Kubernetes API conventions capture a lot of this and we could draw out some of the more important things called out in that document. I'd also include things like:

  • If you're introducing a new object (e.g. spec.databaseConfiguration), could it be implemented a few different ways in future? If so, consider using a type differentiator field (e.g. spec.databaseConfigurationType) and nesting each type's configuration in its own object.
  • If you introduce an array of objects, always require some field that uniquely identifies each object (e.g. name).
  • Always look at your API through the lens of "how far could I evolve this API by only adding new optional fields?"
@negz
Copy link
Member Author

negz commented Feb 14, 2024

I think this would probably include #478.

@negz
Copy link
Member Author

negz commented Feb 14, 2024

Another little thing: don't make status fields required.

@jbw976
Copy link
Member

jbw976 commented Mar 27, 2024

This K8s API doc on "Changing the API" is probably also helpful here: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api_changes.md

This document is oriented at developers who want to change existing APIs

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

No branches or pull requests

2 participants