feat: add OpenAPI examples for /explanation/, /debugging/, /suggestio…#229
Closed
Neelr1912 wants to merge 1 commit into
Closed
feat: add OpenAPI examples for /explanation/, /debugging/, /suggestio…#229Neelr1912 wants to merge 1 commit into
Neelr1912 wants to merge 1 commit into
Conversation
…ns/, /analyze/ endpoints Closes imDarshanGK#205 - Add Body(openapi_examples=...) with 3 named examples per endpoint so Swagger UI shows a dropdown of sample payloads in Try it out - Add model_config json_schema_extra example to CodeRequest schema - Examples cover Python, JavaScript, and edge cases (auto-detect, clean code, buggy code, callback hell, etc.) - Compatible with FastAPI >=0.115.0 and Pydantic v2
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.
Summary
Closes #205
Populate OpenAPI examples for all four analysis endpoints so users can try sample payloads directly in the Swagger UI (
/docs).Changes
backend/app/schemas.py— Addedmodel_configwithjson_schema_extraexample onCodeRequestbackend/app/routers/explanation.py— Added 3 named examples: Python function, JavaScript ES6 class, auto-detect languagebackend/app/routers/debugging.py— Added 3 named examples: Python bugs, JavaScript pitfalls, clean codebackend/app/routers/suggestions.py— Added 3 named examples: unoptimized loop, callback hell, missing type hintsbackend/app/routers/analyze.py— Added 3 named examples: Python with issues, JavaScript with issues, clean PythonHow it works
Each endpoint now uses
Body(openapi_examples=...)which renders a named dropdown in Swagger UI's "Try it out" panel. Users can pick a sample payload and test without typing anything.Testing
python -m py_compileon all changed files