Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(api): update api description #13429

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

walpox
Copy link

@walpox walpox commented Jan 4, 2025

Proposed changes

  • Move the API description string to a separate variable to improve code readability.
  • Add content to the (Open)API description summarized from general sections of the REST API documentation.

Checklist

  • Lint and unit tests pass locally with my changes.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added documentation to describe my feature.
  • I have squashed my commits into logic units.
  • I have described the changes in the commit messages.

Other information

The rationale behind this change is to help the OpenAPI document stand on its own.

Relates to #12584

walpox added 2 commits January 4, 2025 23:13
Move the API description string to a separate variable to improve code readability.

Add content to the (Open)API description summarized from general sections of the REST API documentation.
Rate limiting can be adjusted in the `settings.py` file; see [Throttling in Django REST framework documentation](https://www.django-rest-framework.org/api-guide/throttling/)
for more details on how to configure it.

In the Docker container, this can be configured with the [WEBLATE_API_RATELIMIT_ANON]({get_doc_url(page='admin/install/docker', anchor='envvar-WEBLATE_API_RATELIMIT_ANON')}) and the [WEBLATE_API_RATELIMIT_USER]({get_doc_url(page='admin/install/docker', anchor='envvar-WEBLATE_API_RATELIMIT_USER')}) environment variables.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The anchors for the URLs of both Docker variables actually use the underscore character, but the get_doc_url function replaces them with hyphens -.

Weblate's REST API is based on [Django REST framework](https://www.django-rest-framework.org).
You can interact with it on the `/api/` URL path by using the [Weblate Client]({get_doc_url(page='wlc')}) or any third-party REST client of your choice.

## Authentication
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already covered in OpenAPI, it could be definitely improved, but better to have it in standard location than in text:

image

requests per day. On the other hand, authenticated requests are rate limited
to 5000 requests per hour by default.

## API rate limiting
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already partly documented in response headers via add_middleware_headers:

image

weblate/api/spectacular.py Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants