This is an automated email from the ASF dual-hosted git repository. gjm pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/bloodhound-core.git
The following commit(s) were added to refs/heads/main by this push: new a840d8e Change over to poetry; fix swagger; update README a840d8e is described below commit a840d8e1b6ca3d417428f1aeb45a01f83eebb769 Author: Gary Martin <g...@apache.org> AuthorDate: Mon May 10 01:24:47 2021 +0100 Change over to poetry; fix swagger; update README The old swagger was not working so switched to drf_yasg for now. * Swapped to poetry from pipenv * Old swagger was not working so switched to drf_yasg as a quick fix ahead of deciding how to continue * Updated README.md to reflect poetry usage and generally improve the text --- .gitignore | 5 + Pipfile | 16 ---- Pipfile.lock | 267 ---------------------------------------------------- README.md | 166 ++++++++++++++++++++------------ bh_core/settings.py | 2 +- pyproject.toml | 19 ++++ trackers/urls.py | 4 +- trackers/views.py | 14 ++- 8 files changed, 146 insertions(+), 347 deletions(-) diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e0db8ba --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +__pycache__/ +.venv/ +db.sqlite3 +tags +*.log diff --git a/Pipfile b/Pipfile deleted file mode 100644 index 114750c..0000000 --- a/Pipfile +++ /dev/null @@ -1,16 +0,0 @@ -[[source]] -url = "https://pypi.python.org/simple" -verify_ssl = true -name = "pypi" - -[dev-packages] -selenium = "*" -pytest-django = "*" -PyYAML = "*" - -[packages] -django = ">=2.0.0" -djangorestframework = "*" -django-rest-swagger = "*" - -[requires] diff --git a/Pipfile.lock b/Pipfile.lock deleted file mode 100644 index 4929a85..0000000 --- a/Pipfile.lock +++ /dev/null @@ -1,267 +0,0 @@ -{ - "_meta": { - "hash": { - "sha256": "32e23ea6222c95881c6e0ea71ead44b51d710f950c012a4c125dec779388bf69" - }, - "pipfile-spec": 6, - "requires": {}, - "sources": [ - { - "name": "pypi", - "url": "https://pypi.python.org/simple", - "verify_ssl": true - } - ] - }, - "default": { - "certifi": { - "hashes": [ - "sha256:47f9c83ef4c0c621eaef743f133f09fa8a74a9b75f037e8624f83bd1b6626cb7", - "sha256:993f830721089fef441cdfeb4b2c8c9df86f0c63239f06bd025a76a7daddb033" - ], - "version": "==2018.11.29" - }, - "chardet": { - "hashes": [ - "sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae", - "sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691" - ], - "version": "==3.0.4" - }, - "coreapi": { - "hashes": [ - "sha256:46145fcc1f7017c076a2ef684969b641d18a2991051fddec9458ad3f78ffc1cb", - "sha256:bf39d118d6d3e171f10df9ede5666f63ad80bba9a29a8ec17726a66cf52ee6f3" - ], - "version": "==2.3.3" - }, - "coreschema": { - "hashes": [ - "sha256:5e6ef7bf38c1525d5e55a895934ab4273548629f16aed5c0a6caa74ebf45551f", - "sha256:9503506007d482ab0867ba14724b93c18a33b22b6d19fb419ef2d239dd4a1607" - ], - "version": "==0.0.4" - }, - "django": { - "hashes": [ - "sha256:275bec66fd2588dd517ada59b8bfb23d4a9abc5a362349139ddda3c7ff6f5ade", - "sha256:939652e9d34d7d53d74d5d8ef82a19e5f8bb2de75618f7e5360691b6e9667963" - ], - "index": "pypi", - "version": "==2.1.7" - }, - "django-rest-swagger": { - "hashes": [ - "sha256:48f6aded9937e90ae7cbe9e6c932b9744b8af80cc4e010088b3278c700e0685b", - "sha256:b039b0288bab4665cd45dc5d16f94b13911bc4ad0ed55f74ad3b90aa31c87c17" - ], - "index": "pypi", - "version": "==2.2.0" - }, - "djangorestframework": { - "hashes": [ - "sha256:79c6efbb2514bc50cf25906d7c0a5cfead714c7af667ff4bd110312cd380ae66", - "sha256:a4138613b67e3a223be6c97f53b13d759c5b90d2b433bad670b8ebf95402075f" - ], - "index": "pypi", - "version": "==3.9.1" - }, - "idna": { - "hashes": [ - "sha256:c357b3f628cf53ae2c4c05627ecc484553142ca23264e593d327bcde5e9c3407", - "sha256:ea8b7f6188e6fa117537c3df7da9fc686d485087abf6ac197f9c46432f7e4a3c" - ], - "version": "==2.8" - }, - "itypes": { - "hashes": [ - "sha256:c6e77bb9fd68a4bfeb9d958fea421802282451a25bac4913ec94db82a899c073" - ], - "version": "==1.1.0" - }, - "jinja2": { - "hashes": [ - "sha256:74c935a1b8bb9a3947c50a54766a969d4846290e1e788ea44c1392163723c3bd", - "sha256:f84be1bb0040caca4cea721fcbbbbd61f9be9464ca236387158b0feea01914a4" - ], - "version": "==2.10" - }, - "markupsafe": { - "hashes": [ - "sha256:048ef924c1623740e70204aa7143ec592504045ae4429b59c30054cb31e3c432", - "sha256:130f844e7f5bdd8e9f3f42e7102ef1d49b2e6fdf0d7526df3f87281a532d8c8b", - "sha256:19f637c2ac5ae9da8bfd98cef74d64b7e1bb8a63038a3505cd182c3fac5eb4d9", - "sha256:1b8a7a87ad1b92bd887568ce54b23565f3fd7018c4180136e1cf412b405a47af", - "sha256:1c25694ca680b6919de53a4bb3bdd0602beafc63ff001fea2f2fc16ec3a11834", - "sha256:1f19ef5d3908110e1e891deefb5586aae1b49a7440db952454b4e281b41620cd", - "sha256:1fa6058938190ebe8290e5cae6c351e14e7bb44505c4a7624555ce57fbbeba0d", - "sha256:31cbb1359e8c25f9f48e156e59e2eaad51cd5242c05ed18a8de6dbe85184e4b7", - "sha256:3e835d8841ae7863f64e40e19477f7eb398674da6a47f09871673742531e6f4b", - "sha256:4e97332c9ce444b0c2c38dd22ddc61c743eb208d916e4265a2a3b575bdccb1d3", - "sha256:525396ee324ee2da82919f2ee9c9e73b012f23e7640131dd1b53a90206a0f09c", - "sha256:52b07fbc32032c21ad4ab060fec137b76eb804c4b9a1c7c7dc562549306afad2", - "sha256:52ccb45e77a1085ec5461cde794e1aa037df79f473cbc69b974e73940655c8d7", - "sha256:5c3fbebd7de20ce93103cb3183b47671f2885307df4a17a0ad56a1dd51273d36", - "sha256:5e5851969aea17660e55f6a3be00037a25b96a9b44d2083651812c99d53b14d1", - "sha256:5edfa27b2d3eefa2210fb2f5d539fbed81722b49f083b2c6566455eb7422fd7e", - "sha256:7d263e5770efddf465a9e31b78362d84d015cc894ca2c131901a4445eaa61ee1", - "sha256:83381342bfc22b3c8c06f2dd93a505413888694302de25add756254beee8449c", - "sha256:857eebb2c1dc60e4219ec8e98dfa19553dae33608237e107db9c6078b1167856", - "sha256:98e439297f78fca3a6169fd330fbe88d78b3bb72f967ad9961bcac0d7fdd1550", - "sha256:bf54103892a83c64db58125b3f2a43df6d2cb2d28889f14c78519394feb41492", - "sha256:d9ac82be533394d341b41d78aca7ed0e0f4ba5a2231602e2f05aa87f25c51672", - "sha256:e982fe07ede9fada6ff6705af70514a52beb1b2c3d25d4e873e82114cf3c5401", - "sha256:edce2ea7f3dfc981c4ddc97add8a61381d9642dc3273737e756517cc03e84dd6", - "sha256:efdc45ef1afc238db84cb4963aa689c0408912a0239b0721cb172b4016eb31d6", - "sha256:f137c02498f8b935892d5c0172560d7ab54bc45039de8805075e19079c639a9c", - "sha256:f82e347a72f955b7017a39708a3667f106e6ad4d10b25f237396a7115d8ed5fd", - "sha256:fb7c206e01ad85ce57feeaaa0bf784b97fa3cad0d4a5737bc5295785f5c613a1" - ], - "version": "==1.1.0" - }, - "openapi-codec": { - "hashes": [ - "sha256:1bce63289edf53c601ea3683120641407ff6b708803b8954c8a876fe778d2145" - ], - "version": "==1.3.2" - }, - "pytz": { - "hashes": [ - "sha256:32b0891edff07e28efe91284ed9c31e123d84bea3fd98e1f72be2508f43ef8d9", - "sha256:d5f05e487007e29e03409f9398d074e158d920d36eb82eaf66fb1136b0c5374c" - ], - "version": "==2018.9" - }, - "requests": { - "hashes": [ - "sha256:502a824f31acdacb3a35b6690b5fbf0bc41d63a24a45c4004352b0242707598e", - "sha256:7bf2a778576d825600030a110f3c0e3e8edc51dfaafe1c146e39a2027784957b" - ], - "version": "==2.21.0" - }, - "simplejson": { - "hashes": [ - "sha256:067a7177ddfa32e1483ba5169ebea1bc2ea27f224853211ca669325648ca5642", - "sha256:2fc546e6af49fb45b93bbe878dea4c48edc34083729c0abd09981fe55bdf7f91", - "sha256:354fa32b02885e6dae925f1b5bbf842c333c1e11ea5453ddd67309dc31fdb40a", - "sha256:37e685986cf6f8144607f90340cff72d36acf654f3653a6c47b84c5c38d00df7", - "sha256:3af610ee72efbe644e19d5eaad575c73fb83026192114e5f6719f4901097fce2", - "sha256:3b919fc9cf508f13b929a9b274c40786036b31ad28657819b3b9ba44ba651f50", - "sha256:3dd289368bbd064974d9a5961101f080e939cbe051e6689a193c99fb6e9ac89b", - "sha256:6c3258ffff58712818a233b9737fe4be943d306c40cf63d14ddc82ba563f483a", - "sha256:75e3f0b12c28945c08f54350d91e624f8dd580ab74fd4f1bbea54bc6b0165610", - "sha256:b1f329139ba647a9548aa05fb95d046b4a677643070dc2afc05fa2e975d09ca5", - "sha256:ee9625fc8ee164902dfbb0ff932b26df112da9f871c32f0f9c1bcf20c350fe2a", - "sha256:fb2530b53c28f0d4d84990e945c2ebb470edb469d63e389bf02ff409012fe7c5" - ], - "version": "==3.16.0" - }, - "uritemplate": { - "hashes": [ - "sha256:01c69f4fe8ed503b2951bef85d996a9d22434d2431584b5b107b2981ff416fbd", - "sha256:1b9c467a940ce9fb9f50df819e8ddd14696f89b9a8cc87ac77952ba416e0a8fd", - "sha256:c02643cebe23fc8adb5e6becffe201185bf06c40bda5c0b4028a93f1527d011d" - ], - "version": "==3.0.0" - }, - "urllib3": { - "hashes": [ - "sha256:61bf29cada3fc2fbefad4fdf059ea4bd1b4a86d2b6d15e1c7c0b582b9752fe39", - "sha256:de9529817c93f27c8ccbfead6985011db27bd0ddfcdb2d86f3f663385c6a9c22" - ], - "version": "==1.24.1" - } - }, - "develop": { - "atomicwrites": { - "hashes": [ - "sha256:03472c30eb2c5d1ba9227e4c2ca66ab8287fbfbbda3888aa93dc2e28fc6811b4", - "sha256:75a9445bac02d8d058d5e1fe689654ba5a6556a1dfd8ce6ec55a0ed79866cfa6" - ], - "version": "==1.3.0" - }, - "attrs": { - "hashes": [ - "sha256:10cbf6e27dbce8c30807caf056c8eb50917e0eaafe86347671b57254006c3e69", - "sha256:ca4be454458f9dec299268d472aaa5a11f67a4ff70093396e1ceae9c76cf4bbb" - ], - "version": "==18.2.0" - }, - "more-itertools": { - "hashes": [ - "sha256:0125e8f60e9e031347105eb1682cef932f5e97d7b9a1a28d9bf00c22a5daef40", - "sha256:590044e3942351a1bdb1de960b739ff4ce277960f2425ad4509446dbace8d9d1" - ], - "markers": "python_version > '2.7'", - "version": "==6.0.0" - }, - "pluggy": { - "hashes": [ - "sha256:8ddc32f03971bfdf900a81961a48ccf2fb677cf7715108f85295c67405798616", - "sha256:980710797ff6a041e9a73a5787804f848996ecaa6f8a1b1e08224a5894f2074a" - ], - "version": "==0.8.1" - }, - "py": { - "hashes": [ - "sha256:bf92637198836372b520efcba9e020c330123be8ce527e535d185ed4b6f45694", - "sha256:e76826342cefe3c3d5f7e8ee4316b80d1dd8a300781612ddbc765c17ba25a6c6" - ], - "version": "==1.7.0" - }, - "pytest": { - "hashes": [ - "sha256:80cfd9c8b9e93f419abcc0400e9f595974a98e44b6863a77d3e1039961bfc9c4", - "sha256:c2396a15726218a2dfef480861c4ba37bd3952ebaaa5b0fede3fc23fddcd7f8c" - ], - "version": "==4.2.1" - }, - "pytest-django": { - "hashes": [ - "sha256:3d489db7c9bd18d7c154347b1bdfb82cc6b1ec8539543508b199c77e5eb2caec", - "sha256:87c31e53ad09ca4f061b82a9d71ad1e3e399c7a5ec9d28f7c3c38a9a9afbd027" - ], - "index": "pypi", - "version": "==3.4.7" - }, - "pyyaml": { - "hashes": [ - "sha256:3d7da3009c0f3e783b2c873687652d83b1bbfd5c88e9813fb7e5b03c0dd3108b", - "sha256:3ef3092145e9b70e3ddd2c7ad59bdd0252a94dfe3949721633e41344de00a6bf", - "sha256:40c71b8e076d0550b2e6380bada1f1cd1017b882f7e16f09a65be98e017f211a", - "sha256:558dd60b890ba8fd982e05941927a3911dc409a63dcb8b634feaa0cda69330d3", - "sha256:a7c28b45d9f99102fa092bb213aa12e0aaf9a6a1f5e395d36166639c1f96c3a1", - "sha256:aa7dd4a6a427aed7df6fb7f08a580d68d9b118d90310374716ae90b710280af1", - "sha256:bc558586e6045763782014934bfaf39d48b8ae85a2713117d16c39864085c613", - "sha256:d46d7982b62e0729ad0175a9bc7e10a566fc07b224d2c79fafb5e032727eaa04", - "sha256:d5eef459e30b09f5a098b9cea68bebfeb268697f78d647bd255a085371ac7f3f", - "sha256:e01d3203230e1786cd91ccfdc8f8454c8069c91bee3962ad93b87a4b2860f537", - "sha256:e170a9e6fcfd19021dd29845af83bb79236068bf5fd4df3327c1be18182b2531" - ], - "index": "pypi", - "version": "==3.13" - }, - "selenium": { - "hashes": [ - "sha256:2d7131d7bc5a5b99a2d9b04aaf2612c411b03b8ca1b1ee8d3de5845a9be2cb3c", - "sha256:deaf32b60ad91a4611b98d8002757f29e6f2c2d5fcaf202e1c9ad06d6772300d" - ], - "index": "pypi", - "version": "==3.141.0" - }, - "six": { - "hashes": [ - "sha256:3350809f0555b11f552448330d0b52d5f24c91a322ea4a15ef22629740f3761c", - "sha256:d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73" - ], - "version": "==1.12.0" - }, - "urllib3": { - "hashes": [ - "sha256:61bf29cada3fc2fbefad4fdf059ea4bd1b4a86d2b6d15e1c7c0b582b9752fe39", - "sha256:de9529817c93f27c8ccbfead6985011db27bd0ddfcdb2d86f3f663385c6a9c22" - ], - "version": "==1.24.1" - } - } -} diff --git a/README.md b/README.md index ee10622..58c10d0 100644 --- a/README.md +++ b/README.md @@ -2,79 +2,130 @@ ## Getting the Bloodhound Code: -There is a reasonable chance that you are reading these instructions from a -copy of the source code that you have already placed on the computer that you -wish to install on. If this is the case you can skip on to the next section. +Note that this document describes a new Apache Bloodhound project that is +intending to replace the Trac-based version. If you are interested in that +version, the appropriate code is available from [here][Legacy Repo]. -While in early development, the alternatives for getting the code include -checking out from [Subversion] with the following command: +The new version of Apache Bloodhound is in the bloodhound-core git repository +which is mirrored on Github [here][Github Mirror]. + +If you have not already got the code, you can clone the repo with the +following command: ``` -svn checkout https://svn.apache.org/repos/asf/bloodhound/branches/bh_core_experimental/ bloodhound +git clone https://github.com/apache/bloodhound-core.git ``` -or cloning with [Git] from the [Apache Bloodhound Github mirror] - the command -below should also check out the appropriate branch: +which will put the code in the `bloodhound-core` directory. + +[Legacy Repo]: https://svn.apache.org/repos/asf/bloodhound/ +[Github Mirror]: https://github.com/apache/bloodhound-core + +## Prerequisites + +This version of Apache Bloodhound requires Python, Poetry and Django. + +### Installing Python + +The versions of Python that can be used are currently 3.6, 3.7, 3.8 and 3.9. + +Where convenient is it sensible to go for the newest release of Python that +you can. + +Modern Linux and BSD distrubutions will have new enough Python 3 packages in +their repos and are often already installed if it is not a minimal +installation. For these cases it will usually be sensible to take advantage of +this. + +If this is not the case, you can look for advice from: + + * [The Hitchiker's Guide to Python][Python Guide] for their install guides on + Mac OS X, Windows and Linux. + * The official Python documentation on [Setup and Usage][Python Usage] which + includes information for installing on more Unix platforms, Windows and Mac. + +[Python Guide]: https://docs.python-guide.org/ +[Python Usage]: https://docs.python.org/3/using/ + +### Installing Poetry + +The project now uses [Poetry][Poetry] for python environment management and +looking after further dependencies. + +If you are installing on linux, it is possible that poetry is installable from +the repositories for your distro. For example, on recent Fedora releases, the +following should work: ``` -git clone --branch bh_core_experimental https://github.com/apache/bloodhound.git +sudo dnf install poetry ``` -With the commands as specified, both will place the code in the `bloodhound` -directory. - -[Subversion]: https://subversion.apache.org/ -[Git]: https://git-scm.com/ -[Apache Bloodhound mirror]: https://github.com/apache/bloodhound -[Github]: https://github.com/ +For anywhere else you can consider following the instructions from the +[Poetry documentation][Poetry Docs]. -## Installing Python and Pipenv +Once installed, optionally you can pre-configure poetry to make it use a +`.venv` directory at the root of poetry projects. This can be helpful as it +makes this easier to find and removal of your copy of the git repo will also +clean up these files. If this seems useful: -Bloodhound core is currently written in [Python 3] and uses [Pipenv] for -looking after the python based dependencies. +``` +poetry config virtualenvs.in-project true +``` -It should be possible to install and run the core successfully with Python 3.6 -or newer. You may find that versions from Python 3.4 work but this is not -currently tested and it is possible that Python features from newer versions -may sneak in. +As Poetry creates and manages python virtual environments (virtualenv) for you, +it is useful to be aware of how they are used. For convenience, throughout this +document, any command that requires the virtualenv to be 'active' will be +provided with `poetry run` before the command. While this may get old, it is +effectively robust as it should work without having to remind you all the time +to be sure the virtualenv is activated. -The guide at <https://docs.python-guide.org/> gives good instructions for -installing Python on [Linux][Python on Linux], [MacOS][Python on MacOS] and -[Windows][Python on Windows]. +For a little more completeness, the following lists the options along with +example sessions, each including a command to demonstrate exiting the +virtualenv if applicable: -Further information about pipenv is available at <https://docs.pipenv.org/>. + * prefix commands that require the virtualenv with `poetry run`: + ``` + poetry run python --version + poetry run django-admin help + ``` + * start the `poetry shell`: + ``` + poetry shell + python --version + django-admin help + exit + ``` + * activate the virtualenv manually (example for bash and assumes the + suggested `virtualenvs.in-project` option was set: + ``` + source .venv/bin/activate + python --version + django-admin help + deactivate + ``` -[Python 3]: https://docs.python.org/3/ -[Pipenv]: https://pipenv.readthedocs.io/en/latest/ -[Python on Linux]: https://docs.python-guide.org/starting/install3/linux/#install3-linux -[Python on MacOS]: https://docs.python-guide.org/starting/install3/osx/#install3-osx -[Python on Windows]: https://docs.python-guide.org/starting/install3/win/#install3-windows +[Poetry]: https://python-poetry.org/ +[Poetry Docs]: https://python-poetry.org/docs/ ## Preparing the Python environment -It should now be possible to use pipenv to install the rest of the project -dependencies and bloodhound itself. Note that the exactly required command may -depend on details like whether you have multiple versions of python available -but for most cases, the following should work. If in doubt, just be more -specific about the python version that you intend to use. +It should now be possible to use poetry to install the rest of the project +dependencies. -For the same directory as the `Pipfile` for the project run: +From the root of the project folder (probably `bloodhound-core` if the above +instructions have been followed) run: ``` -pipenv --python 3 install +poetry install ``` ## Setup -Although it will make the commands more verbose, where a command requires -the pipenv environment that has been created, we will use the `pipenv run` -command in preference to requiring that the environment is 'activated'. - The basic setup steps to get running are: ``` -pipenv run python manage.py makemigrations trackers -pipenv run python manage.py migrate +poetry run python manage.py makemigrations trackers +poetry run python manage.py migrate ``` The above will do the basic database setup. @@ -90,7 +141,7 @@ work with. There are a few ways to add a superuser. For interactive use, the `createsuperuser` action is usually straightforward enough: ``` -pipenv run python manage.py createsuperuser --email ad...@example.com --username admin +poetry run python manage.py createsuperuser --email ad...@example.com --username admin ``` Entering the password twice on prompting is currently required. If the options @@ -100,7 +151,7 @@ details first. ## Running the development server: ``` -pipenv run python manage.py runserver +poetry run python manage.py runserver ``` Amongst the initial output of that command will be something like: @@ -114,7 +165,8 @@ Currently there is not much to see at the specified location. More work has been done on the core API. The following views may be of interest as you explore: - * http://127.0.0.1:8000/schema_view/ + * http://127.0.0.1:8000/swagger/ + * http://127.0.0.1:8000/redoc/ * http://127.0.0.1:8000/api/ These paths are subject to change. @@ -124,22 +176,18 @@ These paths are subject to change. Unit tests are currently being written with the standard unittest framework. This may be replaced with pytest. -Running the tests require a little extra setup: +Unit tests are run with the following command: ``` -pipenv install --dev -``` - -after which the tests may be run with the following command: - -``` -pipenv run python manage.py test +poetry run python manage.py test ``` ## Integration Tests The [Selenium] tests currently require that Firefox is installed and -[geckodriver] is also on the path. If you +[geckodriver] is also on the path. If you do not already have geckodriver, +the following shows one method to get it for linux: + ``` PLATFORM_EXT="linux64.tar.gz" BIN_LOCATION="$HOME/.local/bin" @@ -156,7 +204,7 @@ If `$BIN_LOCATION` is on the system path, and the development server is running, it should be possible to run the integration tests. ``` -pipenv run python functional_tests.py +poetry run python functional_tests.py ``` There are currently not many tests - those that are there are in place to test @@ -170,5 +218,5 @@ the setup above and assume that there will be useful tests in due course. Fixtures for tests when required can be generated with: ``` -pipenv run python manage.py dumpdata trackers --format=yaml --indent=2 > trackers/fixtures/[fixture-name].yaml +poetry run python manage.py dumpdata trackers --format=yaml --indent=2 > trackers/fixtures/[fixture-name].yaml ``` diff --git a/bh_core/settings.py b/bh_core/settings.py index 67148b7..f0db01a 100644 --- a/bh_core/settings.py +++ b/bh_core/settings.py @@ -60,7 +60,7 @@ INSTALLED_APPS = [ 'django.contrib.messages', 'django.contrib.staticfiles', 'rest_framework', - 'rest_framework_swagger', + 'drf_yasg', ] MIDDLEWARE = [ diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..c0671f9 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,19 @@ +[tool.poetry] +name = "bloodhound-core" +version = "0.1.0" +description = "Apache Bloodhound Issue Tracker core functionality" +authors = ["Apache Bloodhound <d...@bloodhound.apache.org>"] +license = "Apache-2.0" + +[tool.poetry.dependencies] +python = "^3.6" +django = "^3.2.2" +django-rest-framework = "^0.1.0" +drf-yasg = "^1.20.0" + +[tool.poetry.dev-dependencies] +selenium = "^3.141.0" + +[build-system] +requires = ["poetry>=0.12"] +build-backend = "poetry.masonry.api" diff --git a/trackers/urls.py b/trackers/urls.py index bebc31c..ffcc408 100644 --- a/trackers/urls.py +++ b/trackers/urls.py @@ -33,5 +33,7 @@ urlpatterns = [ path('', views.home, name='home'), path('api/', include(router.urls)), path('api/tickets/<uuid:id>/', include(ticket_router.urls)), - path('schema_view/', views.schema_view), + path('swagger<str:format>', views.schema_view.without_ui(cache_timeout=0), name='schema-json'), + path('swagger/', views.schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'), + path('redoc/', views.schema_view.with_ui('redoc', cache_timeout=0), name='schema-redoc'), ] diff --git a/trackers/views.py b/trackers/views.py index 03559b8..f1a6999 100644 --- a/trackers/views.py +++ b/trackers/views.py @@ -17,13 +17,21 @@ from django.contrib.auth.models import User, Group from django.http import HttpResponse -from rest_framework import viewsets +from drf_yasg.views import get_schema_view +from drf_yasg import openapi +from rest_framework import permissions, viewsets from . import serializers from . import models -from rest_framework_swagger.views import get_swagger_view -schema_view = get_swagger_view(title='Bloodhound Core API') +schema_view = get_schema_view( + openapi.Info( + title='Bloodhound Core API', + default_version='v1', + ), + public=True, + permission_classes=(permissions.AllowAny,), +) def home(request):