Skip to content

fix: FastAPI parser misclassifies body params and strips Pydantic model params #20

@NandishNaik01

Description

@NandishNaik01

Bug

The FastAPI parser has two param extraction issues that cause broken CLI commands:

1. Pydantic model body params are stripped

Endpoints like POST /items/ that accept a Pydantic model body:

def create_item(session: SessionDep, current_user: CurrentUser, item_in: ItemCreate):

The item_in: ItemCreate param is detected as a regular param but its inner fields (title, description) are not expanded. The CLI generates create-item with no --body flag.

Expected: create-item --body '{"title":"...", "description":"..."}' or expanded flags --title --description

2. Body params sent as query when they should be body

test-email sends email_to as a body param but the server expects it as query:

Error: Validation error: {"detail":[{"type":"missing","loc":["query","email_to"]}]}

Affected commands (full-stack-fastapi-template)

  • create-item — no body flag, can't create items
  • create-user — same issue
  • update-user — same
  • update-item — same
  • test-email — body/query misclassification
  • register-user — has --user-in but expects raw JSON string (awkward UX)

Root cause

_extract_params() in fastapi_parser.py doesn't resolve Pydantic model types to their fields, and the body/query classification heuristic doesn't match what FastAPI actually does.

Reproduction

  1. Parse https://github.com/fastapi/full-stack-fastapi-template
  2. Generate CLI
  3. Try create-item --body '{"title":"test"}' → "No such option: --body"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions