Skip to content

Failing schemathesis validation #105

Open
@awtkns

Description

@awtkns

After #104, using the schemathesis tests are still failing when validating the generated openapi spec. The goal of this issue would be to resolve these failing tests (as detailed in #102).


@awtkns I looked at this a little more, and I think my implementation here might be a little bit off. If you're planning to implement schemathesis I'm sure you'll spot it, but leaving this here in case it's helpful. Looking through these docs, it looks like this is the way to specify responses:

class NotFoundModel(BaseModel):
    detail: str


@router.get('/{item_id}/', status_code=200, response_model=Model, responses={'404': {'model': NotFoundModel}})
async def retrieve(item_id: int) -> Model:
    try:
        return await Model.objects.get(id=item_id)
    except NoMatch:
        raise HTTPException(status_code=404, detail="Item not found")

In other words, I think this PR fixed one schemathesis issue: the missing response code, but didn't fully resolve it, since the model isn't correctly specified.

Originally posted by @sondrelg in #104 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions