Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
drf-spectacularfor automatic OpenAPI 3.0 schema generation and interactive API docs/api/docs/and ReDoc at/api/redoc/for browsing and testing endpoints@extend_schemaannotations andserializer_classattributes across all API views so request bodies, response schemas, and parameters are fully documentedChanges
Configuration
drf-spectaculartorequirements.txtdrf_spectaculartoINSTALLED_APPSand setDEFAULT_SCHEMA_CLASSinsettings.pySPECTACULAR_SETTINGSwith project metadata, JWT security scheme, and Swagger UI configURL Routes
/api/schema/— raw OpenAPI JSON/YAML schema/api/docs/— Swagger UI/api/redoc/— ReDoc UISchema Annotations
Added
@extend_schemawithinline_serializerfor views that return raw dicts:listMeds— GetMedication, DeleteMedicationrisk— RiskWithSourcesViewuploadFile— file upload (multipart), delete, PDF retrievalconversations— continue_conversation, update_titleembeddings— AskEmbeddingsAPIView (with query params)text_extraction— RuleExtractionAPIView, RuleExtractionAPIOpenAIViewassistant— Assistantversion— VersionViewmedRules— MedRules POSTAdded
serializer_classfor auto-detection on:ListOrDetailMedication,AddMedication,UploadFileView,MedRules,FeedbackViewAdded
@extend_schemareferencing existing serializers on function-based views:ai_promptStorage— store_prompt, get_all_promptsai_settings— settings_viewFixed
@extend_schema_fieldonMedRuleSerializer.get_medication_sourcesto resolve type hint warning.How to Use
SwaggerUI is found at
localhost:800/api/docsTo test endpoints that require auth, follow this flow:
/auth/jwt/create/withemailandpasswordin the request body (Can do this in Swagger UI itself with the "try it out" feature)JWT <access_token>Related Issue
Closes #470
Manual Tests
/api/docs/to confirm Swagger UI loads with all endpoints listedDocumentation
I can add a line or two about accessing and using the API docs in the local development section of the README if that would be useful.
Reviewers
@sahilds1