Skip to content

Commit

Permalink
update pydantic fastapi
Browse files Browse the repository at this point in the history
  • Loading branch information
omarudolley committed Oct 23, 2023
1 parent adf98a6 commit 20533d7
Show file tree
Hide file tree
Showing 4 changed files with 187 additions and 183 deletions.
9 changes: 4 additions & 5 deletions openapi_to_fastapi/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@
from typing import Dict, Optional

from fastapi.openapi import models as oas
from pydantic import BaseModel, Field
from pydantic import BaseModel, ConfigDict, Field


class Header(oas.Header):
class Config:
extra = "ignore"
model_config = ConfigDict(extra="ignore")


class ParsedResponse(BaseModel):
description: Optional[str]
model_name: Optional[str]
description: Optional[str] = None
model_name: Optional[str] = None


class Operation(oas.Operation):
Expand Down
2 changes: 1 addition & 1 deletion openapi_to_fastapi/tests/test_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def test_pydantic_model_loading(specs_root):
module.BasicCompanyInfoRequest(companyId=[])

company_info_req = module.BasicCompanyInfoRequest(companyId="abc")
assert company_info_req.dict() == {"companyId": "abc"}
assert company_info_req.model_dump() == {"companyId": "abc"}

assert module.ValidationError(loc=[], msg="Crap", type="Error")

Expand Down
Loading

0 comments on commit 20533d7

Please sign in to comment.