Openverse is a search engine for openly-licensed media. This monorepo includes all application code.
Install drf-spectacular (#1876)
Dhruv Bhanushalidf8e5bb69cd1
diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.ymlindex 858b8ed72..130e8ced4 100644--- a/.github/workflows/ci_cd.yml+++ b/.github/workflows/ci_cd.yml@@ -391,11 +391,20 @@ jobs:strategy:fail-fast: falsematrix:- recipe:- - "api/dj check"- - "api/dj validateopenapischema"- - "api/dj makemigrations --check --noinput --merge"- - "api/doc-test"+ name:+ - check_django+ - validate_openapi+ - check_migrations+ - test_doc+ include:+ - name: check_django+ recipe: api/dj check+ - name: validate_openapi+ recipe: api/dj spectacular --format openapi-json --validate --file openapi.json+ - name: check_migrations+ recipe: api/dj makemigrations --check --noinput --merge+ - name: test_doc+ recipe: api/doc-teststeps:- name: Checkout repository@@ -420,12 +429,12 @@ jobs:env:DC_USER: root- - name: Upload schema on failure- if: failure() && contains(matrix.recipe, 'validateopenapischema')+ - name: Upload schema+ if: matrix.name == 'test_doc'uses: actions/upload-artifact@v3with:- name: openverse-api-openapi-schema.yaml- path: ./api/openapi.yaml+ name: openapi.json+ path: ./api/openapi.json# This job runs when `django-checks` doesn't and always passes, thus allowing# PRs to meet the required checks criteria and be merged.@@ -437,11 +446,11 @@ jobs:- get-changesstrategy:matrix:- recipe:- - "api/dj check"- - "api/dj validateopenapischema"- - "api/dj makemigrations --check --noinput --merge"- - "api/doc-test"+ name:+ - check_django+ - validate_openapi+ - check_migrations+ - test_docsteps:- name: Pass@@ -669,7 +678,10 @@ jobs:github.actor != 'dependabot[bot]')) &&- (needs.get-changes.outputs.frontend == 'true' || needs.get-changes.outputs.documentation == 'true') &&+ (+ needs.get-changes.outputs.frontend == 'true' ||+ needs.get-changes.outputs.documentation == 'true'+ ) &&(needs.test-ing.result == 'success' || needs.test-ing.result == 'skipped') &&(needs.test-api.result == 'success' || needs.test-api.result == 'skipped') &&(needs.test-cat.result == 'success' || needs.test-cat.result == 'skipped') &&@@ -885,7 +897,13 @@ jobs:github.event_name == 'push' &&github.repository == 'WordPress/openverse' &&(- ((needs.get-changes.outputs.frontend == 'true' || needs.get-changes.outputs.documentation == 'true') && needs.emit-docs.result != 'success') ||+ (+ (+ needs.get-changes.outputs.frontend == 'true' ||+ needs.get-changes.outputs.documentation == 'true'+ ) &&+ needs.emit-docs.result != 'success'+ ) ||(needs.determine-images.outputs.do_publish == 'true' && needs.publish-images.result != 'success') ||(needs.get-changes.outputs.frontend == 'true' && needs.deploy-frontend.result != 'success') ||(needs.get-changes.outputs.api == 'true' && needs.deploy-api.result != 'success')diff --git a/api/.gitignore b/api/.gitignoreindex 31b999247..9dee4ec61 100644--- a/api/.gitignore+++ b/api/.gitignore@@ -10,3 +10,4 @@ docs/_build/# OpenAPIopenapi.yaml+openapi.jsondiff --git a/api/Pipfile b/api/Pipfileindex 546b18da6..ef252208b 100644--- a/api/Pipfile+++ b/api/Pipfile@@ -5,9 +5,8 @@ verify_ssl = true[dev-packages]factory-boy = "~=3.2"-fakeredis = "~=2.9"+fakeredis = "==2.10.2"ipython = "~=8.12"-openapi-spec-validator = "~=0.5"pycodestyle = "~=2.10"pytest = "~=7.2"pytest-django = "~=4.5"@@ -19,6 +18,7 @@ freezegun = "~=1.2.2"pytest-sugar = "~=0.9"[packages]+aiohttp = "~=3.8"aws-requests-auth = "~=0.4"boto3 = "~=1.26"deepdiff = "~=6.2"@@ -34,7 +34,7 @@ django-storages = "~=1.13"django-tqdm = "~=1.3"django-uuslug = "~=2.0"djangorestframework = "~=3.14"-drf-yasg = "~=1.21"+drf-spectacular = "*"elasticsearch-dsl = "~=7.4"future = "~=0.18"gevent = "~=22.10"@@ -54,7 +54,6 @@ redlock-py = "~=1.0"requests-oauthlib = "~=1.3"sentry-sdk = "~=1.19"wsgi-basic-auth = "~=1.1"-aiohttp = "~=3.8"[requires]python_version = "3.11"diff --git a/api/Pipfile.lock b/api/Pipfile.lockindex 60b94499e..7a39e780d 100644--- a/api/Pipfile.lock+++ b/api/Pipfile.lock@@ -1,7 +1,7 @@{"_meta": {"hash": {- "sha256": "a2623e143c2f53750d3dc858c34ff09c65682ab2c8443a02efafb917ae5a59df"+ "sha256": "38d1a6b01bc9fe451cb6b111f0624901267303590cddb96b4a40621ce7bab643"},"pipfile-spec": 6,"requires": {@@ -151,19 +151,19 @@},"boto3": {"hashes": [- "sha256:2914776e0138530ec6464d0e2f05b4aa18e9212ac920c48472f8a93650feaed2",- "sha256:f4951f8162905b96fd045e32853ba8cf707042faac846a23910817c508ef27d7"+ "sha256:38ca632be379963f2a2749b5f63a81fe1679913b954914f470ad282c77674bbc",+ "sha256:4d575c180312bec6108852bae12e6396b9d1bb404154d652c57ee849c62fbb83"],"index": "pypi",- "version": "==1.26.105"+ "version": "==1.26.122"},"botocore": {"hashes": [- "sha256:4030b2cde8c8c7b58c657c27e5e4ec0edb7a0cab84e31b0fe752dddee2735d68",- "sha256:955c1dd244b6286d9e17dc525d1459a2a74a1c4e519f35006c72f184fbce0760"+ "sha256:9e4984a9e9777c6b949aa1e98323fa35480d9f99d447af7e179ae611f7ed5af9",+ "sha256:c3b41078d235761b9c5dc22f534a76952622ef96787b96bbd10242ec4d73f2a5"],"markers": "python_version >= '3.7'",- "version": "==1.29.121"+ "version": "==1.29.122"},"certifi": {"hashes": [@@ -320,23 +320,9 @@"sha256:f8303414c7b03f794347ad062c0516cee0e15f7a612abd0ce1e25caf6ceb47df","sha256:fca62a8301b605b954ad2e9c3666f9d97f63872aa4efcae5492baca2056b74ab"],- "markers": "python_version >= '3.7'",+ "markers": "python_full_version >= '3.7.0'","version": "==3.1.0"},- "coreapi": {- "hashes": [- "sha256:46145fcc1f7017c076a2ef684969b641d18a2991051fddec9458ad3f78ffc1cb",- "sha256:bf39d118d6d3e171f10df9ede5666f63ad80bba9a29a8ec17726a66cf52ee6f3"- ],- "version": "==2.3.3"- },- "coreschema": {- "hashes": [- "sha256:5e6ef7bf38c1525d5e55a895934ab4273548629f16aed5c0a6caa74ebf45551f",- "sha256:9503506007d482ab0867ba14724b93c18a33b22b6d19fb419ef2d239dd4a1607"- ],- "version": "==0.0.4"- },"cryptography": {"hashes": ["sha256:05dc219433b14046c476f6f09d7636b92a1c3e5808b9a6536adf4932b3b2c440",@@ -480,20 +466,20 @@"index": "pypi","version": "==3.14.0"},- "drf-yasg": {+ "drf-spectacular": {"hashes": [- "sha256:ba9cf4bf79f259290daee9b400fa4fcdb0e78d2f043fa5e9f6589c939fd06d05",- "sha256:ceef0c3b5dc4389781afd786e6dc3697af2a2fe0d8724ee1f637c23d75bbc5b2"+ "sha256:005623d6bb9de37d2d0ec24ccd59c636e4a42f9af252f1470129ac32ccab38cb",+ "sha256:e80eba58d9579bf6c3380ffd6d6a9b466c4bc35b23da0ba76dfcc96de1e907d7"],"index": "pypi",- "version": "==1.21.5"+ "version": "==0.26.2"},"elasticsearch": {"hashes": ["sha256:0e2454645dc00517dee4c6de3863411a9c5f1955d013c5fefa29123dadc92f98","sha256:66c4ece2adfe7cc120e2b6a6798a1fd5c777aecf82eec39bb95cef7cfc7ea2b3"],- "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3' and python_full_version < '4.0.0'",+ "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3' and python_version < '4'","version": "==7.17.9"},"elasticsearch-dsl": {@@ -504,6 +490,14 @@"index": "pypi","version": "==7.4.1"},+ "fakeredis": {+ "hashes": [+ "sha256:6377c27bc557be46089381d43fd670aece46672d091a494f73ab4c96c34022b3",+ "sha256:e2a95fbda7b11188c117d68b0f9eecc00600cb449ccf3362a15fc03cf9e2477d"+ ],+ "index": "pypi",+ "version": "==2.10.2"+ },"frozenlist": {"hashes": ["sha256:008a054b75d77c995ea26629ab3a0c0d7281341f2fa7e1e85fa6153ae29ae99c",@@ -755,21 +749,6 @@"index": "pypi","version": "==1.0.23"},- "itypes": {- "hashes": [- "sha256:03da6872ca89d29aef62773672b2d408f490f80db48b23079a4b194c86dd04c6",- "sha256:af886f129dea4a2a1e3d36595a2d139589e4dd287f5cab0b40e799ee81570ff1"- ],- "version": "==1.2.0"- },- "jinja2": {- "hashes": [- "sha256:31351a702a408a9e7595a8fc6150fc3f43bb6bf7e319770cbc0db9df9437e852",- "sha256:6088930bfe239f0e6710546ab9c19c9ef35e29792895fed6e6e31a023a182a61"- ],- "markers": "python_version >= '3.7'",- "version": "==3.1.2"- },"jmespath": {"hashes": ["sha256:02e2e4cc71b5bcab88332eebf907519190dd9e6e82107fa7f83b1003a6252980",@@ -778,6 +757,14 @@"markers": "python_version >= '3.7'","version": "==1.0.1"},+ "jsonschema": {+ "hashes": [+ "sha256:0f864437ab8b6076ba6707453ef8f98a6a0d512a80e93f8abdb676f737ecb60d",+ "sha256:a870ad254da1a8ca84b6a2905cac29d265f805acc57af304784962a2aa6508f6"+ ],+ "markers": "python_version >= '3.7'",+ "version": "==4.17.3"+ },"jwcrypto": {"hashes": ["sha256:80a35e9ed1b3b2c43ce03d92c5d48e6d0b6647e2aa2618e4963448923d78a37b"@@ -792,62 +779,6 @@"index": "pypi","version": "==0.2.3"},- "markupsafe": {- "hashes": [- "sha256:0576fe974b40a400449768941d5d0858cc624e3249dfd1e0c33674e5c7ca7aed",- "sha256:085fd3201e7b12809f9e6e9bc1e5c96a368c8523fad5afb02afe3c051ae4afcc",- "sha256:090376d812fb6ac5f171e5938e82e7f2d7adc2b629101cec0db8b267815c85e2",- "sha256:0b462104ba25f1ac006fdab8b6a01ebbfbce9ed37fd37fd4acd70c67c973e460",- "sha256:137678c63c977754abe9086a3ec011e8fd985ab90631145dfb9294ad09c102a7",- "sha256:1bea30e9bf331f3fef67e0a3877b2288593c98a21ccb2cf29b74c581a4eb3af0",- "sha256:22152d00bf4a9c7c83960521fc558f55a1adbc0631fbb00a9471e097b19d72e1",- "sha256:22731d79ed2eb25059ae3df1dfc9cb1546691cc41f4e3130fe6bfbc3ecbbecfa",- "sha256:2298c859cfc5463f1b64bd55cb3e602528db6fa0f3cfd568d3605c50678f8f03",- "sha256:28057e985dace2f478e042eaa15606c7efccb700797660629da387eb289b9323",- "sha256:2e7821bffe00aa6bd07a23913b7f4e01328c3d5cc0b40b36c0bd81d362faeb65",- "sha256:2ec4f2d48ae59bbb9d1f9d7efb9236ab81429a764dedca114f5fdabbc3788013",- "sha256:340bea174e9761308703ae988e982005aedf427de816d1afe98147668cc03036",- "sha256:40627dcf047dadb22cd25ea7ecfe9cbf3bbbad0482ee5920b582f3809c97654f",- "sha256:40dfd3fefbef579ee058f139733ac336312663c6706d1163b82b3003fb1925c4",- "sha256:4cf06cdc1dda95223e9d2d3c58d3b178aa5dacb35ee7e3bbac10e4e1faacb419",- "sha256:50c42830a633fa0cf9e7d27664637532791bfc31c731a87b202d2d8ac40c3ea2",- "sha256:55f44b440d491028addb3b88f72207d71eeebfb7b5dbf0643f7c023ae1fba619",- "sha256:608e7073dfa9e38a85d38474c082d4281f4ce276ac0010224eaba11e929dd53a",- "sha256:63ba06c9941e46fa389d389644e2d8225e0e3e5ebcc4ff1ea8506dce646f8c8a",- "sha256:65608c35bfb8a76763f37036547f7adfd09270fbdbf96608be2bead319728fcd",- "sha256:665a36ae6f8f20a4676b53224e33d456a6f5a72657d9c83c2aa00765072f31f7",- "sha256:6d6607f98fcf17e534162f0709aaad3ab7a96032723d8ac8750ffe17ae5a0666",- "sha256:7313ce6a199651c4ed9d7e4cfb4aa56fe923b1adf9af3b420ee14e6d9a73df65",- "sha256:7668b52e102d0ed87cb082380a7e2e1e78737ddecdde129acadb0eccc5423859",- "sha256:7df70907e00c970c60b9ef2938d894a9381f38e6b9db73c5be35e59d92e06625",- "sha256:7e007132af78ea9df29495dbf7b5824cb71648d7133cf7848a2a5dd00d36f9ff",- "sha256:835fb5e38fd89328e9c81067fd642b3593c33e1e17e2fdbf77f5676abb14a156",- "sha256:8bca7e26c1dd751236cfb0c6c72d4ad61d986e9a41bbf76cb445f69488b2a2bd",- "sha256:8db032bf0ce9022a8e41a22598eefc802314e81b879ae093f36ce9ddf39ab1ba",- "sha256:99625a92da8229df6d44335e6fcc558a5037dd0a760e11d84be2260e6f37002f",- "sha256:9cad97ab29dfc3f0249b483412c85c8ef4766d96cdf9dcf5a1e3caa3f3661cf1",- "sha256:a4abaec6ca3ad8660690236d11bfe28dfd707778e2442b45addd2f086d6ef094",- "sha256:a6e40afa7f45939ca356f348c8e23048e02cb109ced1eb8420961b2f40fb373a",- "sha256:a6f2fcca746e8d5910e18782f976489939d54a91f9411c32051b4aab2bd7c513",- "sha256:a806db027852538d2ad7555b203300173dd1b77ba116de92da9afbc3a3be3eed",- "sha256:abcabc8c2b26036d62d4c746381a6f7cf60aafcc653198ad678306986b09450d",- "sha256:b8526c6d437855442cdd3d87eede9c425c4445ea011ca38d937db299382e6fa3",- "sha256:bb06feb762bade6bf3c8b844462274db0c76acc95c52abe8dbed28ae3d44a147",- "sha256:c0a33bc9f02c2b17c3ea382f91b4db0e6cde90b63b296422a939886a7a80de1c",- "sha256:c4a549890a45f57f1ebf99c067a4ad0cb423a05544accaf2b065246827ed9603",- "sha256:ca244fa73f50a800cf8c3ebf7fd93149ec37f5cb9596aa8873ae2c1d23498601",- "sha256:cf877ab4ed6e302ec1d04952ca358b381a882fbd9d1b07cccbfd61783561f98a",- "sha256:d9d971ec1e79906046aa3ca266de79eac42f1dbf3612a05dc9368125952bd1a1",- "sha256:da25303d91526aac3672ee6d49a2f3db2d9502a4a60b55519feb1a4c7714e07d",- "sha256:e55e40ff0cc8cc5c07996915ad367fa47da6b3fc091fdadca7f5403239c5fec3",- "sha256:f03a532d7dee1bed20bc4884194a16160a2de9ffc6354b3878ec9682bb623c54",- "sha256:f1cd098434e83e656abf198f103a8207a8187c0fc110306691a2e94a78d0abb2",- "sha256:f2bfb563d0211ce16b63c7cb9395d2c682a23187f54c3d79bfec33e6705473c6",- "sha256:f8ffb705ffcf5ddd0e80b65ddf7bed7ee4f5a441ea7d3419e861a12eaf41af58"- ],- "markers": "python_version >= '3.7'",- "version": "==2.1.2"- },"multidict": {"hashes": ["sha256:01a3a55bd90018c9c080fbb0b9f4891db37d148a0a18722b42f94694f8b6d4c9",@@ -946,73 +877,60 @@},"orjson": {"hashes": [- "sha256:0826ad2dc1cea1547edff14ce580374f0061d853cbac088c71162dbfe2e52205",- "sha256:0b470d31244a6f647e5402aac7d2abaf7bb4f52379acf67722a09d35a45c9417",- "sha256:11ae68f995a50724032af297c92f20bcde31005e0bf3653b12bff9356394615b",- "sha256:1486600bc1dd1db26c588dd482689edba3d72d301accbe4301db4b2b28bd7aa4",- "sha256:1810e5446fe68d61732e9743592da0ec807e63972eef076d09e02878c2f5958e",- "sha256:2073b62822738d6740bd2492f6035af5c2fd34aa198322b803dc0e70559a17b7",- "sha256:26aee557cf8c93b2a971b5a4a8e3cca19780573531493ce6573aa1002f5c4378",- "sha256:27bb26e171e9cfdbec39c7ca4739b6bef8bd06c293d56d92d5e3a3fc017df17d",- "sha256:2b8cdaacecb92997916603ab232bb096d0fa9e56b418ca956b9754187d65ca06",- "sha256:344ea91c556a2ce6423dc13401b83ab0392aa697a97fa4142c2c63a6fd0bbfef",- "sha256:345e41abd1d9e3ecfb554e1e75ff818cf42e268bd06ad25a96c34e00f73a327e",- "sha256:34b6901c110c06ab9e8d7d0496db4bc9a0c162ca8d77f67539d22cb39e0a1ef4",- "sha256:35d879b46b8029e1e01e9f6067928b470a4efa1ca749b6d053232b873c2dcf66",- "sha256:3cfe32b1227fe029a5ad989fbec0b453a34e5e6d9a977723f7c3046d062d3537",- "sha256:4355c9aedfefe60904e8bd7901315ebbc8bb828f665e4c9bc94b1432e67cb6f7",- "sha256:45a5afc9cda6b8aac066dd50d8194432fbc33e71f7164f95402999b725232d78",- "sha256:48824649019a25d3e52f6454435cf19fe1eb3d05ee697e65d257f58ae3aa94d9",- "sha256:4bf2556ba99292c4dc550560384dd22e88b5cdbe6d98fb4e202e902b5775cf9f",- "sha256:4dfe0651e26492d5d929bbf4322de9afbd1c51ac2e3947a7f78492b20359711d",- "sha256:595e1e7d04aaaa3d41113e4eb9f765ab642173c4001182684ae9ddc621bb11c8",- "sha256:5a0b1f4e4fa75e26f814161196e365fc0e1a16e3c07428154505b680a17df02f",- "sha256:61e2e51cefe7ef90c4fbbc9fd38ecc091575a3ea7751d56fad95cbebeae2a054",- "sha256:64ffd92328473a2f9af059410bd10c703206a4bbc7b70abb1bedcd8761e39eb8",- "sha256:6a286ad379972e4f46579e772f0477e6b505f1823aabcd64ef097dbb4549e1a4",- "sha256:6bbd7b3a3e2030b03c68c4d4b19a2ef5b89081cbb43c05fe2010767ef5e408db",- "sha256:6fa3a26dcf0f5f2912a8ce8e87273e68b2a9526854d19fd09ea671b154418e88",- "sha256:7d27b6182f75896dd8c10ea0f78b9265a3454be72d00632b97f84d7031900dd4",- "sha256:81aa3f321d201bff0bd0f4014ea44e51d58a9a02d8f2b0eeab2cee22611be8e1",- "sha256:8c1825997232a324911d11c75d91e1e0338c7b723c149cf53a5fc24496c048a4",- "sha256:979f231e3bad1c835627eef1a30db12a8af58bfb475a6758868ea7e81897211f",- "sha256:9b23fb0264bbdd7218aa685cb6fc71f0dcecf34182f0a8596a3a0dff010c06f9",- "sha256:a3fdee68c4bb3c5d6f89ed4560f1384b5d6260e48fbf868bae1a245a3c693d4d",- "sha256:a7bce6e61cea6426309259b04c6ee2295b3f823ea51a033749459fe2dd0423b2",- "sha256:abce8d319aae800fd2d774db1106f926dee0e8a5ca85998fd76391fcb58ef94f",- "sha256:ad632dc330a7b39da42530c8d146f76f727d476c01b719dc6743c2b5701aaf6b",- "sha256:af7601a78b99f0515af2f8ab12c955c0072ffcc1e437fb2556f4465783a4d813",- "sha256:b1f648ec89c6a426098868460c0ef8c86b457ce1378d7569ff4acb6c0c454048",- "sha256:b2c4faf20b6bb5a2d7ac0c16f58eb1a3800abcef188c011296d1dc2bb2224d48",- "sha256:b6e79d8864794635974b18821b49a7f27859d17b93413d4603efadf2e92da7a5",- "sha256:b7b0ba074375e25c1594e770e2215941e2017c3cd121889150737fa1123e8bfe",- "sha256:b88afd662190f19c3bb5036a903589f88b1d2c2608fbb97281ce000db6b08897",- "sha256:bc30de5c7b3a402eb59cc0656b8ee53ca36322fc52ab67739c92635174f88336",- "sha256:bce970f293825e008dbf739268dfa41dfe583aa2a1b5ef4efe53a0e92e9671ea",- "sha256:c08b426fae7b9577b528f99af0f7e0ff3ce46858dd9a7d1bf86d30f18df89a4c",- "sha256:c2ef690335b24f9272dbf6639353c1ffc3f196623a92b851063e28e9515cf7dd",- "sha256:cb62ec16a1c26ad9487727b529103cb6a94a1d4969d5b32dd0eab5c3f4f5a6f2",- "sha256:ce49999bcbbc14791c61844bc8a69af44f5205d219be540e074660038adae6bf",- "sha256:d2874cee6856d7c386b596e50bc517d1973d73dc40b2bd6abec057b5e7c76b2f",- "sha256:d953e6c2087dcd990e794f8405011369ee11cf13e9aaae3172ee762ee63947f2",- "sha256:dcf6adb4471b69875034afab51a14b64f1026bc968175a2bb02c5f6b358bd413",- "sha256:ddabc5e44702d13137949adee3c60b7091e73a664f6e07c7b428eebb2dea7bbf",- "sha256:e5d7f82506212e047b184c06e4bcd48c1483e101969013623cebcf51cf12cad9",- "sha256:e999abca892accada083f7079612307d94dd14cc105a699588a324f843216509",- "sha256:f3e9ac9483c2b4cd794e760316966b7bd1e6afb52b0218f068a4e80c9b2db4f6",- "sha256:f7e85d4682f3ed7321d36846cad0503e944ea9579ef435d4c162e1b73ead8ac9",- "sha256:faee89e885796a9cc493c930013fa5cfcec9bfaee431ddf00f0fbfb57166a8b3"+ "sha256:04b60dfc1251742e79bb075d7a7c4e37078b932a02e6f005c45761bd90c69189",+ "sha256:08729e339ff3146e6de56c1166f014c3d2ec3e79ffb76d6c55d52cc892e5e477",+ "sha256:0a53b3c02a38aadc5302661c2ca18645093971488992df77ce14fef16f598b2e",+ "sha256:0bc3d1b93a73b46a698c054697eb2d27bdedbc5ea0d11ec5f1a6bfbec36346b5",+ "sha256:0f9415b86ef154bf247fa78a6918aac50089c296e26fb6cf15bc9d7e6402a1f8",+ "sha256:1103e597c16f82c241e1b02beadc9c91cecd93e60433ca73cb6464dcc235f37c",+ "sha256:12f647d4da0aab1997e25bed4fa2b76782b5b9d2d1bf3066b5f0a57d34d833c4",+ "sha256:173b8f8c750590f432757292cfb197582e5c14347b913b4017561d47af0e759b",+ "sha256:176d742f53434541e50a5e659694073aa51dcbd8f29a1708a4fa1a320193c615",+ "sha256:1e97fdbb779a3b8f5d9fc7dfddef5325f81ee45897eb7cb4638d5d9734d42514",+ "sha256:1fedcc428416e23a6c9de62a000c22ae33bbe0108302ad5d5935e29ea739bf37",+ "sha256:235926b38ed9b76ab2bca99ff26ece79c1c46bc10079b06e660b087aecffbe69",+ "sha256:2fc050f8e7f2e4061c8c9968ad0be745b11b03913b77ffa8ceca65914696886c",+ "sha256:3485c458670c0edb79ca149fe201f199dd9ccfe7ca3acbdef617e3c683e7b97f",+ "sha256:358e515b8b19a275b259f5ee1e0efa2859b1d976b5ed5d016ac59f9e6c8788a3",+ "sha256:37f38c8194ce086e6a9816b4b8dde5e7f383feeed92feec0385d99baf64f9b6e",+ "sha256:382f15861a4bf447ab9d07106010e61b217ef6d4245c6cf64af0c12c4c5e2346",+ "sha256:3afccf7f8684dca7f017837a315de0a1ab5c095de22a4eed206d079f9325ed72",+ "sha256:3b65424ceee82b94e3613233b67ef110dc58f9d83b0076ec47a506289552a861",+ "sha256:3c55065bc2075a5ea6ffb30462d84fd3aa5bbb7ae600855c325ee5753feec715",+ "sha256:4118dcd2b5a27a22af5ad92414073f25d93bca1868f1f580056003c84841062f",+ "sha256:553fdaf9f4b5060a0dcc517ae0c511c289c184a83d6719d03c5602ed0eef0390",+ "sha256:58c068f93d701f9466f667bf3b5cb4e4946aee940df2b07ca5101f1cf1b60ce4",+ "sha256:5c3b5405edc3a5f9e34516ee1a729f6c46aecf6de960ae07a7b3e95ebdd0e1d9",+ "sha256:5ff10789cbc08a9fd94507c907ba55b9315e99f20345ff8ef34fac432dacd948",+ "sha256:62eb8bdcf6f4cdbe12743e88ad98696277a75f91a35e8fb93a7ea2b9f4a7000c",+ "sha256:66f0c9e4e8f6641497a7dc50591af3704b11468e9fc90cfb5874f28b0a61edb5",+ "sha256:6d7b050135669d2335e40120215ad4120e29958c139f8bab68ce06a1cb1a1b2c",+ "sha256:714c3e2be6ed7e4ff6e887926d6e171bfd94fdee76d7d3bfa74ee19237a2d49d",+ "sha256:71a656f1c62e84c69060093e20cedff6a92e472d53ff5b8b9026b1b298542a68",+ "sha256:7c7b4fae3b8fc69c8e76f1c0694f3decfe8a57f87e7ac7779ebb59cd71135438",+ "sha256:7e4ded77ac7432a155d1d27a83bcadf722750aea3b9e6c4d47f2a92054ab71cb",+ "sha256:882c77126c42dd93bb35288632d69b1e393863a2b752de3e5fe0112833609496",+ "sha256:9486963d2e65482c565dacb366adb36d22aa22acf7274b61490244c3d87fa631",+ "sha256:982ab319b7a5ece4199caf2a2b3a28e62a8e289cb6418548ef98bced7e2a6cfe",+ "sha256:98befa717efaab7ddb847ebe47d473f6bd6f0cb53e98e6c3d487c7c58ba2e174",+ "sha256:9fa900bdd84b4576c8dd6f3e2a00b35797f29283af328c6e3d70addfa4c2d599",+ "sha256:b369019e597b59c4b97e9f925a3b725321fa1481c129d76c74c6ea3823f5d1e8",+ "sha256:b68a07794834b7bd53ae2a8b4fe4bf010734cae3f0917d434c83b97acf8e5bce",+ "sha256:bf48ed8d4b6ab9f23b7ee642462369d7133412d72824bad89f9bf4311c06c6a1",+ "sha256:c2d3e6b65458ed71b6797f321d6e8bfeeadee9d3d31cac47806a608ea745edd7",+ "sha256:c67ac094a4dde914297543af19f22532d7124f3a35245580d8b756c4ff2f5884",+ "sha256:cdf201e77d3fac9d8d6f68d872ef45dccfe46f30b268bb88b6c5af5065b433aa",+ "sha256:d47f97b99beb9bcac6e288a76b559543a61e0187443d8089204b757726b1d000",+ "sha256:d70b6db9d4e1e6057829cd7fe119c217cebaf989f88d14b2445fa69fc568d03e",+ "sha256:d7d5aecccfaf2052cd07ed5bec8efba9ddfea055682fcd346047b1a3e9da3034",+ "sha256:e14903bfeb591a9117b7d40d81e3ebca9700b4e77bd829d6f22ea57941bb0ebf",+ "sha256:ef52f1d5a2f89ef9049781c90ea35d5edf74374ed6ed515c286a706d1b290267",+ "sha256:f2ef933da50b31c112b252be03d1ef59e0d0552c1a08e48295bd529ce42aaab8",+ "sha256:f4e4a1001933166fd1c257b920b241b35322bef99ed7329338bf266ac053abe7",+ "sha256:f7aeefac55848aeb29f20b91fa55f9e488f446201bb1bb31dc17480d113d8955"],"index": "pypi",- "version": "==3.8.10"- },- "packaging": {- "hashes": [- "sha256:994793af429502c4ea2ebf6bf664629d07c1a9fe974af92966e4b8d2df7edc61",- "sha256:a392980d2b6cffa644431898be54b0045151319d1e7ec34f0cfed48767dd334f"- ],- "markers": "python_version >= '3.7'",- "version": "==23.1"+ "version": "==3.8.11"},"piexif": {"hashes": [@@ -1134,6 +1052,39 @@"index": "pypi","version": "==2.6.0"},+ "pyrsistent": {+ "hashes": [+ "sha256:016ad1afadf318eb7911baa24b049909f7f3bb2c5b1ed7b6a8f21db21ea3faa8",+ "sha256:1a2994773706bbb4995c31a97bc94f1418314923bd1048c6d964837040376440",+ "sha256:20460ac0ea439a3e79caa1dbd560344b64ed75e85d8703943e0b66c2a6150e4a",+ "sha256:3311cb4237a341aa52ab8448c27e3a9931e2ee09561ad150ba94e4cfd3fc888c",+ "sha256:3a8cb235fa6d3fd7aae6a4f1429bbb1fec1577d978098da1252f0489937786f3",+ "sha256:3ab2204234c0ecd8b9368dbd6a53e83c3d4f3cab10ecaf6d0e772f456c442393",+ "sha256:42ac0b2f44607eb92ae88609eda931a4f0dfa03038c44c772e07f43e738bcac9",+ "sha256:49c32f216c17148695ca0e02a5c521e28a4ee6c5089f97e34fe24163113722da",+ "sha256:4b774f9288dda8d425adb6544e5903f1fb6c273ab3128a355c6b972b7df39dcf",+ "sha256:4c18264cb84b5e68e7085a43723f9e4c1fd1d935ab240ce02c0324a8e01ccb64",+ "sha256:5a474fb80f5e0d6c9394d8db0fc19e90fa540b82ee52dba7d246a7791712f74a",+ "sha256:64220c429e42a7150f4bfd280f6f4bb2850f95956bde93c6fda1b70507af6ef3",+ "sha256:878433581fc23e906d947a6814336eee031a00e6defba224234169ae3d3d6a98",+ "sha256:99abb85579e2165bd8522f0c0138864da97847875ecbd45f3e7e2af569bfc6f2",+ "sha256:a2471f3f8693101975b1ff85ffd19bb7ca7dd7c38f8a81701f67d6b4f97b87d8",+ "sha256:aeda827381f5e5d65cced3024126529ddc4289d944f75e090572c77ceb19adbf",+ "sha256:b735e538f74ec31378f5a1e3886a26d2ca6351106b4dfde376a26fc32a044edc",+ "sha256:c147257a92374fde8498491f53ffa8f4822cd70c0d85037e09028e478cababb7",+ "sha256:c4db1bd596fefd66b296a3d5d943c94f4fac5bcd13e99bffe2ba6a759d959a28",+ "sha256:c74bed51f9b41c48366a286395c67f4e894374306b197e62810e0fdaf2364da2",+ "sha256:c9bb60a40a0ab9aba40a59f68214eed5a29c6274c83b2cc206a359c4a89fa41b",+ "sha256:cc5d149f31706762c1f8bda2e8c4f8fead6e80312e3692619a75301d3dbb819a",+ "sha256:ccf0d6bd208f8111179f0c26fdf84ed7c3891982f2edaeae7422575f47e66b64",+ "sha256:e42296a09e83028b3476f7073fcb69ffebac0e66dbbfd1bd847d61f74db30f19",+ "sha256:e8f2b814a3dc6225964fa03d8582c6e0b6650d68a232df41e3cc1b66a5d2f8d1",+ "sha256:f0774bf48631f3a20471dd7c5989657b639fd2d285b861237ea9e82c36a415a9",+ "sha256:f0e7c4b2f77593871e918be000b96c8107da48444d57005b6a6bc61fb4331b2c"+ ],+ "markers": "python_version >= '3.7'",+ "version": "==0.19.3"+ },"python-dateutil": {"hashes": ["sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86",@@ -1180,6 +1131,52 @@],"version": "==2023.3"},+ "pyyaml": {+ "hashes": [+ "sha256:01b45c0191e6d66c470b6cf1b9531a771a83c1c4208272ead47a3ae4f2f603bf",+ "sha256:0283c35a6a9fbf047493e3a0ce8d79ef5030852c51e9d911a27badfde0605293",+ "sha256:055d937d65826939cb044fc8c9b08889e8c743fdc6a32b33e2390f66013e449b",+ "sha256:07751360502caac1c067a8132d150cf3d61339af5691fe9e87803040dbc5db57",+ "sha256:0b4624f379dab24d3725ffde76559cff63d9ec94e1736b556dacdfebe5ab6d4b",+ "sha256:0ce82d761c532fe4ec3f87fc45688bdd3a4c1dc5e0b4a19814b9009a29baefd4",+ "sha256:1e4747bc279b4f613a09eb64bba2ba602d8a6664c6ce6396a4d0cd413a50ce07",+ "sha256:213c60cd50106436cc818accf5baa1aba61c0189ff610f64f4a3e8c6726218ba",+ "sha256:231710d57adfd809ef5d34183b8ed1eeae3f76459c18fb4a0b373ad56bedcdd9",+ "sha256:277a0ef2981ca40581a47093e9e2d13b3f1fbbeffae064c1d21bfceba2030287",+ "sha256:2cd5df3de48857ed0544b34e2d40e9fac445930039f3cfe4bcc592a1f836d513",+ "sha256:40527857252b61eacd1d9af500c3337ba8deb8fc298940291486c465c8b46ec0",+ "sha256:432557aa2c09802be39460360ddffd48156e30721f5e8d917f01d31694216782",+ "sha256:473f9edb243cb1935ab5a084eb238d842fb8f404ed2193a915d1784b5a6b5fc0",+ "sha256:48c346915c114f5fdb3ead70312bd042a953a8ce5c7106d5bfb1a5254e47da92",+ "sha256:50602afada6d6cbfad699b0c7bb50d5ccffa7e46a3d738092afddc1f9758427f",+ "sha256:68fb519c14306fec9720a2a5b45bc9f0c8d1b9c72adf45c37baedfcd949c35a2",+ "sha256:77f396e6ef4c73fdc33a9157446466f1cff553d979bd00ecb64385760c6babdc",+ "sha256:81957921f441d50af23654aa6c5e5eaf9b06aba7f0a19c18a538dc7ef291c5a1",+ "sha256:819b3830a1543db06c4d4b865e70ded25be52a2e0631ccd2f6a47a2822f2fd7c",+ "sha256:897b80890765f037df3403d22bab41627ca8811ae55e9a722fd0392850ec4d86",+ "sha256:98c4d36e99714e55cfbaaee6dd5badbc9a1ec339ebfc3b1f52e293aee6bb71a4",+ "sha256:9df7ed3b3d2e0ecfe09e14741b857df43adb5a3ddadc919a2d94fbdf78fea53c",+ "sha256:9fa600030013c4de8165339db93d182b9431076eb98eb40ee068700c9c813e34",+ "sha256:a80a78046a72361de73f8f395f1f1e49f956c6be882eed58505a15f3e430962b",+ "sha256:afa17f5bc4d1b10afd4466fd3a44dc0e245382deca5b3c353d8b757f9e3ecb8d",+ "sha256:b3d267842bf12586ba6c734f89d1f5b871df0273157918b0ccefa29deb05c21c",+ "sha256:b5b9eccad747aabaaffbc6064800670f0c297e52c12754eb1d976c57e4f74dcb",+ "sha256:bfaef573a63ba8923503d27530362590ff4f576c626d86a9fed95822a8255fd7",+ "sha256:c5687b8d43cf58545ade1fe3e055f70eac7a5a1a0bf42824308d868289a95737",+ "sha256:cba8c411ef271aa037d7357a2bc8f9ee8b58b9965831d9e51baf703280dc73d3",+ "sha256:d15a181d1ecd0d4270dc32edb46f7cb7733c7c508857278d3d378d14d606db2d",+ "sha256:d4b0ba9512519522b118090257be113b9468d804b19d63c71dbcf4a48fa32358",+ "sha256:d4db7c7aef085872ef65a8fd7d6d09a14ae91f691dec3e87ee5ee0539d516f53",+ "sha256:d4eccecf9adf6fbcc6861a38015c2a64f38b9d94838ac1810a9023a0609e1b78",+ "sha256:d67d839ede4ed1b28a4e8909735fc992a923cdb84e618544973d7dfc71540803",+ "sha256:daf496c58a8c52083df09b80c860005194014c3698698d1a57cbcfa182142a3a",+ "sha256:dbad0e9d368bb989f4515da330b88a057617d16b6a8245084f1b05400f24609f",+ "sha256:e61ceaab6f49fb8bdfaa0f92c4b57bcfbea54c09277b1b4f7ac376bfb7a7c174",+ "sha256:f84fbc98b019fef2ee9a1cb3ce93e3187a6df0b2538a651bfb890254ba9f90b5"+ ],+ "markers": "python_version >= '3.6'",+ "version": "==6.0"+ },"redis": {"hashes": ["sha256:2c19e6767c474f2e85167909061d525ed65bea9301c0770bb151e041b7ac89a2",@@ -1211,14 +1208,6 @@"index": "pypi","version": "==1.3.1"},- "ruamel.yaml": {- "hashes": [- "sha256:742b35d3d665023981bd6d16b3d24248ce5df75fdb4e2924e93a05c1f8b61ca7",- "sha256:8b7ce697a2f212752a35c1ac414471dc16c424c9573be4926b56ff3f5d23b7af"- ],- "markers": "python_version >= '3'",- "version": "==0.17.21"- },"s3transfer": {"hashes": ["sha256:06176b74f3a15f61f1b4f25a1fc29a4429040b7647133a463da8fa5bd28d5ecd",@@ -1229,11 +1218,11 @@},"sentry-sdk": {"hashes": [- "sha256:7ae78bd921981a5010ab540d6bdf3b793659a4db8cccf7f16180702d48a80d84",- "sha256:885a11c69df23e53eb281d003b9ff15a5bdfa43d8a2a53589be52104a1b4582f"+ "sha256:36a1ca082a3065a8a05aafa4b1e3d74e9459d41fbb0bea8a5364caca68626341",+ "sha256:82faf9e2c9eb77401a7a187094b126ca25c2a3a478de6704612f48b3346f7a84"],"index": "pypi",- "version": "==1.19.1"+ "version": "==1.21.0"},"setuptools": {"hashes": [@@ -1251,6 +1240,13 @@"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'","version": "==1.16.0"},+ "sortedcontainers": {+ "hashes": [+ "sha256:25caa5a06cc30b6b83d11423433f65d1f9d76c4c6a0c90e3379eaa43b9bfdb88",+ "sha256:a163dcaede0f1c021485e957a39245190e74249897e2ae4b2aa38595db237ee0"+ ],+ "version": "==2.4.0"+ },"sqlparse": {"hashes": ["sha256:5430a4fe2ac7d0f93e66f1efc6e1338a41884b7ddf2a350cedd20ccc4d9d28f3",@@ -1512,6 +1508,14 @@}},"develop": {+ "appnope": {+ "hashes": [+ "sha256:02bd91c4de869fbb1e1c50aafc4098827a7a54ab2f39d9dcba6c9547ed920e24",+ "sha256:265a455292d0bd8a72453494fa24df5a11eb18373a60c7c0430889f22548605e"+ ],+ "markers": "sys_platform == 'darwin'",+ "version": "==0.1.3"+ },"asttokens": {"hashes": ["sha256:4622110b2a6f30b77e1473affaa97e711bc2f07d3f10848420ff1898edbe94f3",@@ -1578,6 +1582,14 @@"markers": "python_version >= '3.5'","version": "==5.1.1"},+ "exceptiongroup": {+ "hashes": [+ "sha256:232c37c63e4f682982c8b6459f33a8981039e5fb8756b2074364e5055c498c9e",+ "sha256:d484c3090ba2889ae2928419117447a14daf3c1231d5e30d0aae34f354f01785"+ ],+ "markers": "python_version < '3.11'",+ "version": "==1.1.1"+ },"executing": {"hashes": ["sha256:0314a69e37426e3608aada02473b4161d4caf5a4b244d1d0c48072b8fee7bacc",@@ -1595,11 +1607,11 @@},"faker": {"hashes": [- "sha256:137c6667583b0b458599b11305eed5a486e3932a14cb792b2b5b82ad1ad1a430",- "sha256:64e9ab619d75684cc0593aa9f336170b0b58fa77c07fc0ebc7b2b1258e53b67d"+ "sha256:49060d40e6659e116f53353c5771ad2f2cbcd12b15771f49e3000a3a451f13ec",+ "sha256:ac903ba8cb5adbce2cdd15e5536118d484bbe01126f3c774dd9f6df77b61232d"],"markers": "python_version >= '3.7'",- "version": "==18.5.1"+ "version": "==18.6.0"},"fakeredis": {"hashes": [@@ -1634,11 +1646,11 @@},"ipython": {"hashes": [- "sha256:1c183bf61b148b00bcebfa5d9b39312733ae97f6dad90d7e9b4d86c8647f498c",- "sha256:a950236df04ad75b5bc7f816f9af3d74dc118fd42f2ff7e80e8e60ca1f182e2d"+ "sha256:2442915417763b62181009259782975fa50bb5eedb97ae97fb614204bf6ecc21",+ "sha256:e3015a1a4aa09b3984fb81b9cef4f0772af5a549878b81efb094cda8bb121993"],"index": "pypi",- "version": "==8.12.0"+ "version": "==8.12.1"},"jedi": {"hashes": [@@ -1656,56 +1668,6 @@"markers": "python_version >= '3.7'","version": "==4.17.3"},- "jsonschema-spec": {- "hashes": [- "sha256:34471d8b60e1f06d174236c4d3cf9590fbf3cff1cc733b28d15cd83672bcd062",- "sha256:824c743197bbe2104fcc6dce114a4082bf7f7efdebf16683510cb0ec6d8d53d0"- ],- "markers": "python_version >= '3.7' and python_full_version < '4.0.0'",- "version": "==0.1.4"- },- "lazy-object-proxy": {- "hashes": [- "sha256:09763491ce220c0299688940f8dc2c5d05fd1f45af1e42e636b2e8b2303e4382",- "sha256:0a891e4e41b54fd5b8313b96399f8b0e173bbbfc03c7631f01efbe29bb0bcf82",- "sha256:189bbd5d41ae7a498397287c408617fe5c48633e7755287b21d741f7db2706a9",- "sha256:18b78ec83edbbeb69efdc0e9c1cb41a3b1b1ed11ddd8ded602464c3fc6020494",- "sha256:1aa3de4088c89a1b69f8ec0dcc169aa725b0ff017899ac568fe44ddc1396df46",- "sha256:212774e4dfa851e74d393a2370871e174d7ff0ebc980907723bb67d25c8a7c30",- "sha256:2d0daa332786cf3bb49e10dc6a17a52f6a8f9601b4cf5c295a4f85854d61de63",- "sha256:5f83ac4d83ef0ab017683d715ed356e30dd48a93746309c8f3517e1287523ef4",- "sha256:659fb5809fa4629b8a1ac5106f669cfc7bef26fbb389dda53b3e010d1ac4ebae",- "sha256:660c94ea760b3ce47d1855a30984c78327500493d396eac4dfd8bd82041b22be",- "sha256:66a3de4a3ec06cd8af3f61b8e1ec67614fbb7c995d02fa224813cb7afefee701",- "sha256:721532711daa7db0d8b779b0bb0318fa87af1c10d7fe5e52ef30f8eff254d0cd",- "sha256:7322c3d6f1766d4ef1e51a465f47955f1e8123caee67dd641e67d539a534d006",- "sha256:79a31b086e7e68b24b99b23d57723ef7e2c6d81ed21007b6281ebcd1688acb0a",- "sha256:81fc4d08b062b535d95c9ea70dbe8a335c45c04029878e62d744bdced5141586",- "sha256:8fa02eaab317b1e9e03f69aab1f91e120e7899b392c4fc19807a8278a07a97e8",- "sha256:9090d8e53235aa280fc9239a86ae3ea8ac58eff66a705fa6aa2ec4968b95c821",- "sha256:946d27deaff6cf8452ed0dba83ba38839a87f4f7a9732e8f9fd4107b21e6ff07",- "sha256:9990d8e71b9f6488e91ad25f322898c136b008d87bf852ff65391b004da5e17b",- "sha256:9cd077f3d04a58e83d04b20e334f678c2b0ff9879b9375ed107d5d07ff160171",- "sha256:9e7551208b2aded9c1447453ee366f1c4070602b3d932ace044715d89666899b",- "sha256:9f5fa4a61ce2438267163891961cfd5e32ec97a2c444e5b842d574251ade27d2",- "sha256:b40387277b0ed2d0602b8293b94d7257e17d1479e257b4de114ea11a8cb7f2d7",- "sha256:bfb38f9ffb53b942f2b5954e0f610f1e721ccebe9cce9025a38c8ccf4a5183a4",- "sha256:cbf9b082426036e19c6924a9ce90c740a9861e2bdc27a4834fd0a910742ac1e8",- "sha256:d9e25ef10a39e8afe59a5c348a4dbf29b4868ab76269f81ce1674494e2565a6e",- "sha256:db1c1722726f47e10e0b5fdbf15ac3b8adb58c091d12b3ab713965795036985f",- "sha256:e7c21c95cae3c05c14aafffe2865bbd5e377cfc1348c4f7751d9dc9a48ca4bda",- "sha256:e8c6cfb338b133fbdbc5cfaa10fe3c6aeea827db80c978dbd13bc9dd8526b7d4",- "sha256:ea806fd4c37bf7e7ad82537b0757999264d5f70c45468447bb2b91afdbe73a6e",- "sha256:edd20c5a55acb67c7ed471fa2b5fb66cb17f61430b7a6b9c3b4a1e40293b1671",- "sha256:f0117049dd1d5635bbff65444496c90e0baa48ea405125c088e93d9cf4525b11",- "sha256:f0705c376533ed2a9e5e97aacdbfe04cecd71e0aa84c7c0595d02ef93b6e4455",- "sha256:f12ad7126ae0c98d601a7ee504c1122bcef553d1d5e0c3bfa77b16b3968d2734",- "sha256:f2457189d8257dd41ae9b434ba33298aec198e30adf2dcdaaa3a28b9994f6adb",- "sha256:f699ac1c768270c9e384e4cbd268d6e67aebcfae6cd623b4d7c3bfde5a35db59"- ],- "markers": "python_version >= '3.7'",- "version": "==1.9.0"- },"matplotlib-inline": {"hashes": ["sha256:f1f41aab5328aa5aaea9b16d083b128102f8712542f819fe7e6a420ff581b311",@@ -1714,22 +1676,6 @@"markers": "python_version >= '3.5'","version": "==0.1.6"},- "openapi-schema-validator": {- "hashes": [- "sha256:79f37f38ef9fd5206b924ed7a6f382cea7b649b3b56383c47f1906082b7b9015",- "sha256:c573e2be2c783abae56c5a1486ab716ca96e09d1c3eab56020d1dc680aa57bf8"- ],- "markers": "python_version >= '3.7' and python_full_version < '4.0.0'",- "version": "==0.4.4"- },- "openapi-spec-validator": {- "hashes": [- "sha256:1189d0618ae0678ccf6c883cc1266d381454eece6f21fcf330cc7caea5fc25eb",- "sha256:4145478f26df16059c147406eaaa59b77ff60e3461ba6edb9aa84d481ed89aaf"- ],- "index": "pypi",- "version": "==0.5.6"- },"orderedmultidict": {"hashes": ["sha256:04070bbb5e87291cc9bfa51df413677faf2141c73c61d2a5f7b26bea3cd882ad",@@ -1753,14 +1699,6 @@"markers": "python_version >= '3.6'","version": "==0.8.3"},- "pathable": {- "hashes": [- "sha256:5c869d315be50776cc8a993f3af43e0c60dc01506b399643f919034ebf4cdcab",- "sha256:cdd7b1f9d7d5c8b8d3315dbf5a86b2596053ae845f056f57d97c0eefff84da14"- ],- "markers": "python_version >= '3.7' and python_full_version < '4.0.0'",- "version": "==0.4.3"- },"pendulum": {"hashes": ["sha256:0731f0c661a3cb779d398803655494893c9f581f6488048b3fb629c2342b5394",@@ -1839,7 +1777,7 @@"sha256:23ac5d50538a9a38c8bde05fecb47d0b403ecd0662857a86f886f798563d5b9b","sha256:45ea77a2f7c60418850331366c81cf6b5b9cf4c7fd34616f733c5427e6abbb1f"],- "markers": "python_version >= '3.7'",+ "markers": "python_full_version >= '3.7.0'","version": "==3.0.38"},"psycopg": {@@ -1961,52 +1899,6 @@"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'","version": "==2020.1"},- "pyyaml": {- "hashes": [- "sha256:01b45c0191e6d66c470b6cf1b9531a771a83c1c4208272ead47a3ae4f2f603bf",- "sha256:0283c35a6a9fbf047493e3a0ce8d79ef5030852c51e9d911a27badfde0605293",- "sha256:055d937d65826939cb044fc8c9b08889e8c743fdc6a32b33e2390f66013e449b",- "sha256:07751360502caac1c067a8132d150cf3d61339af5691fe9e87803040dbc5db57",- "sha256:0b4624f379dab24d3725ffde76559cff63d9ec94e1736b556dacdfebe5ab6d4b",- "sha256:0ce82d761c532fe4ec3f87fc45688bdd3a4c1dc5e0b4a19814b9009a29baefd4",- "sha256:1e4747bc279b4f613a09eb64bba2ba602d8a6664c6ce6396a4d0cd413a50ce07",- "sha256:213c60cd50106436cc818accf5baa1aba61c0189ff610f64f4a3e8c6726218ba",- "sha256:231710d57adfd809ef5d34183b8ed1eeae3f76459c18fb4a0b373ad56bedcdd9",- "sha256:277a0ef2981ca40581a47093e9e2d13b3f1fbbeffae064c1d21bfceba2030287",- "sha256:2cd5df3de48857ed0544b34e2d40e9fac445930039f3cfe4bcc592a1f836d513",- "sha256:40527857252b61eacd1d9af500c3337ba8deb8fc298940291486c465c8b46ec0",- "sha256:432557aa2c09802be39460360ddffd48156e30721f5e8d917f01d31694216782",- "sha256:473f9edb243cb1935ab5a084eb238d842fb8f404ed2193a915d1784b5a6b5fc0",- "sha256:48c346915c114f5fdb3ead70312bd042a953a8ce5c7106d5bfb1a5254e47da92",- "sha256:50602afada6d6cbfad699b0c7bb50d5ccffa7e46a3d738092afddc1f9758427f",- "sha256:68fb519c14306fec9720a2a5b45bc9f0c8d1b9c72adf45c37baedfcd949c35a2",- "sha256:77f396e6ef4c73fdc33a9157446466f1cff553d979bd00ecb64385760c6babdc",- "sha256:81957921f441d50af23654aa6c5e5eaf9b06aba7f0a19c18a538dc7ef291c5a1",- "sha256:819b3830a1543db06c4d4b865e70ded25be52a2e0631ccd2f6a47a2822f2fd7c",- "sha256:897b80890765f037df3403d22bab41627ca8811ae55e9a722fd0392850ec4d86",- "sha256:98c4d36e99714e55cfbaaee6dd5badbc9a1ec339ebfc3b1f52e293aee6bb71a4",- "sha256:9df7ed3b3d2e0ecfe09e14741b857df43adb5a3ddadc919a2d94fbdf78fea53c",- "sha256:9fa600030013c4de8165339db93d182b9431076eb98eb40ee068700c9c813e34",- "sha256:a80a78046a72361de73f8f395f1f1e49f956c6be882eed58505a15f3e430962b",- "sha256:afa17f5bc4d1b10afd4466fd3a44dc0e245382deca5b3c353d8b757f9e3ecb8d",- "sha256:b3d267842bf12586ba6c734f89d1f5b871df0273157918b0ccefa29deb05c21c",- "sha256:b5b9eccad747aabaaffbc6064800670f0c297e52c12754eb1d976c57e4f74dcb",- "sha256:bfaef573a63ba8923503d27530362590ff4f576c626d86a9fed95822a8255fd7",- "sha256:c5687b8d43cf58545ade1fe3e055f70eac7a5a1a0bf42824308d868289a95737",- "sha256:cba8c411ef271aa037d7357a2bc8f9ee8b58b9965831d9e51baf703280dc73d3",- "sha256:d15a181d1ecd0d4270dc32edb46f7cb7733c7c508857278d3d378d14d606db2d",- "sha256:d4b0ba9512519522b118090257be113b9468d804b19d63c71dbcf4a48fa32358",- "sha256:d4db7c7aef085872ef65a8fd7d6d09a14ae91f691dec3e87ee5ee0539d516f53",- "sha256:d4eccecf9adf6fbcc6861a38015c2a64f38b9d94838ac1810a9023a0609e1b78",- "sha256:d67d839ede4ed1b28a4e8909735fc992a923cdb84e618544973d7dfc71540803",- "sha256:daf496c58a8c52083df09b80c860005194014c3698698d1a57cbcfa182142a3a",- "sha256:dbad0e9d368bb989f4515da330b88a057617d16b6a8245084f1b05400f24609f",- "sha256:e61ceaab6f49fb8bdfaa0f92c4b57bcfbea54c09277b1b4f7ac376bfb7a7c174",- "sha256:f84fbc98b019fef2ee9a1cb3ce93e3187a6df0b2538a651bfb890254ba9f90b5"- ],- "markers": "python_version >= '3.6'",- "version": "==6.0"- },"redis": {"hashes": ["sha256:2c19e6767c474f2e85167909061d525ed65bea9301c0770bb151e041b7ac89a2",@@ -2023,14 +1915,6 @@"index": "pypi","version": "==2.1.0"},- "rfc3339-validator": {- "hashes": [- "sha256:138a2abdf93304ad60530167e51d2dfb9549521a836871b88d7f4695d0022f6b",- "sha256:24f6ec1eda14ef823da9e36ec7113124b39c04d50a4d3d3a3c2859577e7791fa"- ],- "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'",- "version": "==0.1.4"- },"setproctitle": {"hashes": ["sha256:1c5d5dad7c28bdd1ec4187d818e43796f58a845aa892bb4481587010dc4d362b",@@ -2158,6 +2042,14 @@"markers": "python_version >= '3.7'","version": "==2.3.0"},+ "tomli": {+ "hashes": [+ "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc",+ "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"+ ],+ "markers": "python_version < '3.11'",+ "version": "==2.0.1"+ },"traitlets": {"hashes": ["sha256:9e6ec080259b9a5940c797d58b613b5e31441c2257b87c2e795c5228ae80d2d8",diff --git a/api/catalog/api/docs/README.md b/api/catalog/api/docs/README.mddeleted file mode 100644index 57a10006a..000000000--- a/api/catalog/api/docs/README.md+++ /dev/null@@ -1,144 +0,0 @@-This documentation is focused towards consumers who are using the Openverse API.-To contribute to the development of the Openverse API, please refer to the-[Openverse developer documentation](https://docs.openverse.org/).--# Introduction--The Openverse API is a system that allows programmatic access to public domain-digital media. It is our ambition to index and catalog billions of-openly-licensed works, including articles, songs, videos, photographs,-paintings, and more. Using this API, developers will be able to access the-digital commons in their own applications.--# Rate limits--Please note that the API has imposed rate limits to prevent abuse. In the-response for each request that is subject to rate-limits, you can see the-`X-RateLimit-` headers for information about your permitted and available usage.-Exceeding the limit will result in '429: Too Many Requests' responses.--## Anonymous usage--Anonymous usage is subject to a rate limit of 100 requests per day and,-simultaneously, 5 requests per hour. This is fine for introducing yourself to-the API, but we strongly recommend that you obtain an API key as soon as-possible.--## Authenticated usage--Authorized clients have a higher rate limit of 10000 requests per day and 100-requests per minute. Additionally, Openverse can give your key an even higher-limit that fits your application's needs. See the-[Register and Authenticate section](#section/Register-and-Authenticate) for-instructions on obtaining an API key.--# Register and Authenticate--## Register for a key--Before using the Openverse API, you need to register access via OAuth2. This can-be done using the `/v1/auth_tokens/register/` endpoint.--Example on how to register for a key:--```bash-$ curl \- -X POST \- -H "Content-Type: application/json" \- -d '{"name": "My amazing project", "description": "To access Openverse API", "email": "[email protected]"}' \- "https://api.openverse.engineering/v1/auth_tokens/register/"-```--If your request is successful, you will get a `client_id` and `client_secret`.-Save these keys securely because you will not be able to see them again.--Example of successful request:--```json-{- "client_secret": "YhVjvIBc7TuRJSvO2wIi344ez5SEreXLksV7GjalLiKDpxfbiM8qfUb5sNvcwFOhBUVzGNdzmmHvfyt6yU3aGrN6TAbMW8EOkRMOwhyXkN1iDetmzMMcxLVELf00BR2e",- "client_id": "pm8GMaIXIhkjQ4iDfXLOvVUUcIKGYRnMlZYApbda",- "name": "My amazing project"-}-```--## Authenticate--In order to use the Openverse API endpoints, you need to include access token in-the header. This can be done by exchanging your client credentials for a token-using the `/v1/auth_tokens/token/` endpoint.--Example on how to authenticate using OAuth2:--```bash-$ curl \- -X POST \- -d "client_id=pm8GMaIXIhkjQ4iDfXLOvVUUcIKGYRnMlZYApbda&client_secret=YhVjvIBc7TuRJSvO2wIi344ez5SEreXLksV7GjalLiKDpxfbiM8qfUb5sNvcwFOhBUVzGNdzmmHvfyt6yU3aGrN6TAbMW8EOkRMOwhyXkN1iDetmzMMcxLVELf00BR2e&grant_type=client_credentials" \- "https://api.openverse.engineering/v1/auth_tokens/token/"-```--If your request is successful, you will get an access token.--Example of successful request:--```json-{- "access_token": "DLBYIcfnKfolaXKcmMC8RIDCavc2hW",- "scope": "read write groups",- "expires_in": 36000,- "token_type": "Bearer"-}-```--Check your email for a verification link. After you have followed the link, your-API key will be activated.--## Using Access Token--Include the `access_token` in the authorization header to use your key in your-future API requests.--Example on how to make an authenticated request:--```bash-$ curl \- -H "Authorization: Bearer DLBYIcfnKfolaXKcmMC8RIDCavc2hW" \- "https://api.openverse.engineering/v1/images?q=test"-```--> **NOTE:** Your token will be throttled like an anonymous user until the email-> address has been verified.--# Glossary--| Term | Definition |-| ----------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |-| API | an abbreviation for Application Programming Interface |-| OAuth2 | an authorization framework that enables a third party application to get access to an HTTP service |-| access token | a private string that authorizes an application to make API requests |-| client ID | a publicly exposed string used by Openverse API to identify the application |-| client secret | a private string that authenticates the identity of the application to the Openverse API |-| CC | an abbreviation for Creative Commons |-| copyright | a type of intellectual property that gives the owner an exclusive right to reproduce, publish, sell or distribute content |-| mature content | any content that requires the audience to be 18 and older |-| sensitive content | any content that depicts graphic violence, adult content, and hostility or malice against others based on their race, religion, disability, sexual orientation, ethnicity and national origin |--# Contribute--We love pull requests! If you’re interested in-[contributing on Github](https://github.com/WordPress/openverse-api/blob/main/CONTRIBUTING.md),-here’s a todo list to get started.--- Read up about [Django REST Framework](https://www.django-rest-framework.org/),- which is the framework used to build Openverse API-- Read up about [drf-yasg](https://drf-yasg.readthedocs.io/en/stable/), which is- a tool used to generate real Swagger/OpenAPI 2.0 specifications-- Read up about Documentation Guidelines, which provides guidelines on how to- contribute to documentation, documentation styles and cheat sheet for drf-yasg-- Run the server locally by following this- [link](https://github.com/wordpress/openverse-api#running-the-server-locally)-- Update documentation or codebase-- Make sure the updates passed the automated tests in this- [file](https://github.com/WordPress/openverse-api/blob/master/.github/workflows/integration-tests.yml)-- Commit and push-- Create pull requestdiff --git a/api/catalog/api/docs/audio_docs.py b/api/catalog/api/docs/audio_docs.pyindex a42bd4a0b..72fd2b6c2 100644--- a/api/catalog/api/docs/audio_docs.py+++ b/api/catalog/api/docs/audio_docs.py@@ -1,14 +1,6 @@-from drf_yasg import openapi+from drf_spectacular.utils import OpenApiResponse, extend_schema-from catalog.api.docs.media_docs import (- MediaComplain,- MediaDetail,- MediaRelated,- MediaSearch,- MediaStats,- fields_to_md,- refer_sample,-)+from catalog.api.docs.base_docs import custom_extend_schema, fields_to_mdfrom catalog.api.examples import (audio_complain_201_example,audio_complain_curl,@@ -23,12 +15,15 @@ from catalog.api.examples import (audio_search_list_curl,audio_stats_200_example,audio_stats_curl,+ audio_waveform_200_example,+ audio_waveform_404_example,+ audio_waveform_curl,)from catalog.api.serializers.audio_serializers import (AudioReportRequestSerializer,AudioSearchRequestSerializer,- AudioSearchSerializer,AudioSerializer,+ AudioWaveformSerializer,)from catalog.api.serializers.error_serializers import (InputErrorSerializer,@@ -38,188 +33,86 @@ from catalog.api.serializers.media_serializers import MediaThumbnailRequestSeriafrom catalog.api.serializers.provider_serializers import ProviderSerializer-class AudioSearch(MediaSearch):- desc = f"""-audio_search is an API endpoint to search audio files using a query string.--By using this endpoint, you can obtain search results based on specified query and-optionally filter results by-{fields_to_md(AudioSearchRequestSerializer.fields_names)}.--{MediaSearch.desc}"""-- responses = {- "200": openapi.Response(- description="OK",- examples=audio_search_200_example,- schema=AudioSearchSerializer(many=True),- ),- "400": openapi.Response(- description="Bad Request",- examples=audio_search_400_example,- schema=InputErrorSerializer,- ),- }-- code_examples = [- {- "lang": "Bash",- "source": audio_search_list_curl,- },- ]-- swagger_setup = {- "operation_id": "audio_search",- "operation_description": desc,- "query_serializer": AudioSearchRequestSerializer,- "responses": responses,- "code_examples": code_examples,- }---class AudioStats(MediaStats):- desc = f"""-audio_stats is an API endpoint to get a list of all content providers and their-respective number of audio files in the Openverse catalog.--{MediaStats.desc}"""-- responses = {- "200": openapi.Response(- description="OK",- examples=audio_stats_200_example,- schema=ProviderSerializer(many=True),- )- }-- code_examples = [- {- "lang": "Bash",- "source": audio_stats_curl,- },- ]-- swagger_setup = {- "operation_id": "audio_stats",- "operation_description": desc,- "responses": responses,- "code_examples": code_examples,- }---class AudioDetail(MediaDetail):- desc = f"""-audio_detail is an API endpoint to get the details of a specified audio ID.--By using this endpoint, you can get audio details such as-{fields_to_md(AudioSerializer.Meta.fields)}.--{MediaDetail.desc}"""-- responses = {- "200": openapi.Response(- description="OK", examples=audio_detail_200_example, schema=AudioSerializer- ),- "404": openapi.Response(- description="OK",- examples=audio_detail_404_example,- schema=NotFoundErrorSerializer,- ),- }-- code_examples = [- {- "lang": "Bash",- "source": audio_detail_curl,- },- ]-- swagger_setup = {- "operation_id": "audio_detail",- "operation_description": desc,- "responses": responses,- "code_examples": code_examples,- }---class AudioRelated(MediaRelated):- desc = f"""-recommendations_audio_read is an API endpoint to get related audio files for a specified-audio ID.--By using this endpoint, you can get the details of related audio such as-{fields_to_md(AudioSerializer.Meta.fields)}.--{MediaRelated.desc}"""-- responses = {- "200": openapi.Response(- description="OK", examples=audio_related_200_example, schema=AudioSerializer- ),- "404": openapi.Response(- description="Not Found",- examples=audio_related_404_example,- schema=NotFoundErrorSerializer,- ),- }-- code_examples = [- {- "lang": "Bash",- "source": audio_related_curl,- },- ]-- swagger_setup = {- "operation_id": "audio_related",- "operation_description": desc,- "responses": responses,- "code_examples": code_examples,- }---class AudioComplain(MediaComplain):- desc = f"""-audio_report_create is an API endpoint to report an issue about a specified audio ID to-Openverse.--By using this endpoint, you can report an audio file if it infringes copyright, contains-mature or sensitive content and others.--{MediaComplain.desc}"""+search = custom_extend_schema(+ desc=f"""+ Search audio files using a query string.++ By using this endpoint, you can obtain search results based on specified+ query and optionally filter results by+ {fields_to_md(AudioSearchRequestSerializer.fields_names)}.++ Results are ranked in order of relevance and paginated on the basis of the+ `page` param. The `page_size` param controls the total number of pages.++ Although there may be millions of relevant records, only the most relevant+ several thousand records can be viewed. This is by design: the search+ endpoint should be used to find the top 10,000 most relevant results, not+ for exhaustive search or bulk download of every barely relevant result. As+ such, the caller should not try to access pages beyond `page_count`, or else+ the server will reject the query.""",+ params=AudioSearchRequestSerializer,+ res={+ 200: (AudioSerializer, audio_search_200_example),+ 400: (InputErrorSerializer, audio_search_400_example),+ },+ eg=[audio_search_list_curl],+ external_docs={+ "description": "Openverse Syntax Guide",+ "url": "https://openverse.org/search-help",+ },+)- responses = {- "201": openapi.Response(- description="OK",- examples=audio_complain_201_example,- schema=AudioReportRequestSerializer,- )- }+stats = custom_extend_schema(+ desc=f"""+ Get a list of all content providers and their respective number of+ audio files in the Openverse catalog.- code_examples = [- {- "lang": "Bash",- "source": audio_complain_curl,- }- ]+ By using this endpoint, you can obtain info about content providers such+ as {fields_to_md(ProviderSerializer.Meta.fields)}.""",+ res={200: (ProviderSerializer, audio_stats_200_example)},+ eg=[audio_stats_curl],+)- swagger_setup = {- "operation_id": "audio_report",- "operation_description": desc,- "responses": responses,- "code_examples": code_examples,- }+detail = custom_extend_schema(+ desc=f"""+ Get the details of a specified audio track.++ By using this endpoint, you can obtain info about audio files such as+ {fields_to_md(AudioSerializer.Meta.fields)}""",+ res={+ 200: (AudioSerializer, audio_detail_200_example),+ 404: (NotFoundErrorSerializer, audio_detail_404_example),+ },+ eg=[audio_detail_curl],+)+related = custom_extend_schema(+ desc=f"""+ Get related audio files for a specified audio track.++ By using this endpoint, you can get the details of related audio such as+ {fields_to_md(AudioSerializer.Meta.fields)}.""",+ res={+ 200: (AudioSerializer(many=True), audio_related_200_example),+ 404: (NotFoundErrorSerializer, audio_related_404_example),+ },+ eg=[audio_related_curl],+)-class AudioThumbnail:- desc = f"""-thumbnail is an API endpoint to retrieve the scaled down and compressed thumbnail-of the artwork of an audio track or its audio set.+report = custom_extend_schema(+ res={201: (AudioReportRequestSerializer, audio_complain_201_example)},+ eg=[audio_complain_curl],+)-{refer_sample}"""+thumbnail = extend_schema(+ parameters=[MediaThumbnailRequestSerializer],+ responses={200: OpenApiResponse(description="Thumbnail image")},+)- swagger_setup = {- "operation_id": "audio_thumbnail",- "operation_description": desc,- "query_serializer": MediaThumbnailRequestSerializer,- }+waveform = custom_extend_schema(+ res={+ 200: (AudioWaveformSerializer, audio_waveform_200_example),+ 404: (NotFoundErrorSerializer, audio_waveform_404_example),+ },+ eg=[audio_waveform_curl],+)diff --git a/api/catalog/api/docs/base_docs.py b/api/catalog/api/docs/base_docs.pynew file mode 100644index 000000000..44440eec5--- /dev/null+++ b/api/catalog/api/docs/base_docs.py@@ -0,0 +1,85 @@+from http.client import responses as http_responses+from textwrap import dedent++from drf_spectacular.openapi import AutoSchema, OpenApiResponse+from drf_spectacular.utils import OpenApiExample, extend_schema+++refer_curl = (+ "You can refer to the cURL request samples "+ "for examples on how to consume this endpoint."+)+++def fields_to_md(field_names):+ """+ Create a Markdown representation of the given list of names to use in Swagger docs.++ :param field_names: the list of field names to convert to Markdown+ :return: the names as a Markdown string+ """++ *all_but_last, last = field_names+ all_but_last = ", ".join([f"`{name}`" for name in all_but_last])+ return f"{all_but_last} and `{last}`"+++def custom_extend_schema(**kwargs):+ extend_args = {}++ description = kwargs.pop("desc", None)+ if description:+ description = dedent(description)+ extend_args["description"] = f"{description}\n\n{refer_curl}"++ parameters = kwargs.pop("params", [])+ if not isinstance(parameters, list):+ parameters = [parameters]+ if parameters:+ extend_args["parameters"] = parameters++ responses = kwargs.pop("res", {})+ if responses:+ responses = {+ code: OpenApiResponse(+ serializer,+ description=http_responses[code],+ examples=[+ OpenApiExample(+ http_responses[code], value=example["application/json"]+ )+ ]+ if example+ else [],+ )+ for code, (serializer, example) in responses.items()+ }+ extend_args["responses"] = responses++ eg = kwargs.pop("eg", [])+ if eg:+ # Docs: https://redocly.com/docs/api-reference-docs/specification-extensions/x-code-samples/+ extend_args["extensions"] = {+ "x-codeSamples": [{"lang": "cURL", "source": example} for example in eg]+ }++ return extend_schema(**extend_args, **kwargs)+++class MediaSchema(AutoSchema):+ """+ Overrides the default schema generator provided by drf-spectacular to adapt+ to the conventions of the Openverse API documentation.+ """++ def get_description(self) -> str:+ return f"""{super().get_description()}\n\n{refer_curl}"""++ def get_operation_id(self) -> str:+ operation_tokens = super().get_operation_id().split("_")[0:-1]+ if self.method == "GET" and len(operation_tokens) == 1:+ if self._is_list_view():+ operation_tokens.append("search")+ else:+ operation_tokens.append("detail")+ return "_".join(operation_tokens)diff --git a/api/catalog/api/docs/image_docs.py b/api/catalog/api/docs/image_docs.pyindex 933228a82..7fafb8d4d 100644--- a/api/catalog/api/docs/image_docs.py+++ b/api/catalog/api/docs/image_docs.py@@ -1,14 +1,6 @@-from drf_yasg import openapi+from drf_spectacular.utils import OpenApiResponse, extend_schema-from catalog.api.docs.media_docs import (- MediaComplain,- MediaDetail,- MediaRelated,- MediaSearch,- MediaStats,- fields_to_md,- refer_sample,-)+from catalog.api.docs.base_docs import custom_extend_schema, fields_to_mdfrom catalog.api.examples import (image_complain_201_example,image_complain_curl,@@ -34,7 +26,6 @@ from catalog.api.serializers.error_serializers import (from catalog.api.serializers.image_serializers import (ImageReportRequestSerializer,ImageSearchRequestSerializer,- ImageSearchSerializer,ImageSerializer,OembedRequestSerializer,OembedSerializer,@@ -43,218 +34,91 @@ from catalog.api.serializers.media_serializers import MediaThumbnailRequestSeriafrom catalog.api.serializers.provider_serializers import ProviderSerializer-class ImageSearch(MediaSearch):- desc = f"""-image_search is an API endpoint to search images using a query string.--By using this endpoint, you can obtain search results based on specified query and-optionally filter results by-{fields_to_md(ImageSearchRequestSerializer.fields_names)}.--{MediaSearch.desc}"""-- responses = {- "200": openapi.Response(- description="OK",- examples=image_search_200_example,- schema=ImageSearchSerializer,- ),- "400": openapi.Response(- description="Bad Request",- examples=image_search_400_example,- schema=InputErrorSerializer,- ),- }-- code_examples = [- {- "lang": "Bash",- "source": image_search_list_curl,- },- ]-- swagger_setup = {- "operation_id": "image_search",- "operation_description": desc,- "query_serializer": ImageSearchRequestSerializer,- "responses": responses,- "code_examples": code_examples,- }---class ImageStats(MediaStats):- desc = f"""-image_stats is an API endpoint to get a list of all content providers and their-respective number of images in the Openverse catalog.--{MediaStats.desc}"""-- responses = {- "200": openapi.Response(- description="OK",- examples=image_stats_200_example,- schema=ProviderSerializer(many=True),- )- }-- code_examples = [- {- "lang": "Bash",- "source": image_stats_curl,- }- ]-- swagger_setup = {- "operation_id": "image_stats",- "operation_description": desc,- "responses": responses,- "code_examples": code_examples,- }---class ImageDetail(MediaDetail):- desc = f"""-image_detail is an API endpoint to get the details of a specified image ID.--By using this endpoint, you can image details such as-{fields_to_md(ImageSerializer.Meta.fields)}.--{MediaDetail.desc}"""-- responses = {- "200": openapi.Response(- description="OK", examples=image_detail_200_example, schema=ImageSerializer- ),- "404": openapi.Response(- description="Not Found",- examples=image_detail_404_example,- schema=NotFoundErrorSerializer,- ),- }-- code_examples = [{"lang": "Bash", "source": image_detail_curl}]-- swagger_setup = {- "operation_id": "image_detail",- "operation_description": desc,- "responses": responses,- "code_examples": code_examples,- }---class ImageRelated(MediaRelated):- desc = f"""-recommendations_images_read is an API endpoint to get related images for a specified-image ID.--By using this endpoint, you can get the details of related images such as-{fields_to_md(ImageSerializer.Meta.fields)}.--{MediaRelated.desc}"""-- responses = {- "200": openapi.Response(- description="OK", examples=image_related_200_example, schema=ImageSerializer- ),- "404": openapi.Response(- description="Not Found",- examples=image_related_404_example,- schema=NotFoundErrorSerializer,- ),- }-- code_examples = [{"lang": "Bash", "source": image_related_curl}]-- swagger_setup = {- "operation_id": "image_related",- "operation_description": desc,- "responses": responses,- "code_examples": code_examples,- }---class ImageComplain(MediaComplain):- desc = f"""-images_report_create is an API endpoint to report an issue about a specified image ID to-Openverse.--By using this endpoint, you can report an image if it infringes copyright, contains-mature or sensitive content and others.--{MediaComplain.desc}"""-- responses = {- "201": openapi.Response(- description="OK",- examples=image_complain_201_example,- schema=ImageReportRequestSerializer,- )- }-- code_examples = [- {- "lang": "Bash",- "source": image_complain_curl,- }- ]-- swagger_setup = {- "operation_id": "image_report",- "operation_description": desc,- "responses": responses,- "code_examples": code_examples,- }---class ImageOembed:- desc = f"""-oembed is an API endpoint to retrieve the structured data for a specified image URL in-the oEmbed format, which can be used to embed the image on the consumer's website.-Only JSON format is supported. The oEmbed specification is available-at https://oembed.com/.--By using this endpoint, you can retrieve a JSON oembed object containing the following-properties: `version`, `type`, `width`, `height`, `title`, `author_name`, `author_url`-and `license_url`.+search = custom_extend_schema(+ desc=f"""+ Search images using a query string.++ By using this endpoint, you can obtain search results based on specified+ query and optionally filter results by+ {fields_to_md(ImageSearchRequestSerializer.fields_names)}.++ Results are ranked in order of relevance and paginated on the basis of the+ `page` param. The `page_size` param controls the total number of pages.++ Although there may be millions of relevant records, only the most relevant+ several thousand records can be viewed. This is by design: the search+ endpoint should be used to find the top 10,000 most relevant results, not+ for exhaustive search or bulk download of every barely relevant result. As+ such, the caller should not try to access pages beyond `page_count`, or else+ the server will reject the query.""",+ params=ImageSearchRequestSerializer,+ res={+ 200: (ImageSerializer, image_search_200_example),+ 400: (InputErrorSerializer, image_search_400_example),+ },+ eg=[image_search_list_curl],+ external_docs={+ "description": "Openverse Syntax Guide",+ "url": "https://search.creativecommons.org/search-help",+ },+)-{refer_sample}"""+stats = custom_extend_schema(+ desc=f"""+ Get a list of all content providers and their respective number of+ images in the Openverse catalog.- responses = {- "200": openapi.Response(- description="OK", examples=image_oembed_200_example, schema=OembedSerializer- ),- "404": openapi.Response(- description="Not Found",- examples=image_oembed_404_example,- schema=NotFoundErrorSerializer,- ),- }+ By using this endpoint, you can obtain info about content providers such+ as {fields_to_md(ProviderSerializer.Meta.fields)}.""",+ res={200: (ProviderSerializer, image_stats_200_example)},+ eg=[image_stats_curl],+)- code_examples = [- {- "lang": "Bash",- "source": image_oembed_curl,- },- ]+detail = custom_extend_schema(+ desc=f"""+ Get the details of a specified image.++ By using this endpoint, you can obtain info about images such as+ {fields_to_md(ImageSerializer.Meta.fields)}""",+ res={+ 200: (ImageSerializer, image_detail_200_example),+ 404: (NotFoundErrorSerializer, image_detail_404_example),+ },+ eg=[image_detail_curl],+)- swagger_setup = {- "operation_id": "image_oembed",- "operation_description": desc,- "query_serializer": OembedRequestSerializer,- "responses": responses,- "code_examples": code_examples,- }+related = custom_extend_schema(+ desc=f"""+ Get related images for a specified image.++ By using this endpoint, you can get the details of related images such as+ {fields_to_md(ImageSerializer.Meta.fields)}.""",+ res={+ 200: (ImageSerializer, image_related_200_example),+ 404: (NotFoundErrorSerializer, image_related_404_example),+ },+ eg=[image_related_curl],+)+report = custom_extend_schema(+ res={201: (ImageReportRequestSerializer, image_complain_201_example)},+ eg=[image_complain_curl],+)-class ImageThumbnail:- desc = f"""-thumbnail is an API endpoint to retrieve the scaled down and compressed thumbnail-of an image.+thumbnail = extend_schema(+ parameters=[MediaThumbnailRequestSerializer],+ responses={200: OpenApiResponse(description="Thumbnail image")},+)-{refer_sample}"""+oembed = custom_extend_schema(+ params=OembedRequestSerializer,+ res={+ 200: (OembedSerializer, image_oembed_200_example),+ 404: (NotFoundErrorSerializer, image_oembed_404_example),+ },+ eg=[image_oembed_curl],+)- swagger_setup = {- "operation_id": "image_thumbnail",- "operation_description": desc,- "query_serializer": MediaThumbnailRequestSerializer,- }+watermark = custom_extend_schema(+ deprecated=True,+)diff --git a/api/catalog/api/docs/media_docs.py b/api/catalog/api/docs/media_docs.pydeleted file mode 100644index e39895d8b..000000000--- a/api/catalog/api/docs/media_docs.py+++ /dev/null@@ -1,62 +0,0 @@-refer_sample = """-You can refer to the cURL request samples for examples on how to consume this-endpoint.-"""---def fields_to_md(field_names):- """- Create a Markdown representation of the given list of names to use in Swagger docs.-- :param field_names: the list of field names to convert to Markdown- :return: the names as a Markdown string- """-- *all_but_last, last = field_names- all_but_last = ", ".join([f"`{name}`" for name in all_but_last])- return f"{all_but_last} and `{last}`"---class MediaSearch:- desc = f"""-Results are ranked in order of relevance and paginated on the basis of the `page` param.-The `page_size` param controls the total number of pages.--Although there may be millions of relevant records, only the most relevant several-thousand records can be viewed. This is by design: the search endpoint should be used to-find the top 10,000 most relevant results, not for exhaustive search or bulk download of-every barely relevant result. As such, the caller should not try to access pages beyond-`page_count`, or else the server will reject the query.--For more precise results, you can go to the-[Openverse Syntax Guide](https://search.creativecommons.org/search-help)-for information about creating queries and-[Apache Lucene Syntax Guide](https://lucene.apache.org/core/2_9_4/queryparsersyntax.html)-for information on structuring advanced searches.--{refer_sample}""" # noqa: E501---class MediaStats:- desc = f"""-You can use this endpoint to get details about content providers such as `source_name`,-`display_name`, and `source_url` along with a count of the number of individual items-indexed from them.--{refer_sample}"""---class MediaDetail:- desc = refer_sample---class MediaRelated:- desc = refer_sample---class MediaComplain:- desc = f"""-By using this endpoint, you can report a file if it infringes copyright, contains mature-or sensitive content and others.--{refer_sample}"""diff --git a/api/catalog/api/docs/oauth2_docs.py b/api/catalog/api/docs/oauth2_docs.pynew file mode 100644index 000000000..2f8b5445f--- /dev/null+++ b/api/catalog/api/docs/oauth2_docs.py@@ -0,0 +1,52 @@+from catalog.api.docs.base_docs import custom_extend_schema+from catalog.api.examples import (+ auth_key_info_200_example,+ auth_key_info_403_example,+ auth_key_info_curl,+ auth_register_201_example,+ auth_register_curl,+ auth_token_200_example,+ auth_token_curl,+)+from catalog.api.serializers.error_serializers import (+ ForbiddenErrorSerializer,+ InputErrorSerializer,+ InternalServerErrorSerializer,+)+from catalog.api.serializers.oauth2_serializers import (+ OAuth2ApplicationSerializer,+ OAuth2KeyInfoSerializer,+ OAuth2RegistrationSerializer,+ OAuth2TokenRequestSerializer,+ OAuth2TokenSerializer,+)+++register = custom_extend_schema(+ operation_id="register",+ request=OAuth2RegistrationSerializer,+ res={+ 201: (OAuth2ApplicationSerializer, auth_register_201_example),+ 400: (InputErrorSerializer, None),+ },+ eg=[auth_register_curl],+)++key_info = custom_extend_schema(+ operation_id="key_info",+ res={+ 200: (OAuth2KeyInfoSerializer, auth_key_info_200_example),+ 403: (ForbiddenErrorSerializer, auth_key_info_403_example),+ 500: (InternalServerErrorSerializer, None),+ },+ eg=[auth_key_info_curl],+)++token = custom_extend_schema(+ operation_id="token",+ request={"application/x-www-form-urlencoded": OAuth2TokenRequestSerializer},+ res={+ 200: (OAuth2TokenSerializer, auth_token_200_example),+ },+ eg=[auth_token_curl],+)diff --git a/api/catalog/api/examples/__init__.py b/api/catalog/api/examples/__init__.pyindex 4554dbec1..fa8283f7f 100644--- a/api/catalog/api/examples/__init__.py+++ b/api/catalog/api/examples/__init__.py@@ -5,6 +5,7 @@ from catalog.api.examples.audio_requests import (audio_search_curl,audio_search_list_curl,audio_stats_curl,+ audio_waveform_curl,)from catalog.api.examples.audio_responses import (audio_complain_201_example,@@ -15,6 +16,8 @@ from catalog.api.examples.audio_responses import (audio_search_200_example,audio_search_400_example,audio_stats_200_example,+ audio_waveform_200_example,+ audio_waveform_404_example,)from catalog.api.examples.image_requests import (image_complain_curl,@@ -37,6 +40,17 @@ from catalog.api.examples.image_responses import (image_search_400_example,image_stats_200_example,)+from catalog.api.examples.oauth2_requests import (+ auth_key_info_curl,+ auth_register_curl,+ auth_token_curl,+)+from catalog.api.examples.oauth2_responses import (+ auth_key_info_200_example,+ auth_key_info_403_example,+ auth_register_201_example,+ auth_token_200_example,+)audio_mappings = {diff --git a/api/catalog/api/examples/audio_requests.py b/api/catalog/api/examples/audio_requests.pyindex b817ede4f..f1b9128e3 100644--- a/api/catalog/api/examples/audio_requests.py+++ b/api/catalog/api/examples/audio_requests.py@@ -67,3 +67,10 @@ curl \\-d '{{"reason": "mature", "description": "This audio contains sensitive content"}}' \\"{origin}/v1/audio/{identifier}/report/""""++audio_waveform_curl = f"""+# Get the waveform of audio ID {identifier}+curl \\+ {auth} \\+ "{origin}/v1/audio/{identifier}/waveform/"+"""diff --git a/api/catalog/api/examples/audio_responses.py b/api/catalog/api/examples/audio_responses.pyindex c557b9d36..a65dff0bb 100644--- a/api/catalog/api/examples/audio_responses.py+++ b/api/catalog/api/examples/audio_responses.py@@ -143,3 +143,22 @@ audio_complain_201_example = {"description": "This audio contains sensitive content",}}++audio_waveform_200_example = {+ "application/json": {+ "len": 1083,+ "points": [+ 0.61275,+ 0.19593,+ 0.74023,+ # 1077 more entries+ 0.00089,+ 0.00043,+ 0.00049,+ ],+ }+}++audio_waveform_404_example = {+ "application/json": {"detail": "An internal server error occurred."}+}diff --git a/api/catalog/api/examples/oauth2_requests.py b/api/catalog/api/examples/oauth2_requests.pynew file mode 100644index 000000000..4b8222d89--- /dev/null+++ b/api/catalog/api/examples/oauth2_requests.py@@ -0,0 +1,31 @@+import os+++token = os.getenv("AUDIO_REQ_TOKEN", "DLBYIcfnKfolaXKcmMC8RIDCavc2hW")+origin = os.getenv("AUTH_REQ_ORIGIN", "https://api.openverse.engineering")++auth = f'-H "Authorization: Bearer {token}"' if token else ""++auth_register_curl = f"""+# Register for a key+curl \\+ -X POST \\+ -H "Content-Type: application/json" \\+ -d '{{"name": "My amazing project", "description": "To access Openverse API", "email": "[email protected]"}}' \\+ "{origin}/v1/auth_tokens/register/"+""" # noqa: E501++auth_token_curl = f"""+# Get an access token token+curl \\+ -X POST \\+ -H "Content-Type: application/x-www-form-urlencoded" \\+ -d 'grant_type=client_credentials&client_id=pm8GMaIXIhkjQ4iDfXLOvVUUcIKGYRnMlZYApbda&client_secret=YhVjvIBc7TuRJSvO2wIi344ez5SEreXLksV7GjalLiKDpxfbiM8qfUb5sNvcwFOhBUVzGNdzmmHvfyt6yU3aGrN6TAbMW8EOkRMOwhyXkN1iDetmzMMcxLVELf00BR2e' \\+ "{origin}/v1/auth_tokens/token/"+""" # noqa: E501++auth_key_info_curl = f"""+curl \\+ {auth} \\+ "{origin}/v1/rate_limit/"+"""diff --git a/api/catalog/api/examples/oauth2_responses.py b/api/catalog/api/examples/oauth2_responses.pynew file mode 100644index 000000000..d6859f6f5--- /dev/null+++ b/api/catalog/api/examples/oauth2_responses.py@@ -0,0 +1,29 @@+auth_register_201_example = {+ "application/json": {+ "name": "My amazing project",+ "client_id": "pm8GMaIXIhkjQ4iDfXLOvVUUcIKGYRnMlZYApbda",+ "client_secret": (+ "YhVjvIBc7TuRJSvO2wIi344ez5SEreXLksV7GjalLiKDpxfbiM8qfUb5sNvcwFOh"+ "BUVzGNdzmmHvfyt6yU3aGrN6TAbMW8EOkRMOwhyXkN1iDetmzMMcxLVELf00BR2e"+ ),+ }+}++auth_token_200_example = {+ "application/json": {+ "access_token": "DLBYIcfnKfolaXKcmMC8RIDCavc2hW",+ "scope": "read write groups",+ "expires_in": 36000,+ "token_type": "Bearer",+ }+}++auth_key_info_200_example = {+ "application/json": {+ "requests_this_minute": 2,+ "requests_today": 40,+ "rate_limit_model": "enhanced",+ }+}++auth_key_info_403_example = {"application/json": "Forbidden"}diff --git a/api/catalog/api/models/media.py b/api/catalog/api/models/media.pyindex 143f91315..e6f9dd4c5 100644--- a/api/catalog/api/models/media.py+++ b/api/catalog/api/models/media.py@@ -92,12 +92,7 @@ class AbstractMedia(@propertydef attribution(self) -> str:- """- The plain-text English attribution for a media item.-- Use this to credit creators for their work and fulfill legal attribution- requirements.- """+ """Legally valid attribution for the media item in plain-text English."""return get_attribution_text(self.title,diff --git a/api/catalog/api/serializers/audio_serializers.py b/api/catalog/api/serializers/audio_serializers.pyindex 40b8720e3..bf3f1ae16 100644--- a/api/catalog/api/serializers/audio_serializers.py+++ b/api/catalog/api/serializers/audio_serializers.py@@ -4,7 +4,6 @@ from elasticsearch_dsl.response import Hitfrom catalog.api.constants.field_order import field_position_mapfrom catalog.api.constants.field_values import AUDIO_CATEGORIES, LENGTHS-from catalog.api.docs.media_docs import fields_to_mdfrom catalog.api.models import Audio, AudioReport, AudioSetfrom catalog.api.serializers.fields import (EnumCharField,@@ -13,7 +12,6 @@ from catalog.api.serializers.fields import (from catalog.api.serializers.media_serializers import (MediaReportRequestSerializer,MediaSearchRequestSerializer,- MediaSearchSerializer,MediaSerializer,get_hyperlinks_serializer,get_search_request_source_serializer,@@ -172,23 +170,6 @@ class AudioSerializer(AudioHyperlinksSerializer, MediaSerializer):return output-class AudioSearchSerializer(MediaSearchSerializer):- """- The full audio search response.-- This serializer is purely representational and not actually used to serialize the- response.- """-- results = AudioSerializer(- many=True,- help_text=(- "An array of audios and their details such as "- f"{fields_to_md(AudioSerializer.Meta.fields)}."- ),- )--########################### Additional serializers ###########################diff --git a/api/catalog/api/serializers/error_serializers.py b/api/catalog/api/serializers/error_serializers.pyindex bc322f717..fddcc3696 100644--- a/api/catalog/api/serializers/error_serializers.py+++ b/api/catalog/api/serializers/error_serializers.py@@ -13,7 +13,10 @@ class InputErrorSerializer(serializers.Serializer):detail = serializers.DictField(help_text="Mapping of field names with errors from to that field.",- child=serializers.ListField(child=serializers.CharField()),+ child=serializers.ListField(+ help_text="List of errors for the field.",+ child=serializers.CharField(),+ ),)diff --git a/api/catalog/api/serializers/image_serializers.py b/api/catalog/api/serializers/image_serializers.pyindex 4fb5ebefb..61a7aeeff 100644--- a/api/catalog/api/serializers/image_serializers.py+++ b/api/catalog/api/serializers/image_serializers.py@@ -6,14 +6,12 @@ from catalog.api.constants.field_values import (IMAGE_CATEGORIES,IMAGE_SIZES,)-from catalog.api.docs.media_docs import fields_to_mdfrom catalog.api.models import Image, ImageReportfrom catalog.api.serializers.base import BaseModelSerializerfrom catalog.api.serializers.fields import EnumCharFieldfrom catalog.api.serializers.media_serializers import (MediaReportRequestSerializer,MediaSearchRequestSerializer,- MediaSearchSerializer,MediaSerializer,get_hyperlinks_serializer,get_search_request_source_serializer,@@ -105,33 +103,16 @@ class ImageSerializer(ImageHyperlinksSerializer, MediaSerializer):needs_db = True # for the 'height' and 'width' fields-class ImageSearchSerializer(MediaSearchSerializer):- """- The full image search response.-- This serializer is purely representational and not actually used to- serialize the response.- """-- results = ImageSerializer(- many=True,- help_text=(- "An array of images and their details such as "- f"{fields_to_md(ImageSerializer.Meta.fields)}."- ),- )--########################### Additional serializers ###########################class OembedRequestSerializer(serializers.Serializer):- """Parse and validate Oembed parameters."""+ """Parse and validate oEmbed parameters."""url = serializers.CharField(- help_text="The link to an image.",+ help_text="The link to an image present in Openverse.",)@staticmethoddiff --git a/api/catalog/api/serializers/media_serializers.py b/api/catalog/api/serializers/media_serializers.pyindex 266717355..5de4ca5e5 100644--- a/api/catalog/api/serializers/media_serializers.py+++ b/api/catalog/api/serializers/media_serializers.py@@ -6,6 +6,8 @@ from django.core.validators import MaxValueValidatorfrom rest_framework import serializersfrom rest_framework.exceptions import NotAuthenticated+from drf_spectacular.utils import extend_schema_serializer+from catalog.api.constants.licenses import LICENSE_GROUPSfrom catalog.api.constants.sorting import (DESCENDING,@@ -27,6 +29,15 @@ from catalog.api.utils.url import add_protocol#######################+@extend_schema_serializer(+ # Hide unstable fields from documentation, also see `field_names` below.+ exclude_fields=[+ "unstable__sort_by",+ "unstable__sort_dir",+ "unstable__authority",+ "unstable__authority_boost",+ ],+)class MediaSearchRequestSerializer(serializers.Serializer):"""This serializer parses and validates search query string parameters."""@@ -48,10 +59,11 @@ class MediaSearchRequestSerializer(serializers.Serializer):"extension","mature","qa",- # "unstable__sort_by", # excluding unstable fields- # "unstable__sort_dir", # excluding unstable fields- # "unstable__authority", # excluding unstable fields- # "unstable__authority_boost", # excluding unstable fields+ # Excluded unstable fields, also see `exclude_fields` above.+ # "unstable__sort_by",+ # "unstable__sort_dir",+ # "unstable__authority",+ # "unstable__authority_boost","page_size","page",]@@ -341,28 +353,6 @@ class TagSerializer(serializers.Serializer):)-class MediaSearchSerializer(serializers.Serializer):- """- This serializer serializes the full media search response.-- The class should be inherited by all individual media serializers.- """-- result_count = serializers.IntegerField(- help_text="The total number of items returned by search result.",- )- page_count = serializers.IntegerField(- help_text="The total number of pages returned by search result.",- )- page_size = serializers.IntegerField(- help_text="The number of items per page.",- )- page = serializers.IntegerField(- help_text="The current page number returned in the response.",- )- # ``results`` field added by child serializers--class MediaSerializer(BaseModelSerializer):"""This serializer serializes a single media file.@@ -458,6 +448,11 @@ class MediaSerializer(BaseModelSerializer):def get_search_request_source_serializer(media_type):+ media_path = {+ "image": "images",+ "audio": "audio",+ }[media_type]+class MediaSearchRequestSourceSerializer(serializers.Serializer):"""Parses and validates the source/not_source fields from the query params."""@@ -471,8 +466,10 @@ def get_search_request_source_serializer(media_type):"""_field_attrs = {- "help_text": make_comma_separated_help_text(- search_controller.get_sources(media_type).keys(), "data sources"+ "help_text": (+ "A comma separated list of data sources; valid values are "+ "``source_name``s from the stats endpoint: "+ f"https://api.openverse.engineering/v1/{media_path}/stats/."),"required": False,}diff --git a/api/catalog/api/serializers/oauth2_serializers.py b/api/catalog/api/serializers/oauth2_serializers.pyindex f41782d85..bff298365 100644--- a/api/catalog/api/serializers/oauth2_serializers.py+++ b/api/catalog/api/serializers/oauth2_serializers.py@@ -6,11 +6,52 @@ from catalog.api.models import OAuth2Registrationclass OAuth2RegistrationSerializer(serializers.ModelSerializer):+ name = serializers.CharField(+ help_text=(+ "A unique human-readable name for your application or project "+ "requiring access to the Openverse API."+ ),+ required=True,+ min_length=1,+ max_length=150,+ )+ description = serializers.CharField(+ help_text=(+ "A description of what you are trying to achieve with your project "+ "using the API. Please provide as much detail as possible!"+ ),+ min_length=1,+ max_length=10000,+ )+ email = serializers.EmailField(+ help_text=(+ "A valid email that we can reach you at if we have any questions "+ "about your use case or data consumption."+ ),+ min_length=1,+ max_length=254,+ )+class Meta:model = OAuth2Registrationfields = ("name", "description", "email")+class OAuth2ApplicationSerializer(serializers.Serializer):+ client_id = serializers.CharField(+ help_text="The unique, public identifier of your application.",+ )+ client_secret = serializers.CharField(+ help_text="The secret key used to authenticate your application.",+ )+ name = serializers.CharField(+ help_text="The name of your application or project.",+ )+ msg = serializers.CharField(+ help_text="Some additional information about the application.",+ )++class OAuth2RegistrationSuccessful(serializers.ModelSerializer):name = serializers.CharField(help_text="A unique human-readable name for your application "@@ -30,14 +71,13 @@ class OAuth2RegistrationSuccessful(serializers.ModelSerializer):fields = ("name", "client_id", "client_secret")-class OAuth2KeyInfo(serializers.Serializer):+class OAuth2KeyInfoSerializer(serializers.Serializer):requests_this_minute = serializers.IntegerField(- help_text="The number of requests your key has performed in the last "- "minute.",+ help_text="The number of requests your key has performed in the last minute.",allow_null=True,)requests_today = serializers.IntegerField(- help_text="The number of requests your key has performed in the last " "day.",+ help_text="The number of requests your key has performed in the last day.",allow_null=True,)rate_limit_model = serializers.CharField(@@ -46,3 +86,45 @@ class OAuth2KeyInfo(serializers.Serializer):"limits than their standard key counterparts. Contact ""Openverse if you need a higher rate limit.")+ verified = serializers.BooleanField(+ help_text="Whether the application has verified the submitted email address."+ )+++class OAuth2TokenRequestSerializer(serializers.Serializer):+ """+ Serializes a request for an access token.++ This is a dummy serializer for OpenAPI and is not actually used.+ """++ client_id = serializers.CharField(+ help_text="The unique, public identifier of your application.",+ )++ client_secret = serializers.CharField(+ help_text="The secret key used to authenticate your application.",+ )++ grant_type = serializers.ChoiceField(choices=["client_credentials"])+++class OAuth2TokenSerializer(serializers.Serializer):+ """+ Serializes the response for an access token.++ This is a dummy serializer for OpenAPI and is not actually used.+ """++ access_token = serializers.CharField(+ help_text="The access token that can be used to authenticate requests.",+ )+ token_type = serializers.CharField(+ help_text="The type of token. This will always be 'Bearer'.",+ )+ expires_in = serializers.IntegerField(+ help_text="The number of seconds until the token expires.",+ )+ scope = serializers.CharField(+ help_text="The scope of the token.",+ )diff --git a/api/catalog/api/serializers/provider_serializers.py b/api/catalog/api/serializers/provider_serializers.pyindex 62e567962..9cd199956 100644--- a/api/catalog/api/serializers/provider_serializers.py+++ b/api/catalog/api/serializers/provider_serializers.py@@ -1,8 +1,13 @@from rest_framework import serializers+from drf_spectacular.utils import extend_schema_serializer+from catalog.api.models import ContentProvider+@extend_schema_serializer(+ deprecate_fields=["logo_url"],+)class ProviderSerializer(serializers.ModelSerializer):source_name = serializers.CharField(source="provider_identifier",@@ -17,7 +22,8 @@ class ProviderSerializer(serializers.ModelSerializer):help_text="The URL of the source, e.g. https://www.flickr.com",)logo_url = serializers.ReadOnlyField(- default=None, help_text="Deprecated and unused. Always `null`."+ default=None,+ help_text="The URL to a logo for the source.",)media_count = serializers.SerializerMethodField(help_text="The number of media items indexed from the source.",diff --git a/api/catalog/api/utils/pagination.py b/api/catalog/api/utils/pagination.pyindex e438eb2b3..02e91be3f 100644--- a/api/catalog/api/utils/pagination.py+++ b/api/catalog/api/utils/pagination.py@@ -23,3 +23,24 @@ class StandardPagination(PageNumberPagination):"results": data,})++ def get_paginated_response_schema(self, schema):+ """+ Get the schema of the paginated response, used by `drf-spectacular` to+ generate the documentation of the paginated search results response.+ """++ field_descriptions = {+ "result_count": "The total number of items returned by search result.",+ "page_count": "The total number of pages returned by search result.",+ "page_size": "The number of items per page.",+ "page": "The current page number returned in the response.",+ }+ return {+ "type": "object",+ "properties": {+ field: {"type": "integer", "description": description}+ for field, description in field_descriptions.items()+ }+ | {"results": schema},+ }diff --git a/api/catalog/api/views/audio_views.py b/api/catalog/api/views/audio_views.pyindex 2c66a8f1e..03c067aba 100644--- a/api/catalog/api/views/audio_views.py+++ b/api/catalog/api/views/audio_views.py@@ -1,19 +1,19 @@from django.conf import settings-from django.utils.decorators import method_decoratorfrom rest_framework.decorators import actionfrom rest_framework.exceptions import APIException, NotFoundfrom rest_framework.response import Response-from drf_yasg.utils import swagger_auto_schema+from drf_spectacular.utils import extend_schema, extend_schema_viewfrom catalog.api.constants.media_types import AUDIO_TYPEfrom catalog.api.docs.audio_docs import (- AudioComplain,- AudioDetail,- AudioRelated,- AudioSearch,- AudioStats,- AudioThumbnail,+ detail,+ related,+ report,+ search,+ stats,+ thumbnail,+ waveform,)from catalog.api.models import Audiofrom catalog.api.serializers.audio_serializers import (@@ -30,13 +30,13 @@ from catalog.api.utils.throttle import (from catalog.api.views.media_views import MediaViewSet-@method_decorator(swagger_auto_schema(**AudioSearch.swagger_setup), "list")-@method_decorator(swagger_auto_schema(**AudioStats.swagger_setup), "stats")-@method_decorator(swagger_auto_schema(**AudioDetail.swagger_setup), "retrieve")-@method_decorator(swagger_auto_schema(**AudioRelated.swagger_setup), "related")-@method_decorator(swagger_auto_schema(**AudioComplain.swagger_setup), "report")-@method_decorator(swagger_auto_schema(**AudioThumbnail.swagger_setup), "thumbnail")-@method_decorator(swagger_auto_schema(auto_schema=None), "waveform")+@extend_schema(tags=["audio"])+@extend_schema_view(+ list=search,+ stats=stats,+ retrieve=detail,+ related=related,+)class AudioViewSet(MediaViewSet):"""Viewset for all endpoints pertaining to audio."""@@ -52,6 +52,7 @@ class AudioViewSet(MediaViewSet):# Extra actions+ @thumbnail@action(detail=True,url_path="thumb",@@ -60,6 +61,11 @@ class AudioViewSet(MediaViewSet):throttle_classes=[AnonThumbnailRateThrottle, OAuth2IdThumbnailRateThrottle],)def thumbnail(self, request, *_, **__):+ """+ Retrieve the scaled down and compressed thumbnail of the artwork of an+ audio track or its audio set.+ """+audio = self.get_object()image_url = None@@ -72,12 +78,21 @@ class AudioViewSet(MediaViewSet):return super().thumbnail(image_url, request)+ @waveform@action(detail=True,serializer_class=AudioWaveformSerializer,throttle_classes=[AnonThumbnailRateThrottle, OAuth2IdThumbnailRateThrottle],)def waveform(self, *_, **__):+ """+ Get the waveform peaks for an audio track.++ The peaks are provided as a list of numbers, each of these numbers being+ a fraction between 0 and 1. The list contains approximately 1000 numbers,+ although it can be slightly higher or lower, depending on the track's length.+ """+audio = self.get_object()try:@@ -88,10 +103,18 @@ class AudioViewSet(MediaViewSet):except Exception as e:raise APIException(getattr(e, "message", str(e)))+ @report@action(detail=True,methods=["post"],serializer_class=AudioReportRequestSerializer,)def report(self, request, identifier):+ """+ Report an issue about a specified audio track to Openverse.++ By using this endpoint, you can report an audio track if it infringes+ copyright, contains mature or sensitive content or some other reason.+ """+return super().report(request, identifier)diff --git a/api/catalog/api/views/health_views.py b/api/catalog/api/views/health_views.pyindex e83d2959d..8c2c2f8d5 100644--- a/api/catalog/api/views/health_views.py+++ b/api/catalog/api/views/health_views.py@@ -20,7 +20,7 @@ class HealthCheck(APIView):load balancer and destroyed."""- swagger_schema = None+ schema = None # Hide this view from the OpenAPI schema.@staticmethoddef _check_db() -> None:diff --git a/api/catalog/api/views/image_views.py b/api/catalog/api/views/image_views.pyindex 53b3fa6c9..ae574aecf 100644--- a/api/catalog/api/views/image_views.py+++ b/api/catalog/api/views/image_views.py@@ -4,26 +4,26 @@ import structfrom django.conf import settingsfrom django.http.response import FileResponse, HttpResponsefrom django.shortcuts import get_object_or_404-from django.utils.decorators import method_decoratorfrom rest_framework.decorators import actionfrom rest_framework.exceptions import NotFoundfrom rest_framework.response import Responseimport piexifimport requests-from drf_yasg.utils import swagger_auto_schema+from drf_spectacular.utils import extend_schema, extend_schema_viewfrom PIL import Image as PILImagefrom catalog.api.constants.media_types import IMAGE_TYPEfrom catalog.api.docs.image_docs import (- ImageComplain,- ImageDetail,- ImageOembed,- ImageRelated,- ImageSearch,- ImageStats,- ImageThumbnail,+ detail,+ oembed,+ related,+ report,+ search,+ stats,+ thumbnail,)+from catalog.api.docs.image_docs import watermark as watermark_docfrom catalog.api.models import Imagefrom catalog.api.serializers.image_serializers import (ImageReportRequestSerializer,@@ -42,14 +42,13 @@ from catalog.api.utils.watermark import watermarkfrom catalog.api.views.media_views import MediaViewSet-@method_decorator(swagger_auto_schema(**ImageSearch.swagger_setup), "list")-@method_decorator(swagger_auto_schema(**ImageStats.swagger_setup), "stats")-@method_decorator(swagger_auto_schema(**ImageDetail.swagger_setup), "retrieve")-@method_decorator(swagger_auto_schema(**ImageRelated.swagger_setup), "related")-@method_decorator(swagger_auto_schema(**ImageComplain.swagger_setup), "report")-@method_decorator(swagger_auto_schema(**ImageOembed.swagger_setup), "oembed")-@method_decorator(swagger_auto_schema(**ImageThumbnail.swagger_setup), "thumbnail")-@method_decorator(swagger_auto_schema(auto_schema=None), "watermark")+@extend_schema(tags=["images"])+@extend_schema_view(+ list=search,+ stats=stats,+ retrieve=detail,+ related=related,+)class ImageViewSet(MediaViewSet):"""Viewset for all endpoints pertaining to images."""@@ -69,6 +68,7 @@ class ImageViewSet(MediaViewSet):# Extra actions+ @oembed@action(detail=False,url_path="oembed",@@ -76,6 +76,14 @@ class ImageViewSet(MediaViewSet):serializer_class=OembedSerializer,)def oembed(self, request, *_, **__):+ """+ Retrieve the structured data for a specified image URL as per the+ [oEmbed spec](https://oembed.com/).++ This info can be used to embed the image on the consumer's website. Only+ JSON format is supported.+ """+params = OembedRequestSerializer(data=request.query_params)params.is_valid(raise_exception=True)@@ -97,6 +105,7 @@ class ImageViewSet(MediaViewSet):serializer = self.get_serializer(image, context=context)return Response(data=serializer.data)+ @thumbnail@action(detail=True,url_path="thumb",@@ -105,6 +114,8 @@ class ImageViewSet(MediaViewSet):throttle_classes=[AnonThumbnailRateThrottle, OAuth2IdThumbnailRateThrottle],)def thumbnail(self, request, *_, **__):+ """Retrieve the scaled down and compressed thumbnail of the image."""+image = self.get_object()image_url = image.url# Hotfix to use thumbnails for SMK images@@ -114,8 +125,17 @@ class ImageViewSet(MediaViewSet):return super().thumbnail(image_url, request)+ @watermark_doc@action(detail=True, url_path="watermark", url_name="watermark")- def watermark(self, request, *_, **__):+ def watermark(self, request, *_, **__): # noqa: D401+ """+ This endpoint is deprecated.++ ---++ 🚧 **TODO:** Document this.+ """+if not settings.WATERMARK_ENABLED:raise NotFound("The watermark feature is currently disabled.")@@ -174,12 +194,20 @@ class ImageViewSet(MediaViewSet):self._save_wrapper(watermarked, exif_bytes, response)return response+ @report@action(detail=True,methods=["post"],serializer_class=ImageReportRequestSerializer,)def report(self, request, identifier):+ """+ Report an issue about a specified image to Openverse.++ By using this endpoint, you can report an image if it infringes+ copyright, contains mature or sensitive content or some other reason.+ """+return super().report(request, identifier)# Helper functionsdiff --git a/api/catalog/api/views/media_views.py b/api/catalog/api/views/media_views.pyindex 77ef8f6e7..969ddb8ff 100644--- a/api/catalog/api/views/media_views.py+++ b/api/catalog/api/views/media_views.py@@ -11,15 +11,12 @@ from catalog.api.models import ContentProviderfrom catalog.api.serializers.provider_serializers import ProviderSerializerfrom catalog.api.utils import photonfrom catalog.api.utils.pagination import StandardPagination-from catalog.custom_auto_schema import CustomAutoSchemaparent_logger = logging.getLogger(__name__)class MediaViewSet(ReadOnlyModelViewSet):- swagger_schema = CustomAutoSchema-lookup_field = "identifier"# TODO: https://github.com/encode/django-rest-framework/pull/6789lookup_value_regex = (diff --git a/api/catalog/api/views/oauth2_views.py b/api/catalog/api/views/oauth2_views.pyindex c1aad087e..3a8840c25 100644--- a/api/catalog/api/views/oauth2_views.py+++ b/api/catalog/api/views/oauth2_views.py@@ -1,6 +1,7 @@import logging as logimport secretsimport smtplib+from textwrap import dedentfrom django.conf import settingsfrom django.core.cache import cache@@ -9,115 +10,43 @@ from rest_framework.response import Responsefrom rest_framework.reverse import reversefrom rest_framework.views import APIView-from drf_yasg import openapi-from drf_yasg.utils import swagger_auto_schema+from drf_spectacular.utils import extend_schemafrom oauth2_provider.generators import generate_client_secret+from oauth2_provider.views import TokenView as BaseTokenView-from catalog.api.docs.media_docs import refer_sample+from catalog.api.docs.oauth2_docs import key_info, register, tokenfrom catalog.api.models import OAuth2Verification, ThrottledApplication-from catalog.api.serializers.error_serializers import (- ForbiddenErrorSerializer,- InternalServerErrorSerializer,-)from catalog.api.serializers.oauth2_serializers import (- OAuth2KeyInfo,+ OAuth2KeyInfoSerializer,OAuth2RegistrationSerializer,- OAuth2RegistrationSuccessful,)from catalog.api.utils.oauth2_helper import get_token_infofrom catalog.api.utils.throttle import OnePerSecond, TenPerDay-from catalog.custom_auto_schema import CustomAutoSchema-from catalog.example_responses import (- key_info_200_example,- key_info_403_example,- key_info_500_example,- register_api_oauth2_201_example,-)+@extend_schema(tags=["auth"])class Register(APIView):- swagger_schema = CustomAutoSchema- register_api_oauth2_description = f"""-register_api_oauth2 is an API endpoint to register access to the API via OAuth2.+ throttle_classes = (TenPerDay,)-Upon registering, you will receive a `client_id` and `client_secret`, which you can then-use to authenticate using the standard OAuth2 Client Credentials flow. See the Register-and Authenticate section for instructions on registering access to the API via OAuth2.+ @register+ def post(self, request, format=None):+ """+ Register an application to access to API via OAuth2.-> **WARNING:** You must keep `client_secret` confidential, as anybody with your-> `client_secret` can impersonate your application.+ Upon registering, you will receive a `client_id` and `client_secret`,+ which you can then use to authenticate using the standard OAuth2 flow.-Authenticated users have higher rate limits than anonymous users. Additionally, by-identifying yourself, you can request Openverse to adjust your personal rate limit-depending on your organization's needs.+ > ⚠️ **WARNINGS:**+ > - Store your `client_id` and `client_secret` because you will not be+ > able to retrieve them later.+ > - You must keep `client_secret` confidential, as anybody with your+ > `client_secret` can impersonate your application.-{refer_sample}"""+ You must verify your email address by click the link sent to you in an+ email. Until you do that, the application will be subject to the same+ rate limits as an anonymous user.+ """- throttle_classes = (TenPerDay,)- register_api_oauth2_response = {- "201": openapi.Response(- description="OK",- examples=register_api_oauth2_201_example,- schema=OAuth2RegistrationSuccessful,- )- }-- register_api_oauth2_bash = """-# Register for a key-curl \\- -X POST \\- -H "Content-Type: application/json" \\- -d '{"name": "My amazing project", "description": "To access Openverse API", "email": "[email protected]"}' \\- https://api.openverse.engineering/v1/auth_tokens/register/-""" # noqa: E501-- register_api_oauth2_request = openapi.Schema(- type=openapi.TYPE_OBJECT,- required=["name", "description", "email"],- properties={- "name": openapi.Schema(- title="Name",- type=openapi.TYPE_STRING,- min_length=1,- max_length=150,- description="A unique human-readable name for your application "- "or project requiring access to the Openverse API.",- ),- "description": openapi.Schema(- title="Description",- type=openapi.TYPE_STRING,- min_length=1,- max_length=10000,- description="A description of what you are trying to achieve "- "with your project using the API. Please provide "- "as much detail as possible!",- ),- "email": openapi.Schema(- title="Email",- type=openapi.TYPE_STRING,- min_length=1,- max_length=254,- format=openapi.FORMAT_EMAIL,- description="A valid email that we can reach you at if we "- "have any questions about your use case or "- "data consumption.",- ),- },- example={- "name": "My amazing project",- "description": "To access Openverse API",- "email": "[email protected]",- },- )-- @swagger_auto_schema(- operation_id="register_api_oauth2",- operation_description=register_api_oauth2_description,- request_body=register_api_oauth2_request,- responses=register_api_oauth2_response,- code_examples=[{"lang": "Bash", "source": register_api_oauth2_bash}],- )- def post(self, request, format=None):# Store the registration information the developer gave us.serialized = OAuth2RegistrationSerializer(data=request.data)if not serialized.is_valid():@@ -146,13 +75,15 @@ curl \\verification.save()token = verification.codelink = request.build_absolute_uri(reverse("verify-email", [token]))- verification_msg = f"""-To verify your Openverse API credentials, click on the following link:+ verification_msg = dedent(+ f"""+ To verify your Openverse API credentials, click on the following link:-{link}+ {link}-If you believe you received this message in error, please disregard it.+ If you believe you received this message in error, please disregard it."""+ )try:send_mail(subject="Verify your API credentials",@@ -179,7 +110,7 @@ If you believe you received this message in error, please disregard it.class VerifyEmail(APIView):"""Enable a user's OAuth2 key upon visiting the emailed verification link."""- swagger_schema = None+ schema = None # Hide this view from the OpenAPI schema.def get(self, request, code, format=None):try:@@ -204,49 +135,45 @@ class VerifyEmail(APIView):)-class CheckRates(APIView):- swagger_schema = CustomAutoSchema- key_info_description = f"""-key_info is an API endpoint to get information about your API key.+@extend_schema(tags=["auth"])+class TokenView(BaseTokenView, APIView):+ @token+ def post(self, *args, **kwargs):+ """+ Get an access token using client credentials.++ To authenticate your requests to the Openverse API, you need to provide+ an access token as a bearer token in the `Authorization` header of your+ requests. This endpoints takes your client ID and secret, and issues an+ access token.++ > **NOTE:** This endpoint only accepts data as+ > `application/x-www-form-urlencoded`. Any other encoding will not work.-You can use this endpoint to get information about your API key such as-`requests_this_minute`, `requests_today`, and `rate_limit_model`.+ Once your access token expires, you can request another one from this+ endpoint.+ """-> **NOTE:** If you get a 403 Forbidden response, it means your access token has expired.+ return super().post(*args, **kwargs)-{refer_sample}"""+@extend_schema(tags=["auth"])+class CheckRates(APIView):throttle_classes = (OnePerSecond,)- key_info_response = {- "200": openapi.Response(- description="OK", examples=key_info_200_example, schema=OAuth2KeyInfo- ),- "403": openapi.Response(- description="Forbidden",- examples=key_info_403_example,- schema=ForbiddenErrorSerializer,- ),- "500": openapi.Response(- description="Internal Server Error",- examples=key_info_500_example,- schema=InternalServerErrorSerializer,- ),- }-- key_info_bash = """-curl \\- -H "Authorization: Bearer DLBYIcfnKfolaXKcmMC8RIDCavc2hW" \\- http://api.openverse.engineering/v1/rate_limit/-"""-- @swagger_auto_schema(- operation_id="key_info",- operation_description=key_info_description,- responses=key_info_response,- code_examples=[{"lang": "Bash", "source": key_info_bash}],- )+ @key_infodef get(self, request, format=None):+ """+ Get information about your API key.++ You can use this endpoint to get information about your API key such as+ `requests_this_minute`, `requests_today`, and `rate_limit_model`.++ > ℹ️ **NOTE:** If you get a 403 Forbidden response, it means your access+ > token has expired.+ """++ # TODO: Replace 403 responses with DRF `authentication_classes`.if not request.auth:return Response(status=403, data="Forbidden")@@ -278,6 +205,7 @@ curl \\scope="exempt_oauth2_client_credentials_burst", client_id=client_id)else:+ # TODO: Replace 500 response with exception.return Response(status=500, data="Unknown API key rate limit type")sustained_requests_list = cache.get(sustained_throttle_key)@@ -287,10 +215,12 @@ curl \\burst_requests_list = cache.get(burst_throttle_key)burst_requests = len(burst_requests_list) if burst_requests_list else None- response_data = {- "requests_this_minute": burst_requests,- "requests_today": sustained_requests,- "rate_limit_model": throttle_type,- "verified": verified,- }- return Response(status=200, data=response_data)+ response_data = OAuth2KeyInfoSerializer(+ {+ "requests_this_minute": burst_requests,+ "requests_today": sustained_requests,+ "rate_limit_model": throttle_type,+ "verified": verified,+ }+ )+ return Response(status=200, data=response_data.data)diff --git a/api/catalog/configuration/spectacular.py b/api/catalog/configuration/spectacular.pynew file mode 100644index 000000000..b3cc142e3--- /dev/null+++ b/api/catalog/configuration/spectacular.py@@ -0,0 +1,87 @@+from textwrap import dedent++from decouple import config+++SPECTACULAR_SETTINGS = {+ "TITLE": "Openverse API",+ "DESCRIPTION": dedent(+ """+ Openverse is a search engine for openly-licensed media. The Openverse+ API is a system that allows programmatic access to public domain digital+ media. It is our ambition to index and catalog billions of+ openly-licensed works, including articles, songs, videos, photographs,+ paintings, and more. Using this API, developers will be able to access+ the digital commons in their own applications.+ """+ ),+ "TOS": "https://docs.openverse.org/terms_of_service.html",+ "CONTACT": {+ "name": "Openverse",+ "email": "[email protected]",+ },+ "LICENSE": {+ "name": "MIT License",+ "url": "https://github.com/WordPress/openverse/blob/main/LICENSE",+ },+ "VERSION": config("SEMANTIC_VERSION", default="Version not specified"),+ "EXTERNAL_DOCS": {+ "description": "Openverse documentation",+ "url": "http://docs.openverse.org/api/user/index.html",+ },+ "SERVE_INCLUDE_SCHEMA": False,+ "SORT_OPERATION_PARAMETERS": False,+ "EXTENSIONS_INFO": {+ "x-logo": {+ "url": "https://raw.githubusercontent.com/WordPress/openverse/HEAD/brand/logo.svg",+ "backgroundColor": "#fafafa",+ }+ },+ "TAGS": [+ {+ "name": "auth",+ "description": dedent(+ """+ The API has rate-limiting and throttling in place to prevent+ abuse. In the response for each request that is subject to+ rate-limits, you can see the `X-RateLimit-` headers for info+ about your permitted and available usage. Exceeding the limit+ will result in '429: Too Many Requests' responses.++ - Anonymous clients are limited to make 5 req/hour and+ 100 req/day. Therefore we recommend registering for+ authenticated usage.++ - Authenticated clients can make 100 req/minute and 10,000+ req/day. Additionally, you can request a higher limit to fit+ your application's needs.++ To authenticate yourself, you must sign up for an API key using+ the `register` endpoint and then get an access token using the+ `token` endpoint. Read on to know about these endpoints.++ In subsequent requests, include your access token as a bearer+ token in the `Authorization` header.++ ```+ Authorization: Bearer <access_token>+ ```+ """+ ),+ },+ {+ "name": "audio",+ "description": "These are endpoints pertaining to audio files.",+ },+ {+ "name": "images",+ "description": "These are endpoints pertaining to images.",+ },+ ],+ "REDOC_UI_SETTINGS": {+ "theme": {+ "logo": {"gutter": "20px"},+ "typography": {"headings": {"fontFamily": "inherit", "fontWeight": 700}},+ }+ },+}diff --git a/api/catalog/custom_auto_schema.py b/api/catalog/custom_auto_schema.pydeleted file mode 100644index 825a51234..000000000--- a/api/catalog/custom_auto_schema.py+++ /dev/null@@ -1,52 +0,0 @@-from drf_yasg import openapi-from drf_yasg.inspectors import SwaggerAutoSchema-from drf_yasg.utils import filter_none, force_real_str---class CustomAutoSchema(SwaggerAutoSchema):- def get_pagination_parameters(self):- """- Set pagination params to an empty list.-- Since the pagination params are a part of the ``MediaSearchRequestSerializer``,- they need not be added again as pagination params.- """-- return []-- def get_operation(self, operation_keys=None):- operation_keys = operation_keys or self.operation_keys-- consumes = self.get_consumes()- produces = self.get_produces()-- body = self.get_request_body_parameters(consumes)- query = self.get_query_parameters()- parameters = body + query- parameters = filter_none(parameters)- parameters = self.add_manual_parameters(parameters)-- operation_id = self.get_operation_id(operation_keys)- summary, description = self.get_summary_and_description()- security = self.get_security()- assert security is None or isinstance(- security, list- ), "security must be a list of security requirement objects"- deprecated = self.is_deprecated()- tags = self.get_tags(operation_keys)-- responses = self.get_responses()-- return openapi.Operation(- operation_id=operation_id,- description=force_real_str(description),- summary=force_real_str(summary),- responses=responses,- parameters=parameters,- consumes=consumes,- produces=produces,- tags=tags,- security=security,- deprecated=deprecated,- **{"x-code-samples": self.overrides.get("code_examples")}- )diff --git a/api/catalog/example_responses.py b/api/catalog/example_responses.pydeleted file mode 100644index 53bf84c5c..000000000--- a/api/catalog/example_responses.py+++ /dev/null@@ -1,24 +0,0 @@-client_secret = (- "YhVjvIBc7TuRJSvO2wIi344ez5SEreXLksV7GjalLiKDpxfbiM8qfUb5sNvcwFOh"- "BUVzGNdzmmHvfyt6yU3aGrN6TAbMW8EOkRMOwhyXkN1iDetmzMMcxLVELf00BR2e"-)--register_api_oauth2_201_example = {- "application/json": {- "name": "My amazing project",- "client_id": "pm8GMaIXIhkjQ4iDfXLOvVUUcIKGYRnMlZYApbda",- "client_secret": client_secret,- }-}--key_info_200_example = {- "application/json": {- "requests_this_minute": 2,- "requests_today": 40,- "rate_limit_model": "enhanced",- }-}--key_info_403_example = {"application/json": "Forbidden"}--key_info_500_example = {"application/json": "Unknown API key rate limit type"}diff --git a/api/catalog/management/commands/validateopenapischema.py b/api/catalog/management/commands/validateopenapischema.pydeleted file mode 100644index da51e424e..000000000--- a/api/catalog/management/commands/validateopenapischema.py+++ /dev/null@@ -1,42 +0,0 @@-from argparse import ArgumentParser-from pathlib import Path--from django.core.management import BaseCommand, call_command--from openapi_spec_validator import validate_spec-from openapi_spec_validator.readers import read_from_filename-from openapi_spec_validator.validation import openapi_v2_spec_validator---class Command(BaseCommand):- def add_arguments(self, parser: ArgumentParser):- parser.add_argument(- "--output-dir",- default=Path(".").absolute(),- help=(- "The direction into which to output the spec file. "- "Defaults the the current working directory."- ),- )-- def handle_validation(self, spec_dict: dict):- """Validate the spec and raise an error if the spec is not valid."""-- validate_spec(spec_dict, validator=openapi_v2_spec_validator)-- invalid_paths = [p for p in spec_dict["paths"].keys() if not p.endswith("/")]-- assert invalid_paths == [], (- "All paths must end with a trailing slash. "- f"Found {len(invalid_paths)} missing a trailing "- f"slash: {', '.join(invalid_paths)}"- )-- def handle(self, *args, **options):- file_path = (Path(options["output_dir"]).absolute() / "openapi.yaml").absolute()- call_command("generate_swagger", file_path, overwrite=True)- spec_dict, spec_url = read_from_filename(file_path)- self.handle_validation(spec_dict)- # Only remove the file when there are no errros to ease debugging.- # Therefore, we don't `try/except` the call to `handle_validation`- file_path.unlink()diff --git a/api/catalog/settings.py b/api/catalog/settings.pyindex 5feab7cca..fc517452e 100644--- a/api/catalog/settings.py+++ b/api/catalog/settings.py@@ -25,6 +25,7 @@ from catalog.configuration.link_validation_cache import (LinkValidationCacheExpiryConfiguration,)from catalog.configuration.logging import DJANGO_DB_LOGGING, LOGGING+from catalog.configuration.spectacular import SPECTACULAR_SETTINGS# Build paths inside the project like this: BASE_DIR.join('dir', 'subdir'...)@@ -71,7 +72,6 @@ USE_S3 = config("USE_S3", default=False, cast=bool)INSTALLED_APPS = ["catalog","catalog.api",- "drf_yasg","django.contrib.admin","django.contrib.auth","django.contrib.contenttypes",@@ -82,6 +82,7 @@ INSTALLED_APPS = ["rest_framework","corsheaders","sslserver",+ "drf_spectacular",]if USE_S3:@@ -171,6 +172,7 @@ REST_FRAMEWORK = {"exempt_oauth2_client_credentials": None,},"EXCEPTION_HANDLER": "catalog.api.utils.exceptions.exception_handler",+ "DEFAULT_SCHEMA_CLASS": "catalog.api.docs.base_docs.MediaSchema",}if config("DISABLE_GLOBAL_THROTTLING", default=True, cast=bool):diff --git a/api/catalog/templates/drf-yasg/redoc.html b/api/catalog/templates/drf-yasg/redoc.htmldeleted file mode 100644index 6270fe23f..000000000--- a/api/catalog/templates/drf-yasg/redoc.html+++ /dev/null@@ -1,22 +0,0 @@-{% extends "drf-yasg/redoc.html" %}--{% block favicon %}- <link- rel="icon"- type="image/svg"- href="https://raw.githubusercontent.com/WordPress/openverse/master/brand/icon.svg"/>-{% endblock %}--{% block extra_styles %}- <style>- img[alt="logo"] {- padding: 20px; /* same as other sidebar items */- }-- /* Hide fields that are unstable and likely to change */- td[kind="field"][title^="unstable__"],- td[kind="field"][title^="unstable__"] ~ td {- display: none- }- </style>-{% endblock %}diff --git a/api/catalog/urls/__init__.py b/api/catalog/urls/__init__.pyindex 1458e2f81..9a0e30a29 100644--- a/api/catalog/urls/__init__.py+++ b/api/catalog/urls/__init__.py@@ -1,19 +1,8 @@"""This is the Openverse API URL configuration.-The `urlpatterns` list routes URLs to views. For more information please see:- https://docs.djangoproject.com/en/2.0/topics/http/urls/--Examples:-Function views- 1. Add an import: from my_app import views- 2. Add a URL to urlpatterns: path('', views.home, name='home')-Class-based views- 1. Add an import: from other_app.views import Home- 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')-Including another URLconf- 1. Import the include() function: from django.urls import include, path- 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))+The `urlpatterns` list routes URLs to views. For more information please refer+to the [documentation](https://docs.djangoproject.com/en/2.0/topics/http/urls/)."""from django.conf.urls import include@@ -22,13 +11,18 @@ from django.urls import path, re_pathfrom django.views.generic import RedirectViewfrom rest_framework.routers import SimpleRouter+from drf_spectacular.views import (+ SpectacularAPIView,+ SpectacularRedocView,+ SpectacularSwaggerView,+)+from catalog.api.utils.status_code_view import get_status_code_viewfrom catalog.api.views.audio_views import AudioViewSetfrom catalog.api.views.health_views import HealthCheckfrom catalog.api.views.image_views import ImageViewSetfrom catalog.api.views.oauth2_views import CheckRatesfrom catalog.urls.auth_tokens import urlpatterns as auth_tokens_patterns-from catalog.urls.swagger import urlpatterns as swagger_patternsdiscontinuation_message = {@@ -37,6 +31,11 @@ discontinuation_message = {}versioned_paths = [+ # OpenAPI+ path("", SpectacularRedocView.as_view(url_name="schema"), name="root"),+ path("swagger/", SpectacularSwaggerView.as_view(url_name="schema"), name="swagger"),+ path("schema/", SpectacularAPIView.as_view(api_version="v1"), name="schema"),+ # Authentication endpointspath("rate_limit/", CheckRates.as_view(), name="key_info"),path("auth_tokens/", include(auth_tokens_patterns)),# Deprecated, redirects to new URL@@ -79,8 +78,6 @@ urlpatterns = [path("", RedirectView.as_view(pattern_name="root")),path("admin/", admin.site.urls),path("healthcheck/", HealthCheck.as_view()),- # Swagger documentation- path("", include(swagger_patterns)),# APIpath("v1/", include(versioned_paths)),]diff --git a/api/catalog/urls/auth_tokens.py b/api/catalog/urls/auth_tokens.pyindex 344e3c12b..3c4e5c81a 100644--- a/api/catalog/urls/auth_tokens.py+++ b/api/catalog/urls/auth_tokens.py@@ -1,10 +1,11 @@from django.urls import include, path-from catalog.api.views.oauth2_views import Register, VerifyEmail+from catalog.api.views.oauth2_views import Register, TokenView, VerifyEmailurlpatterns = [path("register/", Register.as_view(), name="register"),path("verify/<str:code>/", VerifyEmail.as_view(), name="verify-email"),+ path("token/", TokenView.as_view(), name="token"),path("", include("oauth2_provider.urls", namespace="oauth2_provider")),]diff --git a/api/catalog/urls/swagger.py b/api/catalog/urls/swagger.pydeleted file mode 100644index 7a82ced14..000000000--- a/api/catalog/urls/swagger.py+++ /dev/null@@ -1,58 +0,0 @@-from django.conf import settings-from django.urls import re_path-from rest_framework.permissions import AllowAny--from drf_yasg import openapi-from drf_yasg.views import get_schema_view---description_path = settings.BASE_DIR.joinpath(- "catalog",- "api",- "docs",- "README.md",-)-with open(description_path) as description_file:- description = description_file.read()--tos_url = "https://docs.openverse.org/terms_of_service.html"-license_url = "https://github.com/WordPress/openverse/blob/HEAD/LICENSE"-logo_url = "https://raw.githubusercontent.com/WordPress/openverse/HEAD/brand/logo.svg"-open_api_info = openapi.Info(- title="Openverse API consumer docs",- default_version=settings.API_VERSION,- description=description,- contact=openapi.Contact(email=settings.CONTACT_EMAIL),- license=openapi.License(name="MIT License", url=license_url),- terms_of_service=tos_url,- x_logo={"url": logo_url, "backgroundColor": "#fafafa"},-)--schema_view = get_schema_view(- open_api_info,- public=True,- permission_classes=(AllowAny,),-)--cache_timeout = 0 if settings.DEBUG else 15--urlpatterns = [- re_path(- r"^swagger(?P<format>\.json|\.yaml)$",- schema_view.without_ui(cache_timeout=None),- name="schema-json",- ),- re_path(- r"^swagger/$",- schema_view.with_ui("swagger", cache_timeout=cache_timeout),- name="schema-swagger-ui",- ),- re_path(- r"^redoc/$",- schema_view.with_ui("redoc", cache_timeout=cache_timeout),- name="schema-redoc",- ),- re_path(- r"^v1/$", schema_view.with_ui("redoc", cache_timeout=cache_timeout), name="root"- ),-]diff --git a/api/justfile b/api/justfileindex 0c4db4c38..e40f28192 100644--- a/api/justfile+++ b/api/justfile@@ -116,7 +116,10 @@ test-local *args:# Run smoke test for the API docsdoc-test: wait-up- curl --fail 'http://localhost:50280/v1/?format=openapi'+ curl \+ -H 'Accept: application/vnd.oai.openapi+json' \+ --fail \+ 'http://localhost:50280/v1/schema/' > openapi.json########## NGINX #diff --git a/automations/python/workflows/set_matrix_images.py b/automations/python/workflows/set_matrix_images.pyindex c92c85e87..4599a6836 100644--- a/automations/python/workflows/set_matrix_images.py+++ b/automations/python/workflows/set_matrix_images.py@@ -1,4 +1,8 @@-"""Determine which Docker images to build and publish."""+"""+Determine which Docker images to build and publish. For more information refer+to the documentation:+https://docs.openverse.org/meta/ci_cd/jobs/docker_preparation.html#determine-images+"""import jsonimport os@@ -7,48 +11,55 @@ import syschanges = json.loads(os.environ.get("CHANGES"))-build_matrix = {"image": [], "include": []}-publish_matrix = {"image": []}-if "frontend" in changes:- build_matrix["image"].append("frontend")- build_matrix["include"].append(- {"image": "frontend", "context": "frontend", "target": "app"}- )- publish_matrix["image"].append("frontend")-if any(item in changes for item in ["api", "ingestion_server", "catalog"]):- build_matrix["image"].append("upstream_db")- build_matrix["include"].append(- {"image": "upstream_db", "context": "docker/upstream_db", "target": "db"}- )+def ser_set(x):+ """Convert ``set`` into ``list``, else return the parameter as-is."""+ return list(x) if isinstance(x, set) else x+++build_matrix = {"image": set()}+publish_matrix = {"image": set()}++includes = {+ "upstream_db": {+ "image": "upstream_db",+ "context": "docker/upstream_db",+ "target": "db",+ },+ "catalog": {"image": "catalog", "context": "catalog", "target": "cat"},+ "ingestion_server": {+ "image": "ingestion_server",+ "context": "ingestion_server",+ "target": "ing",+ },+ "api": {"image": "api", "context": "api", "target": "api"},+ "api_nginx": {"image": "api_nginx", "context": "api", "target": "nginx"},+ "frontend": {"image": "frontend", "context": "frontend", "target": "app"},+}+if "catalog" in changes:- build_matrix["image"].append("catalog")- build_matrix["include"].append(- {"image": "catalog", "context": "catalog", "target": "cat"}- )- publish_matrix["image"].append("catalog")-if "api" in changes or "ingestion_server" in changes:- # Always build the ingestion server and API images for either changeset- build_matrix["image"] += ["api", "ingestion_server"]- build_matrix["include"] += [- {"image": "ingestion_server", "context": "ingestion_server", "target": "ing"},- {"image": "api", "context": "api", "target": "api"},- ]- if "api" in changes:- build_matrix["image"].append("api_nginx")- build_matrix["include"].append(- {"image": "api_nginx", "context": "api", "target": "nginx"}- )- publish_matrix["image"] += ["api", "api_nginx"]- if "ingestion_server" in changes:- publish_matrix["image"].append("ingestion_server")+ build_matrix["image"] |= {"upstream_db", "catalog"}+ publish_matrix["image"].add("catalog")+if "ingestion_server" in changes:+ build_matrix["image"] |= {"upstream_db", "ingestion_server", "api"}+ publish_matrix["image"].add("ingestion_server")+if "api" in changes:+ build_matrix["image"] |= {"upstream_db", "ingestion_server", "api", "api_nginx"}+ publish_matrix["image"] |= {"api", "api_nginx"}+if "frontend" in changes:+ build_matrix["image"].add("frontend")+ publish_matrix["image"].add("frontend")++build_matrix["include"] = [includes[item] for item in build_matrix["image"]]do_build = "true" if len(build_matrix["image"]) else "false"do_publish = "true" if len(publish_matrix["image"]) else "false"+build_matrix = json.dumps(build_matrix, default=ser_set)+publish_matrix = json.dumps(publish_matrix, default=ser_set)-with open(os.environ.get("GITHUB_OUTPUT"), "a") as gh_out:+with open(os.environ.get("GITHUB_OUTPUT", "/dev/null"), "a") as gh_out:for dest in [sys.stdout, gh_out]:print(f"do_build={do_build}", file=dest)- print(f"build_matrix={json.dumps(build_matrix)}", file=dest)+ print(f"build_matrix={build_matrix}", file=dest)print(f"do_publish={do_publish}", file=dest)- print(f"publish_matrix={json.dumps(publish_matrix)}", file=dest)+ print(f"publish_matrix={publish_matrix}", file=dest)diff --git a/documentation/meta/ci_cd/flow.md b/documentation/meta/ci_cd/flow.mdindex fa34bd433..e2fcfceae 100644--- a/documentation/meta/ci_cd/flow.md+++ b/documentation/meta/ci_cd/flow.md@@ -242,7 +242,7 @@ flowchart TDAfter all the [proof-of-functionality](./proof_of_functionality.md) tests haveconcluded, we can initiate the stage of building the new documentation. The-documentation is published to the [docs site](https://docs.openvere.org)+documentation is published to the [docs site](https://docs.openverse.org)side-by-side with the [publishing of the Docker images](#docker-publishing).```{mermaid}