Skip to content
This repository has been archived by the owner on Jun 12, 2024. It is now read-only.

Commit

Permalink
Fix another test
Browse files Browse the repository at this point in the history
  • Loading branch information
kumaranvpl committed May 1, 2024
1 parent 268c4a0 commit 9e6ef98
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
15 changes: 9 additions & 6 deletions tests/data/expected/openapi/disable_timestamp/simple/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

from __future__ import annotations

from typing import Optional, Union
from typing import List, Optional, Union

from fastapi import FastAPI, Path

from .models import Error, Pets
from .models import Error, Pet

app = FastAPI(
version='1.0.0',
Expand All @@ -19,9 +19,12 @@


@app.get(
'/pets', response_model=Pets, responses={'default': {'model': Error}}, tags=['pets']
'/pets',
response_model=List[Pet],
responses={'default': {'model': Error}},
tags=['pets'],
)
def list_pets(limit: Optional[int] = None) -> Union[Pets, Error]:
def list_pets(limit: Optional[int] = None) -> Union[List[Pet], Error]:
"""
List all pets
"""
Expand All @@ -40,11 +43,11 @@ def create_pets() -> Optional[Error]:

@app.get(
'/pets/{petId}',
response_model=Pets,
response_model=List[Pet],
responses={'default': {'model': Error}},
tags=['pets'],
)
def show_pet_by_id(pet_id: str = Path(..., alias='petId')) -> Union[Pets, Error]:
def show_pet_by_id(pet_id: str = Path(..., alias='petId')) -> Union[List[Pet], Error]:
"""
Info for a specific pet
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

from __future__ import annotations

from typing import List, Optional
from typing import Optional

from pydantic import BaseModel, Field
from pydantic import BaseModel


class Pet(BaseModel):
Expand All @@ -14,10 +14,6 @@ class Pet(BaseModel):
tag: Optional[str] = None


class Pets(BaseModel):
__root__: List[Pet] = Field(..., description='list of pet')


class Error(BaseModel):
code: int
message: str
4 changes: 4 additions & 0 deletions tests/test_generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ def test_disable_timestamp(oas_file):
expected_files = sorted(list(expected_dir.glob('*')))
assert [f.name for f in output_files] == [f.name for f in expected_files]
for output_file, expected_file in zip(output_files, expected_files):
print(expected_file)
print(expected_file.read_text())
print(output_file)
print(output_file.read_text())
assert output_file.read_text() == expected_file.read_text()


Expand Down

0 comments on commit 9e6ef98

Please sign in to comment.