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

Question regarding decoupling the API from the implementing software #952

Open
eibhear-from-athlone opened this issue Jun 17, 2023 · 7 comments

Comments

@eibhear-from-athlone
Copy link

Where I work we define APIs that are to be implemented by independent organisations. As the APIs are independent of the implementing software, we apply indepdendent versioning to them (in the case of our OpenAPI documents, for example, the info.version attribute describes the version of the API, and not necessarily the service behind the interface).

We are considering mandating SemVer on the APIs. However, feedback we have received is that SemVer can't be applied directly, as SemVer (at 2.0.0 at the time of writing) applies to the software that declares the API.

We are left with one of the following options:

  1. We declare internally that we are using something like (or inspired by) SemVer, but we can't tell people that SemVer – as described at https://semver.org/ – applies, because SemVer applies to the software only.

  2. We get confirmation from that SemVer maintainers that SemVer can be applied to APIs independently. For certainty, I could proceed to raise a PR (perhaps an RFC is required) to add this confirmation to the FAQ in semver.md.

  3. If the SemVer maintainers believes that 2.0.0 of SemVer means that SemVer can only be applied to the software, I could then raise an RFC to replace the text

    Software using Semantic Versioning MUST declare a public API. This API could be declared in the code itself or exist strictly in documentation. However it is done, it SHOULD be precise and comprehensive.
    

    with the following (or something like it)

    A public API CAN use Semantic Versioning. Software using Semantic Versioning MUST declare a public API. This API could be declared in the code itself or exist strictly in documentation. However it is done, it SHOULD be precise and comprehensive.
    

    If the RFC is not accepted (i.e. "closed" in the terms of CONTRIBUTING.md), I will have to revert to my clunky option 1. above.

Can you advise whether my clunky option 1. is all I can use? or that the current SemVer specification can be assumed to include independent versioning of APIs? or if I could/should raise an RFC for your consideration?

@jwdonahue
Copy link
Contributor

SemVer absolutely does apply to API's. Just read the spec, particularly the intro. You define what API means, not the spec. There is no reason you cannot independently version your API from its implementations. The API in the spec, stands for Application Programming Interface, not Application Package Interface or Application Implementation Interface, though the way the intro and the spec define API, it's really up to you what it means.

There may be some nuanced details to consider, depending on your tool chain and how you package and distribute your code, as well as how your customers package and distribute their code. Are you in any particular vertical environment?

The fact that SemVer is mostly implemented by various package management tools in no way implies that SemVer cannot be used to version an API. I have created many independently versioned C# interface packages over the years using SemVer. For a couple of decades prior to SemVer's release, we often used similar/divergent schemes in C (using zip or tar packages), versioning the header files or collections of them, separately from their implementations. It's been a common practice in the embedded systems world, where you have a hardware abstraction layer that provides a common interface and multiple implementations.

@eibhear-from-athlone
Copy link
Author

Hi @jwdonahue, Thanks for your response. I'm hoping that someone on the maintainers list can confirm your assertion that SemVer applies to the APIs.

The feedback I have received where I work contradicts that assertion; backed up by reference to point 1 of the section Semantic Versioning Specification (SemVer) ("Software using Semantic Versioning MUST ...") in the document at semver.org. It's the software that uses SemVer, and not the API, so the argument goes, which I can appreciate (we're a very legalistic lot over here). The other sections in the document are not the specification I am told, and therefore strict adherence to the specification required regarding only the that section.

Are you in any particular vertical environment?

I'm not at liberty to say.

There may be some nuanced details to consider, depending on your tool chain and how you package and distribute your code, as well as how your customers package and distribute their code.

Our context is that we define APIs for HTTP services (some fully compliant with REST, others not so much) and we document them using OpenAPI. We then share those documents with multiple other organisations who will implement services that expose those interfaces. The software stack and tool chain is fully in the control of the organisations that develop the services, so it's not a material concern for my question.

As I say, if someone from the maintainers team can give me a steer here, it would help greatly.

@jwdonahue
Copy link
Contributor

From clause 1 of the v2 spec:

Software using Semantic Versioning MUST declare a public API. This API could be declared in the code itself or exist strictly in documentation. However it is done, it SHOULD be precise and comprehensive.

You have made it clear that you provide an API for your clients to implement. You should version that API, why not use SemVer?

