Skip to content

Commit 3badf5e

Browse files
author
Doug Borg
committed
refactor: unify core models for OpenAPI 3.0/3.1 compatibility (type unions)
1 parent 1ac713b commit 3badf5e

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

src/openapi_python_generator/common.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class Formatter(str, Enum):
2828
BLACK = "black"
2929
NONE = "none"
3030

31+
3132
class FormatOptions:
3233
skip_validation: bool = False
3334
line_length: int = 120

src/openapi_python_generator/models.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,23 @@
1-
from typing import List
1+
from typing import List, Union
22
from typing import Optional
33

4-
from openapi_pydantic.v3.v3_0 import Operation, PathItem, Schema
4+
from openapi_pydantic.v3.v3_0 import (
5+
Operation as Operation30,
6+
PathItem as PathItem30,
7+
Schema as Schema30,
8+
)
9+
from openapi_pydantic.v3.v3_1 import (
10+
Operation as Operation31,
11+
PathItem as PathItem31,
12+
Schema as Schema31,
13+
)
514
from pydantic import BaseModel
615

16+
# Type unions for compatibility with both OpenAPI 3.0 and 3.1
17+
Operation = Union[Operation30, Operation31]
18+
PathItem = Union[PathItem30, PathItem31]
19+
Schema = Union[Schema30, Schema31]
20+
721

822
class LibraryConfig(BaseModel):
923
name: str

0 commit comments

Comments
 (0)