Skip to content

Commit 4ffc7b1

Browse files
Add support for Python 3.12
1 parent 58bf737 commit 4ffc7b1

File tree

11 files changed

+87
-69
lines changed

11 files changed

+87
-69
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
strategy:
2121
fail-fast: false
2222
matrix:
23-
python-version: [3.8, 3.9, "3.10", "3.11"]
23+
python-version: [3.8, 3.9, "3.10", "3.11", "3.12"]
2424

2525
steps:
2626
- uses: actions/checkout@v1
@@ -109,7 +109,7 @@ jobs:
109109
path: dist
110110

111111
- name: Use Python 3.11
112-
uses: actions/setup-python@v1
112+
uses: actions/setup-python@v4
113113
with:
114114
python-version: '3.11'
115115

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ __pycache__
77
*.tar.gz
88
_test_files/
99
dist/
10+
venv312/

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.0.9] - 2023-11-20
9+
- Adds support for Python 3.12.
10+
- Adds `MarkupSafe` among required dependencies (and not optional).
11+
- Adds support for latest function `model_dump` in Pydantic 2 (for examples
12+
defined using Pydantic models).
13+
- Upgrades development dependencies.
14+
- Fix bug with missing items entry #36 by @mh7d and @mh-at-fujitsu
15+
816
## [1.0.8] - 2023-07-19 :cat:
917
- Fixes example generation breaks on explicitly enumerated array elements #31,
1018
by @jjedele.

openapidocs/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
__version__ = "1.0.8"
1+
__version__ = "1.0.9"
22
VERSION = __version__

openapidocs/common.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,6 @@ def regular_dict_factory(items: List[Tuple[Any, Any]]) -> Any:
101101
# bypassing "asdict" on child properties when they implement a `to_obj`
102102
# method: some entities require a specific shape when represented
103103
def _asdict_inner(obj, dict_factory):
104-
if hasattr(obj, "dict") and callable(obj.dict):
105-
return obj.dict()
106104
if hasattr(obj, "to_obj"):
107105
return obj.to_obj()
108106
if isinstance(obj, OpenAPIElement):
@@ -111,6 +109,12 @@ def _asdict_inner(obj, dict_factory):
111109
value = _asdict_inner(getattr(obj, f.name), dict_factory)
112110
result.append((f.name, value))
113111
return dict_factory(result)
112+
if hasattr(obj, "model_dump") and callable(obj.model_dump):
113+
# For Pydantic 2
114+
return obj.model_dump()
115+
if hasattr(obj, "dict") and callable(obj.dict):
116+
# For Pydantic 1
117+
return obj.dict()
114118
if is_dataclass(obj):
115119
return asdict(obj, dict_factory=regular_dict_factory)
116120
elif isinstance(obj, (list, tuple)):

openapidocs/mk/v3/views_markdown/partial/path-items.html

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
{%- for http_method, operation in definition.items() %}
77

88
### {{http_method.upper()}} {{path | safe}}
9-
{%- if "operationId" in operation -%}
10-
<a id='{{operation.operationId}}'></a>
11-
{%- endif -%}
129
{% if "summary" in operation -%}
1310
{{operation.summary | wordwrap(80)}}
1411
{%- endif -%}

openapidocs/mk/v3/views_mkdocs/partial/path-items.html

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
<hr class="operation-separator" />
77

88
### <span class="http-{{http_method.lower()}}">{{http_method.upper()}}</span> {{path | route | safe}}
9-
{%- if "operationId" in operation -%}
10-
<a id='{{operation.operationId}}'></a>
11-
{%- endif -%}
129
{% if "summary" in operation -%}
1310
{{operation.summary | wordwrap(80)}}
1411
{%- endif -%}

openapidocs/utils/source.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ def read_from_source(source: str):
8686

8787
raise ValueError("Unsupported source file.")
8888
else:
89-
9089
source_lower = source.lower()
9190

9291
if source_lower.startswith("http://") or source_lower.startswith("https://"):

pyproject.toml

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ dynamic = ["version"]
88
authors = [{ name = "Roberto Prevato", email = "[email protected]" }]
99
description = "Classes to generate OpenAPI Documentation v3 and v2, in JSON and YAML."
1010
readme = "README.md"
11-
requires-python = ">=3.7"
11+
requires-python = ">=3.8"
1212
classifiers = [
1313
"Development Status :: 5 - Production/Stable",
1414
"License :: OSI Approved :: MIT License",
@@ -17,17 +17,29 @@ classifiers = [
1717
"Programming Language :: Python :: 3.9",
1818
"Programming Language :: Python :: 3.10",
1919
"Programming Language :: Python :: 3.11",
20+
"Programming Language :: Python :: 3.12",
2021
"Operating System :: OS Independent",
2122
]
22-
keywords = ["openapi", "docs", "swagger", "api", "documentation", "v3", "v2", "json", "yaml", "Markdown"]
23+
keywords = [
24+
"openapi",
25+
"docs",
26+
"swagger",
27+
"api",
28+
"documentation",
29+
"v3",
30+
"v2",
31+
"json",
32+
"yaml",
33+
"Markdown",
34+
]
2335

24-
dependencies = ["PyYAML>=6", "essentials>=1.1.5"]
36+
dependencies = ["PyYAML>=6", "essentials>=1.1.5", "MarkupSafe~=2.1.2"]
2537

2638
[tool.hatch.version]
2739
path = "openapidocs/__init__.py"
2840

2941
[project.optional-dependencies]
30-
full = ["click~=8.1.3", "Jinja2~=3.1.2", "MarkupSafe==2.1.2", "rich~=12.6.0", "httpx<1"]
42+
full = ["click~=8.1.3", "Jinja2~=3.1.2", "rich~=12.6.0", "httpx<1"]
3143

3244
[project.scripts]
3345
openapidocs = "openapidocs.main:main"
@@ -42,12 +54,12 @@ exclude = ["tests"]
4254
[tool.hatch.build]
4355
only-packages = false
4456
include = [
45-
"LICENSE",
46-
"README.md",
47-
"CHANGELOG.md",
48-
"openapidocs/**/*.py",
49-
"openapidocs/**/*.html",
50-
"openapidocs/**/*.md",
57+
"LICENSE",
58+
"README.md",
59+
"CHANGELOG.md",
60+
"openapidocs/**/*.py",
61+
"openapidocs/**/*.html",
62+
"openapidocs/**/*.md",
5163
]
5264

5365
[project.urls]

requirements.txt

Lines changed: 32 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,39 @@
1-
anyio==3.6.2
2-
attrs==22.1.0
3-
black==22.10.0
4-
build==0.10.0
5-
certifi==2022.9.24
6-
charset-normalizer==3.0.0
7-
click==8.1.3
8-
commonmark==0.9.1
9-
coverage==6.5.0
1+
annotated-types==0.6.0
2+
anyio==4.0.0
3+
black==23.11.0
4+
blinker==1.7.0
5+
certifi==2023.11.17
6+
click==8.1.7
7+
coverage==7.3.2
108
essentials==1.1.5
11-
flake8==5.0.4
12-
Flask==2.2.2
13-
h11==0.12.0
14-
httpcore==0.15.0
15-
httpx==0.24.0
9+
flake8==6.1.0
10+
Flask==3.0.0
11+
h11==0.14.0
12+
httpcore==1.0.2
13+
httpx==0.25.1
1614
idna==3.4
17-
iniconfig==1.1.1
18-
isort==5.10.1
15+
iniconfig==2.0.0
16+
isort==5.12.0
1917
itsdangerous==2.1.2
2018
Jinja2==3.1.2
21-
markdown-it-py==2.2.0
22-
MarkupSafe==2.1.2
19+
markdown-it-py==3.0.0
20+
MarkupSafe==2.1.3
2321
mccabe==0.7.0
2422
mdurl==0.1.2
25-
mypy-extensions==0.4.3
26-
packaging==21.3
27-
pathspec==0.10.1
28-
platformdirs==2.5.2
29-
pluggy==1.0.0
30-
py==1.11.0
31-
pycodestyle==2.9.1
32-
pydantic==1.10.2
33-
pyflakes==2.5.0
34-
Pygments==2.13.0
35-
pyparsing==3.0.9
36-
pyproject_hooks==1.0.0
37-
pytest==7.2.0
38-
pytest-cov==4.0.0
39-
PyYAML==6.0
40-
regex==2022.10.31
41-
rfc3986==1.5.0
42-
rich==13.3.5
23+
mypy-extensions==1.0.0
24+
packaging==23.2
25+
pathspec==0.11.2
26+
platformdirs==4.0.0
27+
pluggy==1.3.0
28+
pycodestyle==2.11.1
29+
pydantic==2.5.1
30+
pydantic_core==2.14.3
31+
pyflakes==3.1.0
32+
Pygments==2.17.1
33+
pytest==7.4.3
34+
pytest-cov==4.1.0
35+
PyYAML==6.0.1
36+
rich==13.7.0
4337
sniffio==1.3.0
44-
toml==0.10.2
45-
tomli==2.0.1
46-
typing_extensions==4.4.0
47-
Werkzeug==2.2.2
38+
typing_extensions==4.8.0
39+
Werkzeug==3.0.1

0 commit comments

Comments
 (0)