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

Run checks on Django startup #477

Closed
k0t3n opened this issue Aug 3, 2021 · 4 comments
Closed

Run checks on Django startup #477

k0t3n opened this issue Aug 3, 2021 · 4 comments
Labels
enhancement New feature or request fix confirmation pending issue has been fixed and confirmation from issue reporter is pending

Comments

@k0t3n
Copy link

k0t3n commented Aug 3, 2021

Sometimes when working with a swagger docs I see lots of warnings about incorrect schema in the console. It would be great to run whose checks on Django startup using checks framework.

@tfranzel
Copy link
Owner

tfranzel commented Aug 3, 2021

Hi,

that's a very nice idea. it definitely can make sense to run these tests on startup.

however, i'm not sure we can turn off the warning when actually retrieving the schema. there are quite a few use-cases where schema generation can be fine when generated "offline" (checks/CLI) while "online" generation (request) has warnings.

@tfranzel tfranzel added the enhancement New feature or request label Aug 3, 2021
tfranzel added a commit that referenced this issue Aug 17, 2021
@tfranzel tfranzel added the fix confirmation pending issue has been fixed and confirmation from issue reporter is pending label Aug 17, 2021
@k0t3n
Copy link
Author

k0t3n commented Aug 25, 2021

GJ!

@HansAarneLiblik
Copy link

This kinda broke our environment.

We have 2 kinds of APIs in our project - public and internal. We're using annotations to define them and handle this logic in SchemaGenerator.

We've fixed all our Public APIs (hopefully) and care when drf-spectacular gives us a warning / error regarding them.

We don't really care about these errors for Internal APIs, since they may be in development or not properly documented, which is acceptable.

This task currently raises this exceptions for our Internal APIs also. We don't want to disable these for public APIs.

Is there any way to override with some logic, for which endpoints these checks are run ?

@tfranzel
Copy link
Owner

tfranzel commented Aug 30, 2021

Hi @HansAarneLiblik, sry for the inconvenience. i fixed some bugs and added a switch to turn this off, which will be released in 0.18.1 very soon. just waiting for some feedback.

this will turn off the new check. i would suggest just doing that and carrying on as you always did as nothing else changed. your special case is not really applicable here, but you can still do ./manage.py spectacular --fail-on-warn ... as before.

'ENABLE_DJANGO_DEPLOY_CHECK': False

alternatively you can set the Django setting

SILENCED_SYSTEM_CHECKS = ['drf_spectacular.E001', 'drf_spectacular.W001', 'drf_spectacular.W002']

which has the same outcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request fix confirmation pending issue has been fixed and confirmation from issue reporter is pending
Projects
None yet
Development

No branches or pull requests

3 participants