Skip to content

Instantly share code, notes, and snippets.

@mikekistler
Last active September 18, 2025 13:47
Show Gist options
  • Select an option

  • Save mikekistler/1983a8249c0df56a46f94b4df1b7181d to your computer and use it in GitHub Desktop.

Select an option

Save mikekistler/1983a8249c0df56a46f94b4df1b7181d to your computer and use it in GitHub Desktop.
Proposal for links in OpenAPI v4
@vaskozl
Copy link

vaskozl commented Sep 18, 2025

The notion of "just follow this link" with no definition of its parameters, headers, authorization scheme, response schema, response headers, etc does not make sense to me

For a REST API as described by Roy Fielding, the idea is that you'd return not only the link but also define how it is meant to be used in the same response where you gave out the link.

For instance, when returning text/html you might use a <form> to declare that one should do a POST. The client (browser) knows t the media type (text/html) and infers that it should make a POST with whatever input values might be in the said form.

For JSON, you'd technically start the client without reading the global API spec, and in theory the OpenAPI enabled server would return application/openapi+json or some other well defined media type that returns the part of the spec documenting the operation you are linking to.

In theory this could be used for some clever communication of the next possible state. E.g. regular users get told they can only view a resource via a GET, while admin users get told they can additionally DELETE it or replace it edit it via a PUT. Similar to how you only return such a button on an HTML server.

Full HATEOAS support would imply that the clients should be able to dynamically read OpenAPI spec bit by bit. I agree with Bert-R that, this is highly unrealistic and unexpected by your general OpenAPI client.

As such I'm not sure I see a reason to "hide" it from the original spec, given that we don't have the facility to return the spec at all in the ecosystem. HATEAOS clients (such as browsers) wouldn't read the spec in the first place.

This proposal is still really useful because it allows interoperability. E.g. you can make a common "Location" header returning endpoint which is usable via both a regular OpenAPI Client and also a web browser -- which is really nice.

@mikekistler
Copy link
Author

@vaskozl @Bert-R Thanks for your comments. But sadly I think this proposal is dead. There is no agreement on what the current link object means in OpenAPI and the spec offers no guidance, so there is little appetitie in the TSC for fixing or improving a feature that is broken beyond repair.

It pains me to say this because I believe (as I think you do) that this could be an extremely useful feature. But I have given up trying to get others in TSC to find a path forward with this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment