question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Output multiple API versions in one schema (path/namespace versioning only)

See original GitHub issue

Describe the bug

My team is trying to upgrade from 0.14.0 to 0.17.0.

In https://github.com/tfranzel/drf-spectacular/commit/2eaac13889624bffef208c7a401c33a8a472b194#diff-136013649b2fdf2f5496f11ae4591a56cc9d5d340869338b544905cb40b608f4L216, the ability to get the API version from the request was removed.

We used the GET_MOCK_REQUEST setting to set the version on the request that the generator would use. Because our team uses namespace versioning, we could extract something like v2 from a path like /v2/some-resource/.

The effect of this removal is that the operation_matches_version check fails (https://github.com/tfranzel/drf-spectacular/blob/master/drf_spectacular/generators.py#L222) and endpoints that aren’t the default version are skipped in the output.

Expected behavior

I would expect to have a generated schema that includes multiple versions of an endpoint if they exist.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
mblaymancommented, Jun 8, 2021

Thanks for clarifying what you meant by safely. I wasn’t thinking about header based versioning and I agree this would not be safe for that.

Since we’ve got a workaround that makes this scheme work for our team, I can close the issue if you want. Or we can leave it open if you think it would be reasonable to support this kind of namespace versioning pattern as a feature request in the future.

0reactions
tfranzelcommented, Jun 8, 2021

aweome! glad your found a solution. i’ll rename the issue and leave it open for future reference. i can see this feature happening with 1-2 more independent requests.

Read more comments on GitHub >

github_iconTop Results From Across the Web

API versioning with ASP.NET Core and Swashbuckle
ApiVersion : Lets you define in which versions of your API this controller and all of it's methods is supported. You can add...
Read more >
Net Core 3.1 swagger API versioning conflicting namespaces url
You cannot have duplicate route paths or model names in the same document. You can, however, have duplicate model names across multiple versions...
Read more >
Versions in CustomResourceDefinitions - Kubernetes
Versions can have different schemas, and conversion webhooks can convert custom resources between versions. Webhook conversions should follow the Kubernetes API ...
Read more >
Versioning Web API - Blog of Pi Logo
By the way, you will get an error “An API version is required, ... are placed inside two different namespaces, but has the...
Read more >
Versioning an ASP.NET Core API - Meziantou's blog
Once you have published a version of your API, you cannot change the format of the data it sends to the clients. Adding...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found