Only reason I can think of is if client X's implementation is not compatible with client Y's implementation, in which case, what value do you even provide for them?

@jwdonahue
Copy link
Contributor

Skimming through the OpenAPI propaganda once again, I found this bit on what they define an API is:

An Application Programming Interface (API) defines the allowed interactions between two pieces of software, just like a User Interface defines the ways in which a user can interact with a program.

An API is composed of the list of possible methods to call (requests to make), their parameters, return values and any data format they require (among other things). This is equivalent to how a user’s interactions with a mobile phone app are limited to the buttons, sliders and text boxes in the app’s User Interface.

@eibhear-from-athlone, can you provide any technical reasons why your product should not fall under the definition of an API?

That description sounds like a particular kind of software known as an API. The whole point of the OpenAPI initiative is to separate the definition of the interfaces from their implementations. I don't see how that separation can be managed in the real world, if both must have the same version numbers. Maybe there is an existing convention in your particular market that implies something else?

My simple understanding of the model is something like:

  Consumer => OpenAPI Spec <= Service

It seems to me that the consumer and the service probably need to agree on which version of the API spec that they are referencing, much like some package managers reference SemVer 1.0.0-beta and other reference 2.0.0.

Without more detailed context, all any of us can do is quote the spec, apply some common sense and add that context matters, so lacking that, you're not likely to get a more definitive answer. Not even from one of the maintainers, who are likely busy providing value for their employers or just trying to live a life.

My intuition tells me that SemVer is agnostic in your particular domain. Apply it to the service and its exposed API's as they co-evolve or apply to each of the components separately. How you should apply to satisfy your needs and those of your clients, is entirely up to you.

@bhetland
Copy link

bhetland commented Jun 29, 2023 via email

@jwdonahue
Copy link
Contributor

jwdonahue commented Jun 29, 2023

software that don't provide an API (very common for classical Windows apps with only a UI, for example) cannot be versioned using SemVer in any compliant way; they must be versioned in some other way although it may of course incidentally resemble the SemVer principles in the remaining aspects

LOL, you tell that to the thousands of test engineers who write tests for those UI's, including robotics systems that work it through the touch interface. That is an absurd statement that has been put to rest as false here on multiple occasions.

I've even had talks with groups who wanted to use it to version documents. At least one of them has written an overlay spec that describes how to correctly apply full SemVer semantics and syntax in documents.

The SemVer spec literally says that you define what the API is, so you could pretty much declare chisel marks in a stone artifact as the "API" and apply SemVer thereon, if you really wanted to take it to the extreme: Statue 2.0.0, changes since 1.1350.1: 2 new cracks have been introduced as a result of recent refinements :)

I cannot see how you can interpret this as describing a "software" at all. It describes [part of] the behavior of some software pertaining to the API part, but not the software itself. As I see it the software implements an API, but it is not an API

How do you declare your API's? YAML, XML, JSON, signal flags? Sounds like software to me.

An API MAY define behavior or any other aspect of the software you wish to call the API. The fact that some implementations support multiple API's just drives my point home really. If you introduce a breaking change in the way one API is implemented and not the others, are you really going advertise a breaking change to all of them? I hope not.

An earlier version of me was a tester on the Windows kernel team, before they fired all the testers, I owned a small bit of RPC, all of MIDL, Task Scheduler and Service Manager. We versioned interfaces separately from the implementation. Every day we built several thousand different versions of the client and server implementations (lots of branches), mostly without having to bump any interface versions. RPC/COM interface versioning even uses a similar semantic scheme to SemVer. I don't recall the details today, as I have gone through several breaking changes myself, since then, but I think we were actually versioning the interfaces in header files back then.

If your interface definitions are embedded in some way in your implementation code and you don't have the desire or resources to fix that problem, that's fine with me. I am never going to buy the argument that SemVer cannot be applied to API's independently of implementations. I have done it, and it's a common practice.

@jwdonahue
Copy link
Contributor

@bhetland does your current versioning scheme convey any semantic content? Would the SemVer syntax and semantics be useful to your team and your customers? If the answer to the first is no and yes to the second, then don't let anybody's dogmatic misread of the SemVer spec stop you from doing whatever makes the most sense. Call it a SemVer inspired semantic version scheme for OpenAPI's and move on. But don't let the idea that SemVer could be used, prevent you from innovating either.

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

7 participants
@bhetland @jwdonahue @eibhear-from-athlone and others