Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "public api" means in Semantic Versioning?

I'm learning about how to assign and increment version numbers with the rule called "Semantic Versioning" from http://semver.org/.

Among all its rules, the first one said:

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"

I am confused about "public API". What does it refer to?

like image 238
Neekey Avatar asked Feb 27 '12 10:02

Neekey


People also ask

What is the specification of semantic versioning?

Semantic Versioning is a 3-component number in the format of X.Y.Z, where : X stands for a major version. The leftmost number denotes a major version. When you increase the major version number, you increase it by one but you reset both patch version and minor versions to zero.

What is a breaking change SemVer?

Change categories Minor change: a change that requires only a minor SemVer bump. Possibly-breaking change: a change that some projects may consider major and others consider minor.

What is semantic versioning used for?

Semantic versioning is a formal convention for determining the version number of new software releases. The standard helps software users to understand the severity of changes in each new distribution. A project that uses semantic versioning will advertise a Major, Minor and Patch number for each release.

What is the first version in semantic versioning?

Major version zero (0. y.z) is for initial development. Anything may change at any time. The public API should not be considered stable.


3 Answers

Public API refers to the "point of access" that the external world (users, other programs and/or programmers, etc) have to your software.

E.g., if you're developing a library, the public API is the set of all the methods invokations that can be made to your library.

There is understanding that, unless a major version changes, your API will be backwards-compatible, i.e. all the calls that were valid on a version will be valid on a later version. You can read at point 9 of those rules:

Major version X (X.y.z | X > 0) MUST be incremented if any backwards incompatible changes are introduced to the public API.

like image 57
fdierre Avatar answered Sep 18 '22 19:09

fdierre


I discovered SemVer today and read up on it from several sources to ensure I had fully grasped it.

I am confused about "public API". What does it refer to?

I was also confused about this. I wanted to set about using SemVer immediately to version some of my scripts, but they didn't have a public API and it wasn't even clear to me how they could have one.

The best answer I found is one that explains:

SemVer is explicitly not for versioning all code. It's only for code that has a public API.

Using SemVer to version the wrong software is an all too common source of frustration. SemVer can't version software that doesn't declare a public API.

Software that declare a public API include libraries and command line applications. Software that don't declare a public API include many games and websites. Consider a blog; unlike a library, it has no public API. Other pieces of software cannot access it programmatically. As such, the concept of backward compatibility doesn't apply to a blog. As we'll explain, semver version numbers depend on backward compatibility. Because of this dependence, semver can't version software like blogs.

Source: What Software Can SemVer Version?

like image 40
Rounin - Glory to UKRAINE Avatar answered Sep 20 '22 19:09

Rounin - Glory to UKRAINE


It requires a public API in order to effectively apply it's versioning pattern.

For example:

Bug fixes not affecting the API increment the patch version

Backwards compatible API additions/changes increment the minor version, and...

Backwards incompatible API changes increment the major version.

What represents your API is subjective, as they even state in the SemVer doc:

This may consist of documentation or be enforced by the code itself.

like image 42
Yurii Kyparus Avatar answered Sep 21 '22 19:09

Yurii Kyparus