summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCoprDistGit <infra@openeuler.org>2023-04-11 10:59:29 +0000
committerCoprDistGit <infra@openeuler.org>2023-04-11 10:59:29 +0000
commitd0b07e76ecc49bdc0f43eae5261c17a27a0d5e80 (patch)
tree0f97afe18a9709cd763e5ee01fc1e9d28d0e5925
parent03c1afb4d9838c4a7b606a434743d3b89da1f644 (diff)
automatic import of python-fastapi-versioning
-rw-r--r--.gitignore1
-rw-r--r--python-fastapi-versioning.spec530
-rw-r--r--sources1
3 files changed, 532 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index e69de29..bb2f951 100644
--- a/.gitignore
+++ b/.gitignore
@@ -0,0 +1 @@
+/fastapi_versioning-0.10.0.tar.gz
diff --git a/python-fastapi-versioning.spec b/python-fastapi-versioning.spec
new file mode 100644
index 0000000..2a18b46
--- /dev/null
+++ b/python-fastapi-versioning.spec
@@ -0,0 +1,530 @@
+%global _empty_manifest_terminate_build 0
+Name: python-fastapi-versioning
+Version: 0.10.0
+Release: 1
+Summary: api versioning for fastapi web applications
+License: MIT License
+URL: https://github.com/DeanWay/fastapi-versioning
+Source0: https://mirrors.nju.edu.cn/pypi/web/packages/e0/d9/0e81a2680c960b84b3f5b8c434259ad5f7731737be27b5bee0cb6d7b796f/fastapi_versioning-0.10.0.tar.gz
+BuildArch: noarch
+
+Requires: python3-fastapi
+Requires: python3-starlette
+
+%description
+# fastapi-versioning
+api versioning for fastapi web applications
+
+# Installation
+
+`pip install fastapi-versioning`
+
+## Examples
+```python
+from fastapi import FastAPI
+from fastapi_versioning import VersionedFastAPI, version
+
+app = FastAPI(title="My App")
+
+
+@app.get("/greet")
+@version(1, 0)
+def greet_with_hello():
+ return "Hello"
+
+
+@app.get("/greet")
+@version(1, 1)
+def greet_with_hi():
+ return "Hi"
+
+
+app = VersionedFastAPI(app)
+```
+
+this will generate two endpoints:
+```
+/v1_0/greet
+/v1_1/greet
+```
+as well as:
+```
+/docs
+/v1_0/docs
+/v1_1/docs
+/v1_0/openapi.json
+/v1_1/openapi.json
+```
+
+There's also the possibility of adding a set of additional endpoints that
+redirect the most recent API version. To do that make the argument
+`enable_latest` true:
+
+```python
+app = VersionedFastAPI(app, enable_latest=True)
+```
+
+this will generate the following additional endpoints:
+```
+/latest/greet
+/latest/docs
+/latest/openapi.json
+```
+In this example, `/latest` endpoints will reflect the same data as `/v1.1`.
+
+Try it out:
+```sh
+pip install pipenv
+pipenv install --dev
+pipenv run uvicorn example.annotation.app:app
+# pipenv run uvicorn example.folder_name.app:app
+```
+
+## Usage without minor version
+```python
+from fastapi import FastAPI
+from fastapi_versioning import VersionedFastAPI, version
+
+app = FastAPI(title='My App')
+
+@app.get('/greet')
+@version(1)
+def greet():
+ return 'Hello'
+
+@app.get('/greet')
+@version(2)
+def greet():
+ return 'Hi'
+
+app = VersionedFastAPI(app,
+ version_format='{major}',
+ prefix_format='/v{major}')
+```
+
+this will generate two endpoints:
+```
+/v1/greet
+/v2/greet
+```
+as well as:
+```
+/docs
+/v1/docs
+/v2/docs
+/v1/openapi.json
+/v2/openapi.json
+```
+
+## Extra FastAPI constructor arguments
+
+It's important to note that only the `title` from the original FastAPI will be
+provided to the VersionedAPI app. If you have any middleware, event handlers
+etc these arguments will also need to be provided to the VersionedAPI function
+call, as in the example below
+
+```python
+from fastapi import FastAPI, Request
+from fastapi_versioning import VersionedFastAPI, version
+from starlette.middleware import Middleware
+from starlette.middleware.sessions import SessionMiddleware
+
+app = FastAPI(
+ title='My App',
+ description='Greet uses with a nice message',
+ middleware=[
+ Middleware(SessionMiddleware, secret_key='mysecretkey')
+ ]
+)
+
+@app.get('/greet')
+@version(1)
+def greet(request: Request):
+ request.session['last_version_used'] = 1
+ return 'Hello'
+
+@app.get('/greet')
+@version(2)
+def greet(request: Request):
+ request.session['last_version_used'] = 2
+ return 'Hi'
+
+@app.get('/version')
+def last_version(request: Request):
+ return f'Your last greeting was sent from version {request.session["last_version_used"]}'
+
+app = VersionedFastAPI(app,
+ version_format='{major}',
+ prefix_format='/v{major}',
+ description='Greet users with a nice message',
+ middleware=[
+ Middleware(SessionMiddleware, secret_key='mysecretkey')
+ ]
+)
+```
+
+
+
+
+%package -n python3-fastapi-versioning
+Summary: api versioning for fastapi web applications
+Provides: python-fastapi-versioning
+BuildRequires: python3-devel
+BuildRequires: python3-setuptools
+BuildRequires: python3-pip
+%description -n python3-fastapi-versioning
+# fastapi-versioning
+api versioning for fastapi web applications
+
+# Installation
+
+`pip install fastapi-versioning`
+
+## Examples
+```python
+from fastapi import FastAPI
+from fastapi_versioning import VersionedFastAPI, version
+
+app = FastAPI(title="My App")
+
+
+@app.get("/greet")
+@version(1, 0)
+def greet_with_hello():
+ return "Hello"
+
+
+@app.get("/greet")
+@version(1, 1)
+def greet_with_hi():
+ return "Hi"
+
+
+app = VersionedFastAPI(app)
+```
+
+this will generate two endpoints:
+```
+/v1_0/greet
+/v1_1/greet
+```
+as well as:
+```
+/docs
+/v1_0/docs
+/v1_1/docs
+/v1_0/openapi.json
+/v1_1/openapi.json
+```
+
+There's also the possibility of adding a set of additional endpoints that
+redirect the most recent API version. To do that make the argument
+`enable_latest` true:
+
+```python
+app = VersionedFastAPI(app, enable_latest=True)
+```
+
+this will generate the following additional endpoints:
+```
+/latest/greet
+/latest/docs
+/latest/openapi.json
+```
+In this example, `/latest` endpoints will reflect the same data as `/v1.1`.
+
+Try it out:
+```sh
+pip install pipenv
+pipenv install --dev
+pipenv run uvicorn example.annotation.app:app
+# pipenv run uvicorn example.folder_name.app:app
+```
+
+## Usage without minor version
+```python
+from fastapi import FastAPI
+from fastapi_versioning import VersionedFastAPI, version
+
+app = FastAPI(title='My App')
+
+@app.get('/greet')
+@version(1)
+def greet():
+ return 'Hello'
+
+@app.get('/greet')
+@version(2)
+def greet():
+ return 'Hi'
+
+app = VersionedFastAPI(app,
+ version_format='{major}',
+ prefix_format='/v{major}')
+```
+
+this will generate two endpoints:
+```
+/v1/greet
+/v2/greet
+```
+as well as:
+```
+/docs
+/v1/docs
+/v2/docs
+/v1/openapi.json
+/v2/openapi.json
+```
+
+## Extra FastAPI constructor arguments
+
+It's important to note that only the `title` from the original FastAPI will be
+provided to the VersionedAPI app. If you have any middleware, event handlers
+etc these arguments will also need to be provided to the VersionedAPI function
+call, as in the example below
+
+```python
+from fastapi import FastAPI, Request
+from fastapi_versioning import VersionedFastAPI, version
+from starlette.middleware import Middleware
+from starlette.middleware.sessions import SessionMiddleware
+
+app = FastAPI(
+ title='My App',
+ description='Greet uses with a nice message',
+ middleware=[
+ Middleware(SessionMiddleware, secret_key='mysecretkey')
+ ]
+)
+
+@app.get('/greet')
+@version(1)
+def greet(request: Request):
+ request.session['last_version_used'] = 1
+ return 'Hello'
+
+@app.get('/greet')
+@version(2)
+def greet(request: Request):
+ request.session['last_version_used'] = 2
+ return 'Hi'
+
+@app.get('/version')
+def last_version(request: Request):
+ return f'Your last greeting was sent from version {request.session["last_version_used"]}'
+
+app = VersionedFastAPI(app,
+ version_format='{major}',
+ prefix_format='/v{major}',
+ description='Greet users with a nice message',
+ middleware=[
+ Middleware(SessionMiddleware, secret_key='mysecretkey')
+ ]
+)
+```
+
+
+
+
+%package help
+Summary: Development documents and examples for fastapi-versioning
+Provides: python3-fastapi-versioning-doc
+%description help
+# fastapi-versioning
+api versioning for fastapi web applications
+
+# Installation
+
+`pip install fastapi-versioning`
+
+## Examples
+```python
+from fastapi import FastAPI
+from fastapi_versioning import VersionedFastAPI, version
+
+app = FastAPI(title="My App")
+
+
+@app.get("/greet")
+@version(1, 0)
+def greet_with_hello():
+ return "Hello"
+
+
+@app.get("/greet")
+@version(1, 1)
+def greet_with_hi():
+ return "Hi"
+
+
+app = VersionedFastAPI(app)
+```
+
+this will generate two endpoints:
+```
+/v1_0/greet
+/v1_1/greet
+```
+as well as:
+```
+/docs
+/v1_0/docs
+/v1_1/docs
+/v1_0/openapi.json
+/v1_1/openapi.json
+```
+
+There's also the possibility of adding a set of additional endpoints that
+redirect the most recent API version. To do that make the argument
+`enable_latest` true:
+
+```python
+app = VersionedFastAPI(app, enable_latest=True)
+```
+
+this will generate the following additional endpoints:
+```
+/latest/greet
+/latest/docs
+/latest/openapi.json
+```
+In this example, `/latest` endpoints will reflect the same data as `/v1.1`.
+
+Try it out:
+```sh
+pip install pipenv
+pipenv install --dev
+pipenv run uvicorn example.annotation.app:app
+# pipenv run uvicorn example.folder_name.app:app
+```
+
+## Usage without minor version
+```python
+from fastapi import FastAPI
+from fastapi_versioning import VersionedFastAPI, version
+
+app = FastAPI(title='My App')
+
+@app.get('/greet')
+@version(1)
+def greet():
+ return 'Hello'
+
+@app.get('/greet')
+@version(2)
+def greet():
+ return 'Hi'
+
+app = VersionedFastAPI(app,
+ version_format='{major}',
+ prefix_format='/v{major}')
+```
+
+this will generate two endpoints:
+```
+/v1/greet
+/v2/greet
+```
+as well as:
+```
+/docs
+/v1/docs
+/v2/docs
+/v1/openapi.json
+/v2/openapi.json
+```
+
+## Extra FastAPI constructor arguments
+
+It's important to note that only the `title` from the original FastAPI will be
+provided to the VersionedAPI app. If you have any middleware, event handlers
+etc these arguments will also need to be provided to the VersionedAPI function
+call, as in the example below
+
+```python
+from fastapi import FastAPI, Request
+from fastapi_versioning import VersionedFastAPI, version
+from starlette.middleware import Middleware
+from starlette.middleware.sessions import SessionMiddleware
+
+app = FastAPI(
+ title='My App',
+ description='Greet uses with a nice message',
+ middleware=[
+ Middleware(SessionMiddleware, secret_key='mysecretkey')
+ ]
+)
+
+@app.get('/greet')
+@version(1)
+def greet(request: Request):
+ request.session['last_version_used'] = 1
+ return 'Hello'
+
+@app.get('/greet')
+@version(2)
+def greet(request: Request):
+ request.session['last_version_used'] = 2
+ return 'Hi'
+
+@app.get('/version')
+def last_version(request: Request):
+ return f'Your last greeting was sent from version {request.session["last_version_used"]}'
+
+app = VersionedFastAPI(app,
+ version_format='{major}',
+ prefix_format='/v{major}',
+ description='Greet users with a nice message',
+ middleware=[
+ Middleware(SessionMiddleware, secret_key='mysecretkey')
+ ]
+)
+```
+
+
+
+
+%prep
+%autosetup -n fastapi-versioning-0.10.0
+
+%build
+%py3_build
+
+%install
+%py3_install
+install -d -m755 %{buildroot}/%{_pkgdocdir}
+if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
+if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
+if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
+if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
+pushd %{buildroot}
+if [ -d usr/lib ]; then
+ find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+if [ -d usr/lib64 ]; then
+ find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+if [ -d usr/bin ]; then
+ find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+if [ -d usr/sbin ]; then
+ find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+touch doclist.lst
+if [ -d usr/share/man ]; then
+ find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
+fi
+popd
+mv %{buildroot}/filelist.lst .
+mv %{buildroot}/doclist.lst .
+
+%files -n python3-fastapi-versioning -f filelist.lst
+%dir %{python3_sitelib}/*
+
+%files help -f doclist.lst
+%{_docdir}/*
+
+%changelog
+* Tue Apr 11 2023 Python_Bot <Python_Bot@openeuler.org> - 0.10.0-1
+- Package Spec generated
diff --git a/sources b/sources
new file mode 100644
index 0000000..9f58224
--- /dev/null
+++ b/sources
@@ -0,0 +1 @@
+2477507a049d1c862b4810b3d2bcfa45 fastapi_versioning-0.10.0.tar.gz