DeanWay / fastapi-versioning

api versioning for fastapi web applications
MIT License
642 stars 63 forks source link

Add option to deprecate paths #75

Open vagosduke opened 1 year ago

vagosduke commented 1 year ago

Is your feature request related to a problem? Please describe. Once defined, all paths are added to the api version they are linked with, and all the following versions after that. It would be beneficial to be able to deprecate paths

A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like A deprecate_in= option in the @version decorator could cause certain viewfunctions to stop being added to the API paths after a certain version.

An example would be the following

@app.get('/greet')
@version(1)
def greet():
  return 'Hello'

@app.get('/greet')
@version(2, deprecate_in=3)
def greet():
  return 'Hi'

@app.get('/new-greet')
@version(3)
def new_greet():
  return 'This is a different greetings function linked to a different url'

This would result in the following endpoints:

/v1/greet
/v2/greet
/v3/new-greet

(Now, the normal behaviour without deprecate_in is that in v3, both the /v3/new-greet and /v3/greet paths would be available)


I have implemented the solution, but I cannot push it. Can I be given access?

crashCoder commented 1 year ago

Hi, @vagosduke sadly this repo was abandoned a long time ago, you can look at all the opened issues. But thanks to @alexs there is a fork that contains fixes and improvements.

You can read more here: https://github.com/DeanWay/fastapi-versioning/issues/65#issuecomment-1363796400

Hope it helps