Skip to content

feat: add OpenAPI examples for /explanation/, /debugging/, /suggestio…#229

Closed
Neelr1912 wants to merge 1 commit into
imDarshanGK:mainfrom
Neelr1912:feature/openapi-examples
Closed

feat: add OpenAPI examples for /explanation/, /debugging/, /suggestio…#229
Neelr1912 wants to merge 1 commit into
imDarshanGK:mainfrom
Neelr1912:feature/openapi-examples

Conversation

@Neelr1912
Copy link
Copy Markdown

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 — Added model_config with json_schema_extra example on CodeRequest
  • backend/app/routers/explanation.py — Added 3 named examples: Python function, JavaScript ES6 class, auto-detect language
  • backend/app/routers/debugging.py — Added 3 named examples: Python bugs, JavaScript pitfalls, clean code
  • backend/app/routers/suggestions.py — Added 3 named examples: unoptimized loop, callback hell, missing type hints
  • backend/app/routers/analyze.py — Added 3 named examples: Python with issues, JavaScript with issues, clean Python

How 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

  • Syntax verified with python -m py_compile on all changed files
  • Compatible with FastAPI >= 0.115.0 and Pydantic v2

…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
@Neelr1912 Neelr1912 requested a review from imDarshanGK as a code owner May 21, 2026 18:01
@Neelr1912 Neelr1912 closed this May 22, 2026
@Neelr1912 Neelr1912 deleted the feature/openapi-examples branch May 22, 2026 10:20
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.

Add OpenAPI examples for analysis endpoints

1 participant