Use neoteroi-mkdocs instead

- seems to render more reliably
This commit is contained in:
Oliver Walters 2024-02-11 08:35:57 +11:00
parent 2627917383
commit 45ac4e774f
8 changed files with 34697 additions and 19 deletions

View File

@ -514,21 +514,6 @@ if USE_JWT:
INSTALLED_APPS.append('rest_framework_simplejwt') INSTALLED_APPS.append('rest_framework_simplejwt')
# WSGI default setting # WSGI default setting
SPECTACULAR_SETTINGS = {
'TITLE': 'InvenTree API',
'DESCRIPTION': 'API for InvenTree - the intuitive open source inventory management system',
'LICENSE': {
'name': 'MIT',
'url': 'https://github.com/inventree/InvenTree/blob/master/LICENSE',
},
'EXTERNAL_DOCS': {
'description': 'More information about InvenTree in the official docs',
'url': 'https://docs.inventree.org',
},
'VERSION': str(inventreeApiVersion()),
'SERVE_INCLUDE_SCHEMA': False,
}
WSGI_APPLICATION = 'InvenTree.wsgi.application' WSGI_APPLICATION = 'InvenTree.wsgi.application'
""" """
@ -1177,3 +1162,23 @@ if CUSTOM_FLAGS:
# Magic login django-sesame # Magic login django-sesame
SESAME_MAX_AGE = 300 SESAME_MAX_AGE = 300
LOGIN_REDIRECT_URL = '/api/auth/login-redirect/' LOGIN_REDIRECT_URL = '/api/auth/login-redirect/'
# Configuratino for API schema generation
SPECTACULAR_SETTINGS = {
'TITLE': 'InvenTree API',
'DESCRIPTION': 'API for InvenTree - the intuitive open source inventory management system',
'LICENSE': {
'name': 'MIT',
'url': 'https://github.com/inventree/InvenTree/blob/master/LICENSE',
},
'EXTERNAL_DOCS': {
'description': 'More information about InvenTree in the official docs',
'url': 'https://docs.inventree.org',
},
'VERSION': str(inventreeApiVersion()),
'SERVE_INCLUDE_SCHEMA': False,
'SCHEMA_PATH_PREFIX': '/api/',
}
if SITE_URL:
SPECTACULAR_SETTINGS['SERVERS'] = [SITE_URL]

33261
docs/api.yml Normal file

File diff suppressed because it is too large Load Diff

View File

@ -17,6 +17,9 @@ The API is self-documenting, and the documentation is provided alongside any Inv
{% include 'img.html' %} {% include 'img.html' %}
{% endwith %} {% endwith %}
!!! info "Schema Description"
The API schema is also documented in the [API Schema](./schema.md) page.
## Authentication ## Authentication
Users must be authenticated to gain access to the InvenTree API. The API accepts either basic username:password authentication, or token authentication. Token authentication is recommended as it provides much faster API access. Users must be authenticated to gain access to the InvenTree API. The API accepts either basic username:password authentication, or token authentication. Token authentication is recommended as it provides much faster API access.

View File

@ -4,6 +4,10 @@ title: API Schema
The InvenTree API is implemented using the [Django REST framework](https://www.django-rest-framework.org). The API schema as documented below is generated using the [drf-spectactular](https://github.com/tfranzel/drf-spectacular/) extensions. The InvenTree API is implemented using the [Django REST framework](https://www.django-rest-framework.org). The API schema as documented below is generated using the [drf-spectactular](https://github.com/tfranzel/drf-spectacular/) extensions.
## Schama ## Schema File
!!swagger api.yaml!! -- TODO -- download
## Schama Spcecification
[OAD(./docs/api.yml)]

File diff suppressed because it is too large Load Diff

View File

@ -55,6 +55,7 @@ extra_css:
- stylesheets/bootstrap.css - stylesheets/bootstrap.css
- stylesheets/splide.min.css - stylesheets/splide.min.css
- stylesheets/extra.css - stylesheets/extra.css
- stylesheets/neoteroi-mkdocs.css
extra_javascript: extra_javascript:
- javascripts/extra.js - javascripts/extra.js
- javascripts/fontawesome.js - javascripts/fontawesome.js
@ -223,7 +224,8 @@ nav:
# Plugins # Plugins
plugins: plugins:
- render_swagger - neoteroi.mkdocsoad:
use_pymdownx: true
- include-markdown: - include-markdown:
opening_tag: "{!" opening_tag: "{!"
closing_tag: "!}" closing_tag: "!}"
@ -242,6 +244,8 @@ markdown_extensions:
- meta - meta
- pymdownx.details - pymdownx.details
- pymdownx.highlight - pymdownx.highlight
- pymdownx.tabbed:
alternate_style: true
- pymdownx.superfences: - pymdownx.superfences:
custom_fences: custom_fences:
- name: mermaid - name: mermaid

View File

@ -4,4 +4,4 @@ mkdocs-material>=9.0,<10.0
mkdocs-git-revision-date-localized-plugin>=1.1,<2.0 mkdocs-git-revision-date-localized-plugin>=1.1,<2.0
mkdocs-simple-hooks>=0.1,<1.0 mkdocs-simple-hooks>=0.1,<1.0
mkdocs-include-markdown-plugin mkdocs-include-markdown-plugin
mkdocs-render-swagger-plugin neoteroi-mkdocs

View File

@ -898,6 +898,8 @@ def schema(c, filename='schema.yml', overwrite=False, ignore_warnings=False):
"""Export current API schema.""" """Export current API schema."""
check_file_existance(filename, overwrite) check_file_existance(filename, overwrite)
filename = os.path.abspath(filename)
cmd = f'spectacular --file {filename} --validate --color' cmd = f'spectacular --file {filename} --validate --color'
if not ignore_warnings: if not ignore_warnings: