mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-19 05:58:34 +02:00
Bump djangorestframework to 3.11 and move to OpenAPI
See: https://www.django-rest-framework.org/community/3.10-announcement/ CoreAPI is being deprecated and since 3.10, settings must be modified to keep using CoreAPI schemas. This is especially required for the documentation generation. To prevent settings modification while upgrading Modoboa and to follow the standard for modeling Web APIs, CoreAPI is removed. Instead, OpenAPI is used to generate the schema and Swagger UI is used to render the documentation as described here: https://www.django-rest-framework.org/topics/documenting-your-api/
This commit is contained in:
+15
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "swagger-ui",
|
||||
"homepage": "https://github.com/wordnik/swagger-ui",
|
||||
"version": "3.24.3",
|
||||
"_release": "3.24.3",
|
||||
"_resolution": {
|
||||
"type": "version",
|
||||
"tag": "v3.24.3",
|
||||
"commit": "a86a63db045782dbfa48e056888fe85fc4ded050"
|
||||
},
|
||||
"_source": "https://github.com/wordnik/swagger-ui.git",
|
||||
"_target": "3.24.3",
|
||||
"_originalSource": "swagger-ui",
|
||||
"_direct": true
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
node_modules
|
||||
.idea
|
||||
.vscode
|
||||
.deps_check
|
||||
.DS_Store
|
||||
.nyc_output
|
||||
npm-debug.log*
|
||||
.eslintcache
|
||||
*.iml
|
||||
selenium-debug.log
|
||||
test/e2e/db.json
|
||||
docs/_book
|
||||
|
||||
flavors/**/dist/*
|
||||
|
||||
# Cypress
|
||||
test/e2e-cypress/screenshots
|
||||
test/e2e-cypress/videos
|
||||
|
||||
# Ignore files that we don't need for Modoboa
|
||||
.agignore
|
||||
.babelrc
|
||||
.dockerignore
|
||||
.editorconfig
|
||||
.eslintrc
|
||||
.gitattributes
|
||||
.npmignore
|
||||
.prettierrc.yaml
|
||||
Dockerfile
|
||||
composer.json
|
||||
cypress.json
|
||||
renovate.json
|
||||
snapcraft.yaml
|
||||
swagger-config.yaml
|
||||
.github/
|
||||
dev-helpers/
|
||||
docker/
|
||||
docs/
|
||||
flavors/
|
||||
release/
|
||||
src/
|
||||
swagger-ui-dist-package/
|
||||
test/
|
||||
webpack/
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
Copyright 2019 SmartBear Software
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at [apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
+97
@@ -0,0 +1,97 @@
|
||||
# <img src="https://raw.githubusercontent.com/swagger-api/swagger.io/wordpress/images/assets/SWU-logo-clr.png" width="300">
|
||||
|
||||
[](http://badge.fury.io/js/swagger-ui)
|
||||
[](https://jenkins.swagger.io/view/OSS%20-%20JavaScript/job/oss-swagger-ui-master/)
|
||||
[](https://jenkins.swagger.io/job/oss-swagger-ui-security-audit/lastBuild/console)
|
||||

|
||||
|
||||

|
||||

|
||||

|
||||

|
||||
|
||||
**👉🏼 Want to score an easy open-source contribution?** Check out our [Good first issue](https://github.com/swagger-api/swagger-ui/issues?q=is%3Aissue+is%3Aopen+label%3A%22Good+first+issue%22) label.
|
||||
|
||||
**🕰️ Looking for the older version of Swagger UI?** Refer to the [*2.x* branch](https://github.com/swagger-api/swagger-ui/tree/2.x).
|
||||
|
||||
|
||||
This repository publishes to three different NPM modules:
|
||||
|
||||
* [swagger-ui](https://www.npmjs.com/package/swagger-ui) is a traditional npm module intended for use in single-page applications that are capable of resolving dependencies (via Webpack, Browserify, etc).
|
||||
* [swagger-ui-dist](https://www.npmjs.com/package/swagger-ui-dist) is a dependency-free module that includes everything you need to serve Swagger UI in a server-side project, or a single-page application that can't resolve npm module dependencies.
|
||||
* [swagger-ui-react](https://www.npmjs.com/package/swagger-ui-react) is Swagger UI packaged as a React component for use in React applications.
|
||||
|
||||
We strongly suggest that you use `swagger-ui` instead of `swagger-ui-dist` if you're building a single-page application, since `swagger-ui-dist` is significantly larger.
|
||||
|
||||
|
||||
## Compatibility
|
||||
The OpenAPI Specification has undergone 5 revisions since initial creation in 2010. Compatibility between Swagger UI and the OpenAPI Specification is as follows:
|
||||
|
||||
Swagger UI Version | Release Date | OpenAPI Spec compatibility | Notes
|
||||
------------------ | ------------ | -------------------------- | -----
|
||||
3.18.3 | 2018-08-03 | 2.0, 3.0 | [tag v3.18.3](https://github.com/swagger-api/swagger-ui/tree/v3.18.3)
|
||||
3.0.21 | 2017-07-26 | 2.0 | [tag v3.0.21](https://github.com/swagger-api/swagger-ui/tree/v3.0.21)
|
||||
2.2.10 | 2017-01-04 | 1.1, 1.2, 2.0 | [tag v2.2.10](https://github.com/swagger-api/swagger-ui/tree/v2.2.10)
|
||||
2.1.5 | 2016-07-20 | 1.1, 1.2, 2.0 | [tag v2.1.5](https://github.com/swagger-api/swagger-ui/tree/v2.1.5)
|
||||
2.0.24 | 2014-09-12 | 1.1, 1.2 | [tag v2.0.24](https://github.com/swagger-api/swagger-ui/tree/v2.0.24)
|
||||
1.0.13 | 2013-03-08 | 1.1, 1.2 | [tag v1.0.13](https://github.com/swagger-api/swagger-ui/tree/v1.0.13)
|
||||
1.0.1 | 2011-10-11 | 1.0, 1.1 | [tag v1.0.1](https://github.com/swagger-api/swagger-ui/tree/v1.0.1)
|
||||
|
||||
## Documentation
|
||||
|
||||
#### Usage
|
||||
- [Installation](docs/usage/installation.md)
|
||||
- [Configuration](docs/usage/configuration.md)
|
||||
- [CORS](docs/usage/cors.md)
|
||||
- [OAuth2](docs/usage/oauth2.md)
|
||||
- [Deep Linking](docs/usage/deep-linking.md)
|
||||
- [Limitations](docs/usage/limitations.md)
|
||||
- [Version detection](docs/usage/version-detection.md)
|
||||
|
||||
#### Customization
|
||||
- [Overview](docs/customization/overview.md)
|
||||
- [Plugin API](docs/customization/plugin-api.md)
|
||||
- [Custom layout](docs/customization/custom-layout.md)
|
||||
|
||||
#### Development
|
||||
- [Setting up](docs/development/setting-up.md)
|
||||
- [Scripts](docs/development/scripts.md)
|
||||
|
||||
##### Integration Tests
|
||||
|
||||
You will need JDK of version 7 or higher as instructed here
|
||||
https://nightwatchjs.org/gettingstarted/#selenium-server-setup
|
||||
|
||||
Integration tests can be run locally with `npm run e2e` - be sure you aren't running a dev server when testing!
|
||||
|
||||
### Browser support
|
||||
Swagger UI works in the latest versions of Chrome, Safari, Firefox, Edge and IE11.
|
||||
|
||||
### Known Issues
|
||||
|
||||
To help with the migration, here are the currently known issues with 3.X. This list will update regularly, and will not include features that were not implemented in previous versions.
|
||||
|
||||
- Only part of the parameters previously supported are available.
|
||||
- The JSON Form Editor is not implemented.
|
||||
- Support for `collectionFormat` is partial.
|
||||
- l10n (translations) is not implemented.
|
||||
- Relative path support for external files is not implemented.
|
||||
|
||||
## Security contact
|
||||
|
||||
Please disclose any security-related issues or vulnerabilities by emailing [security@swagger.io](mailto:security@swagger.io), instead of using the public issue tracker.
|
||||
|
||||
## License
|
||||
|
||||
Copyright 2019 SmartBear Software
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at [apache.org/licenses/LICENSE-2.0](https://www.apache.org/licenses/LICENSE-2.0)
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
# Security Policy
|
||||
|
||||
If you believe you've found an exploitable security issue in Swagger UI,
|
||||
**please don't create a public issue**.
|
||||
|
||||
|
||||
## Supported versions
|
||||
|
||||
This is the list of versions of `swagger-ui` which are
|
||||
currently being supported with security updates.
|
||||
|
||||
| Version | Supported | Notes |
|
||||
| -------- | ------------------ | ---------------------- |
|
||||
| 3.x | :white_check_mark: | |
|
||||
| 2.x | :x: | End-of-life as of 2017 |
|
||||
|
||||
## Reporting a vulnerability
|
||||
|
||||
To report a vulnerability please send an email with the details to [security@swagger.io](mailto:security@swagger.io).
|
||||
|
||||
We'll acknowledge receipt of your report ASAP, and set expectations on how we plan to handle it.
|
||||
@@ -0,0 +1,60 @@
|
||||
<!-- HTML for static distribution bundle build -->
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Swagger UI</title>
|
||||
<link rel="stylesheet" type="text/css" href="./swagger-ui.css" >
|
||||
<link rel="icon" type="image/png" href="./favicon-32x32.png" sizes="32x32" />
|
||||
<link rel="icon" type="image/png" href="./favicon-16x16.png" sizes="16x16" />
|
||||
<style>
|
||||
html
|
||||
{
|
||||
box-sizing: border-box;
|
||||
overflow: -moz-scrollbars-vertical;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
|
||||
*,
|
||||
*:before,
|
||||
*:after
|
||||
{
|
||||
box-sizing: inherit;
|
||||
}
|
||||
|
||||
body
|
||||
{
|
||||
margin:0;
|
||||
background: #fafafa;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="swagger-ui"></div>
|
||||
|
||||
<script src="./swagger-ui-bundle.js"> </script>
|
||||
<script src="./swagger-ui-standalone-preset.js"> </script>
|
||||
<script>
|
||||
window.onload = function() {
|
||||
// Begin Swagger UI call region
|
||||
const ui = SwaggerUIBundle({
|
||||
url: "https://petstore.swagger.io/v2/swagger.json",
|
||||
dom_id: '#swagger-ui',
|
||||
deepLinking: true,
|
||||
presets: [
|
||||
SwaggerUIBundle.presets.apis,
|
||||
SwaggerUIStandalonePreset
|
||||
],
|
||||
plugins: [
|
||||
SwaggerUIBundle.plugins.DownloadUrl
|
||||
],
|
||||
layout: "StandaloneLayout"
|
||||
})
|
||||
// End Swagger UI call region
|
||||
|
||||
window.ui = ui
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+19447
File diff suppressed because it is too large
Load Diff
+168
@@ -0,0 +1,168 @@
|
||||
{
|
||||
"name": "swagger-ui",
|
||||
"version": "3.24.3",
|
||||
"main": "dist/swagger-ui.js",
|
||||
"homepage": "https://github.com/swagger-api/swagger-ui",
|
||||
"repository": "git@github.com:swagger-api/swagger-ui.git",
|
||||
"contributors": [
|
||||
"(in alphabetical order)",
|
||||
"Anna Bodnia <anna.bodnia@gmail.com>",
|
||||
"Buu Nguyen <buunguyen@gmail.com>",
|
||||
"Josh Ponelat <jponelat@gmail.com>",
|
||||
"Kyle Shockey <kyleshockey@gmail.com>",
|
||||
"Robert Barnwell <robert@robertismy.name>",
|
||||
"Sahar Jafari <shr.jafari@gmail.com>"
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"scripts": {
|
||||
"automated-release": "release-it --config ./release/.release-it.json",
|
||||
"build": "run-p --aggregate-output build-core build-bundle build-standalone build-stylesheets",
|
||||
"build-bundle": "webpack --colors --config webpack/bundle.babel.js",
|
||||
"build-core": "webpack --colors --config webpack/core.babel.js",
|
||||
"build-standalone": "webpack --colors --config webpack/standalone.babel.js",
|
||||
"build-stylesheets": "webpack --colors --config webpack/stylesheets.babel.js",
|
||||
"predev": "npm install",
|
||||
"dev": "webpack-dev-server --config webpack/dev.babel.js",
|
||||
"deps-license": "license-checker --production --csv --out $npm_package_config_deps_check_dir/licenses.csv && license-checker --development --csv --out $npm_package_config_deps_check_dir/licenses-dev.csv",
|
||||
"deps-size": "webpack -p --config webpack/bundle.babel.js --json | webpack-bundle-size-analyzer >| $npm_package_config_deps_check_dir/sizes.txt",
|
||||
"deps-check": "run-s deps-license deps-size",
|
||||
"lint": "eslint --cache --ext '.js,.jsx' src test",
|
||||
"lint-errors": "eslint --cache --quiet --ext '.js,.jsx' src test",
|
||||
"lint-fix": "eslint --cache --ext '.js,.jsx' src test --fix",
|
||||
"test": "run-s just-test-in-node e2e-cypress lint-errors",
|
||||
"test-in-node": "run-s lint-errors just-test-in-node",
|
||||
"just-test-in-node": "mocha --require test/mocha/setup.js --recursive --compilers js:@babel/register --require source-map-support 'test/mocha/**/*.{js,jsx}'",
|
||||
"test-e2e-cypress": "cypress run",
|
||||
"test-e2e-selenium": "sleep 3 && nightwatch test/e2e-selenium/scenarios/ --config test/e2e-selenium/nightwatch.json",
|
||||
"e2e-initial-render": "nightwatch test/e2e-selenium/scenarios/ --config test/e2e-selenium/nightwatch.json --group initial-render",
|
||||
"mock-api": "json-server --watch test/e2e-selenium/db.json --port 3204",
|
||||
"hot-e2e-cypress-server": "webpack-dev-server --config webpack/dev-e2e.babel.js --content-base test/e2e-cypress/static",
|
||||
"hot-e2e-selenium-server": "webpack-dev-server --config webpack/dev-e2e.babel.js --content-base test/e2e-selenium/static",
|
||||
"e2e-cypress": "run-p -r hot-e2e-cypress-server mock-api test-e2e-cypress",
|
||||
"e2e-selenium": "run-p -r hot-e2e-selenium-server mock-api test-e2e-selenium",
|
||||
"open-static": "node -e 'require(\"open\")(\"http://localhost:3002\")'",
|
||||
"security-audit": "run-s -sc security-audit:all security-audit:prod",
|
||||
"security-audit:prod": "npm-audit-ci-wrapper -p -t low",
|
||||
"security-audit:all": "npm-audit-ci-wrapper -t moderate",
|
||||
"serve-static": "http-server dist/ -i -a 0.0.0.0 -p 3002",
|
||||
"start": "npm-run-all --parallel serve-static open-static"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/runtime-corejs2": "^7.5.5",
|
||||
"@braintree/sanitize-url": "^3.0.0",
|
||||
"@kyleshockey/object-assign-deep": "^0.4.2",
|
||||
"@kyleshockey/xml": "^1.0.2",
|
||||
"base64-js": "^1.2.0",
|
||||
"classnames": "^2.2.6",
|
||||
"core-js": "^2.5.1",
|
||||
"css.escape": "1.5.1",
|
||||
"deep-extend": "0.6.0",
|
||||
"dompurify": "^2.0.7",
|
||||
"ieee754": "^1.1.13",
|
||||
"immutable": "^3.x.x",
|
||||
"js-file-download": "^0.4.1",
|
||||
"js-yaml": "^3.13.1",
|
||||
"lodash": "^4.17.15",
|
||||
"memoizee": "^0.4.12",
|
||||
"prop-types": "^15.7.2",
|
||||
"randombytes": "^2.1.0",
|
||||
"react": "^15.6.2",
|
||||
"react-debounce-input": "^3.2.0",
|
||||
"react-dom": "^15.6.2",
|
||||
"react-immutable-proptypes": "2.1.0",
|
||||
"react-immutable-pure-component": "^1.1.1",
|
||||
"react-inspector": "^2.3.0",
|
||||
"react-motion": "^0.5.2",
|
||||
"react-redux": "^4.x.x",
|
||||
"redux": "^3.x.x",
|
||||
"redux-immutable": "3.1.0",
|
||||
"remarkable": "^1.7.4",
|
||||
"reselect": "^2.5.4",
|
||||
"serialize-error": "^2.1.0",
|
||||
"sha.js": "^2.4.11",
|
||||
"swagger-client": "^3.9.6",
|
||||
"url-parse": "^1.4.7",
|
||||
"xml-but-prettier": "^1.0.1",
|
||||
"zenscroll": "^4.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.0.0",
|
||||
"@babel/core": "^7.0.0",
|
||||
"@babel/plugin-proposal-class-properties": "^7.5.0",
|
||||
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.0.0",
|
||||
"@babel/plugin-proposal-optional-chaining": "^7.2.0",
|
||||
"@babel/plugin-transform-runtime": "^7.0.0",
|
||||
"@babel/preset-env": "^7.0.0",
|
||||
"@babel/preset-react": "^7.0.0",
|
||||
"@babel/register": "^7.4.4",
|
||||
"@release-it/conventional-changelog": "^1.1.0",
|
||||
"autoprefixer": "^8.4.1",
|
||||
"babel-eslint": "^9.0.0",
|
||||
"babel-loader": "^8.0.6",
|
||||
"babel-plugin-module-resolver": "^3.2.0",
|
||||
"babel-plugin-transform-react-remove-prop-types": "^0.4.13",
|
||||
"body-parser": "^1.19.0",
|
||||
"bundlesize": "^0.18.0",
|
||||
"chromedriver": "^2.38.3",
|
||||
"copy-webpack-plugin": "^5.0.4",
|
||||
"cors": "^2.8.5",
|
||||
"css-loader": "^3.1.0",
|
||||
"cypress": "^3.4.1",
|
||||
"dedent": "^0.7.0",
|
||||
"deepmerge": "^2.1.0",
|
||||
"enzyme": "^2.7.1",
|
||||
"eslint": "^4.1.1",
|
||||
"eslint-plugin-import": "^2.18.2",
|
||||
"eslint-plugin-mocha": "^4.11.0",
|
||||
"eslint-plugin-react": "^7.14.3",
|
||||
"expect": "^1.20.2",
|
||||
"express": "^4.17.1",
|
||||
"file-loader": "^4.1.0",
|
||||
"git-describe": "^4.0.4",
|
||||
"http-server": "^0.11.1",
|
||||
"ignore-assets-webpack-plugin": "^2.0.1",
|
||||
"imports-loader": "^0.8.0",
|
||||
"jsdom": "^11.10.0",
|
||||
"json-loader": "^0.5.7",
|
||||
"json-merger": "^1.1.1",
|
||||
"json-server": "^0.15.0",
|
||||
"less": "^3.9.0",
|
||||
"license-checker": "^19.0.0",
|
||||
"mini-css-extract-plugin": "^0.8.0",
|
||||
"mocha": "^5.1.1",
|
||||
"nightwatch": "^1.1.13",
|
||||
"node-sass": "^4.12.0",
|
||||
"npm-audit-ci-wrapper": "^2.3.0",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"oauth2-server": "^2.4.1",
|
||||
"open": "^6.4.0",
|
||||
"optimize-css-assets-webpack-plugin": "^5.0.3",
|
||||
"postcss-loader": "^3.0.0",
|
||||
"prettier": "^1.18.2",
|
||||
"raw-loader": "^3.1.0",
|
||||
"react-test-renderer": "^15.5.4",
|
||||
"release-it": "^12.3.4",
|
||||
"rimraf": "^2.6.3",
|
||||
"sass-loader": "^7.1.0",
|
||||
"selenium-server-standalone-jar": "^3.141.5",
|
||||
"source-map-support": "^0.5.12",
|
||||
"standard": "^11.0.1",
|
||||
"tachyons-sass": "^4.9.5",
|
||||
"terser-webpack-plugin": "^1.4.1",
|
||||
"url-loader": "^2.1.0",
|
||||
"webpack": "^4.39.0",
|
||||
"webpack-bundle-size-analyzer": "^2.5.0",
|
||||
"webpack-cli": "^3.3.6",
|
||||
"webpack-dev-server": "^3.7.2"
|
||||
},
|
||||
"config": {
|
||||
"deps_check_dir": ".deps_check"
|
||||
},
|
||||
"bundlesize": [
|
||||
{
|
||||
"path": "./dist/swagger-ui-bundle.js",
|
||||
"maxSize": "1 MB",
|
||||
"compression": "none"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -15,4 +15,5 @@ BOWER_INSTALLED_APPS = (
|
||||
"font-awesome#4.7.0",
|
||||
"c3#0.4.10",
|
||||
"selectize#0.12.4",
|
||||
"swagger-ui#3.24.3",
|
||||
)
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
from django.urls import reverse_lazy
|
||||
|
||||
from modoboa.lib.tests import ModoTestCase
|
||||
|
||||
|
||||
class OpenAPITestCase(ModoTestCase):
|
||||
openapi_schema_url = reverse_lazy('openapi_schema')
|
||||
|
||||
def test_unauthorized(self):
|
||||
self.client.logout()
|
||||
|
||||
response = self.client.get("/docs/api/")
|
||||
self.assertRedirects(response, "/accounts/login/?next=/docs/api/")
|
||||
|
||||
response = self.client.get(self.openapi_schema_url)
|
||||
self.assertEqual(response.status_code, 403)
|
||||
|
||||
def test_get_schema(self):
|
||||
self.assertEqual(self.openapi_schema_url, "/docs/openapi.json")
|
||||
|
||||
response = self.client.get(self.openapi_schema_url)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(response.json()['info'], {
|
||||
'title': "Modoboa API",
|
||||
'version': "1.0.0",
|
||||
})
|
||||
|
||||
def test_get_swagger_ui(self):
|
||||
response = self.client.get("/docs/api/")
|
||||
self.assertContains(response, "Modoboa API")
|
||||
@@ -0,0 +1,53 @@
|
||||
<!DOCTYPE html>
|
||||
{% load static %}
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Modoboa API</title>
|
||||
<link rel="stylesheet" href="{% static 'swagger-ui/dist/swagger-ui.css' %}">
|
||||
<style>
|
||||
html {
|
||||
box-sizing: border-box;
|
||||
overflow: -moz-scrollbars-vertical;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
|
||||
*,
|
||||
*:before,
|
||||
*:after {
|
||||
box-sizing: inherit;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
background: #fafafa;
|
||||
}
|
||||
|
||||
.swagger-ui .highlight-code .download-contents {
|
||||
right: 20px;
|
||||
height: auto;
|
||||
width: auto;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="swagger-ui"></div>
|
||||
<script src="{% static 'swagger-ui/dist/swagger-ui-bundle.js' %}"></script>
|
||||
<script>
|
||||
window.onload = function() {
|
||||
const ui = SwaggerUIBundle({
|
||||
url: "{% url 'openapi_schema' %}",
|
||||
dom_id: '#swagger-ui',
|
||||
deepLinking: true,
|
||||
presets: [
|
||||
SwaggerUIBundle.presets.apis
|
||||
],
|
||||
layout: "BaseLayout"
|
||||
});
|
||||
|
||||
window.ui = ui;
|
||||
};
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
+12
-4
@@ -6,16 +6,16 @@ from django.conf import settings
|
||||
from django.conf.urls import include, url
|
||||
from django.contrib.auth import views as auth_views
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.views.generic import TemplateView
|
||||
from django.views.i18n import JavaScriptCatalog
|
||||
|
||||
from rest_framework.documentation import include_docs_urls
|
||||
from rest_framework.renderers import JSONOpenAPIRenderer
|
||||
from rest_framework.schemas import get_schema_view
|
||||
|
||||
from modoboa.admin.views.user import forward
|
||||
from modoboa.core import signals as core_signals, views as core_views
|
||||
from modoboa.core.extensions import exts_pool
|
||||
|
||||
API_TITLE = "Modoboa API"
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^jsi18n/$', JavaScriptCatalog.as_view(), name="javascript-catalog"),
|
||||
url(r'^ckeditor/upload/', login_required(cku_views.upload),
|
||||
@@ -48,8 +48,16 @@ if extra_routes:
|
||||
urlpatterns += extra_routes
|
||||
|
||||
# API urls
|
||||
schema_view = get_schema_view(
|
||||
title="Modoboa API",
|
||||
version="1.0.0",
|
||||
public=False,
|
||||
renderer_classes=[JSONOpenAPIRenderer],
|
||||
)
|
||||
urlpatterns += [
|
||||
url("^docs/api/", include_docs_urls(title=API_TITLE, public=False)),
|
||||
url(r'^docs/openapi.json$', schema_view, name="openapi_schema"),
|
||||
url(r'^docs/api/', login_required(
|
||||
TemplateView.as_view(template_name="swagger-ui.html"))),
|
||||
url("^api/v1/", include("modoboa.urls_api", namespace="api")),
|
||||
]
|
||||
|
||||
|
||||
+2
-3
@@ -7,9 +7,8 @@ django-xforwardedfor-middleware==2.0
|
||||
|
||||
dj-database-url
|
||||
|
||||
coreapi==2.3.3
|
||||
coreapi-cli==1.0.9
|
||||
djangorestframework>=3.9,<3.10
|
||||
djangorestframework>=3.11,<3.12
|
||||
uritemplate
|
||||
|
||||
passlib==1.7.2
|
||||
bcrypt # Requires libffi-dev and python-dev
|
||||
|
||||
Reference in New Issue
Block a user