-
Notifications
You must be signed in to change notification settings - Fork 711
deprecated property on operations in swagger.json #441
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
Comments
Hi, I'm kind of new to versioning and swagger. Regards |
There is no direct relationship or dependencies between API versioning and Swagger. The provided API Explorer can tell you whether a specific action is deprecated for a particular API version or whether the entire API version is deprecated (e.g. for a given API version, all containing actions are deprecated). If you want a specific operation in Swagger to be marked as deprecated, it would be your responsibly to indicate that in your Swagger generator of choice (ex: Swashbuckle, NSwag, etc). API Versioning provides you with the necessary information to determine whether said API is deprecated, but it's up to you to take advantage of that information. The API Explorer can be used for other scenarios besides Swagger generation. The exact method in which you tie the two together depends on which Swagger generator you are using. I hope that helps clear things up. |
Thanks for answering me so quickly, really appreciate it. Regards |
Correct. This is because:
While it's totally convenient for the two to marry up, it doesn't really make sense for either side to take a hard dependency on the other. The most ideal situation would be for someone in the community (wink, wink) to create a new package that did this pairing. Although I don't plan to support directly wiring up Swagger information, I have absolutely no problems providing samples as to how it can/should be done. There was no existing reason that couldn't have been done today, I just hadn't done it (and I'm not exactly a Swagger expert). You didn't indicate which platform you're using, but I've updated all of the Swagger examples to set the deprecated member of the Swagger operation. In updating the samples, I realized it's more difficult to set things up than it should be. Specifically, although you can determine if an action is deprecated, it's not necessarily easy to understand how to get the necessary information. I've gone ahead and submitted a PR that will add an IsDeprecated extension method to make this simpler. I likely won't ship this until the next patch though. Once I ship a new package version, I'll update the examples. In the meantime, you can use code provided in the examples. The extension methods are ultimately going to do the exact same thing. I hope that helps. |
It makes completely sense. I'm not sure what the package you are mentioning should do beside wiring the deprecated property to the api one. I don't know too much about swagger. I'll investigate more. Thank you |
Your 100% correct - there's isn't very much required to connect the two. The biggest barrier is the dependency coupling. Unless the intrinsic interfaces for the API Explorer provided by ASP.NET define a facility to mark an API description as deprecated, there isn't a way to tie the two packages and libraries together. The simplest solution is a new library and package that can do this. I already manage 8 libraries and packages related to API versioning. I also run this project almost entirely by myself. I simply don't have the capacity to take on more. My solution has currently just been to show how the pieces connect in the examples. Perhaps one of the Swagger generator libraries, like Swashbuckle, would define some type of hook to test if an API description is deprecated using some type of callback function. This is how API versions were paired back in Web API. I not sure where it would be setup, maybe in the options? Something like: |
Yeah, that'd be a good option. |
Looks like you're on your way. Come back if you have more questions. Keep an eye out for the new extension method (shortcut) in the next patch. ;) Thanks! |
yes, thank you, the default value linked to the api.deprecated did the trick. Thank you! |
FYI, versions 3.1.0 (Web API) and 3.2.0 (Core) of the API Explorer have been published which now contain the |
That's great. |
No description provided.
The text was updated successfully, but these errors were encountered: