Skip to content

Commit 4c4c69c

Browse files
Workflow maintenance, fix #18, #19
1 parent 8966acf commit 4c4c69c

File tree

14 files changed

+567
-52
lines changed

14 files changed

+567
-52
lines changed

.github/workflows/build.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ env:
1616

1717
jobs:
1818
build:
19-
runs-on: ubuntu-18.04
19+
runs-on: ubuntu-latest
2020
strategy:
2121
fail-fast: false
2222
matrix:
23-
python-version: [3.7, 3.8, 3.9, "3.10"]
23+
python-version: [3.8, 3.9, "3.10", "3.11"]
2424

2525
steps:
2626
- uses: actions/checkout@v1
@@ -29,7 +29,7 @@ jobs:
2929
submodules: false
3030

3131
- name: Use Python ${{ matrix.python-version }}
32-
uses: actions/setup-python@v1
32+
uses: actions/setup-python@v4
3333
with:
3434
python-version: ${{ matrix.python-version }}
3535

@@ -54,7 +54,7 @@ jobs:
5454
pip install -U --no-index --find-links=deps deps/*
5555
fi
5656
57-
pip install black==21.11b0 isort==5.10.1
57+
pip install black isort
5858
5959
- name: Run tests
6060
run: |
@@ -84,28 +84,28 @@ jobs:
8484
8585
- name: Install distribution dependencies
8686
run: pip install --upgrade twine setuptools wheel
87-
if: matrix.python-version == 3.8 || matrix.python-version == 3.9
87+
if: matrix.python-version == 3.10
8888

8989
- name: Create distribution package
9090
run: python setup.py sdist bdist_wheel
91-
if: matrix.python-version == 3.8 || matrix.python-version == 3.9
91+
if: matrix.python-version == 3.10
9292

9393
- name: Upload distribution package
9494
uses: actions/upload-artifact@master
9595
with:
9696
name: dist-package-${{ matrix.python-version }}
9797
path: dist
98-
if: matrix.python-version == 3.8 || matrix.python-version == 3.9
98+
if: matrix.python-version == 3.10
9999

100100
publish:
101-
runs-on: ubuntu-18.04
101+
runs-on: ubuntu-latest
102102
needs: build
103103
if: github.event_name == 'release' || startsWith(github.ref, 'refs/tags/')
104104
steps:
105105
- name: Download a distribution artifact
106106
uses: actions/download-artifact@v2
107107
with:
108-
name: dist-package-3.9
108+
name: dist-package-3.10
109109
path: dist
110110
- name: Publish distribution 📦 to Test PyPI
111111
uses: pypa/gh-action-pypi-publish@master

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ 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.4] - 2022-11-06 :snake:
9+
- Fixes [#18](https://github.com/Neoteroi/essentials-openapi/issues/18)
10+
- Workflow maintenance
11+
812
## [1.0.3] - 2022-10-02
913
- Changes how `httpx` version is pinned (`<1`)
1014

openapidocs/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
VERSION = "1.0.3"
1+
VERSION = "1.0.4"

openapidocs/mk/jinja.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@
77

88
from . import get_http_status_phrase, highlight_params, read_dict, sort_dict
99
from .common import DocumentsWriter, is_reference
10-
from .md import write_table
10+
from .md import normalize_link, write_table
1111

1212

1313
def configure_filters(env: Environment):
14-
env.filters.update({"route": highlight_params, "table": write_table})
14+
env.filters.update(
15+
{"route": highlight_params, "table": write_table, "link": normalize_link}
16+
)
1517

1618

1719
def configure_functions(env: Environment):

openapidocs/mk/md.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,9 @@ def write_table(
6666
Writes a Markdown table from a matrix (iterable of string records).
6767
"""
6868
return "\n".join((write_table_lines(matrix, write_headers, padding)))
69+
70+
71+
def normalize_link(value: str) -> str:
72+
if not value:
73+
raise ValueError("Missing value")
74+
return value.replace(".", "")

openapidocs/mk/v3/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,8 @@ def get_properties(self, schema):
593593

594594
if not schema:
595595
return []
596-
return [[key, value] for key, value in sort_dict(schema.get("properties"))]
596+
597+
return [[key, value] for key, value in sort_dict(schema.get("properties", {}))]
597598

598599
def iter_schemas_bindings(self):
599600
"""
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
{% if definition.type == "object" %}
2+
{%- with props = handler.get_properties(definition) -%}
3+
{% if props %}
24
| {{texts.name}} | {{texts.type}} |
35
| -- | -- |
4-
{%- for name, schema in handler.get_properties(definition) %}
6+
{%- for name, schema in props %}
57
| {{name}} | {% include "partial/schema-repr.html" %} |
68
{%- endfor -%}
9+
{%- endif %}
10+
{%- endwith -%}
711
{%- else -%}
812
{%- with schema = definition -%}
9-
Type:&nbsp;
13+
{{texts.type}}:&nbsp;
1014
{%- include "partial/schema-repr.html" -%}
1115
{%- endwith -%}
1216
{%- endif %}

openapidocs/mk/v3/views_mkdocs/partial/request-responses.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
</p>
1616
{%- if is_reference(definition) -%}
1717
{%- with type_name = definition["$ref"].replace("#/components/responses/", "") %}
18-
<div class="common-response"><p>Refer to the common response description: <a href="#{{type_name.lower()}}" class="ref-link">{{type_name}}</a>.</p></div>
18+
<div class="common-response"><p>Refer to the common response description: <a href="#{{type_name.lower() | link}}" class="ref-link">{{type_name}}</a>.</p></div>
1919
{%- endwith -%}
2020
{%- endif -%}
2121
{%- if definition.content %}

openapidocs/mk/v3/views_mkdocs/partial/schema-repr.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{%- if is_reference(schema) -%}
22
{%- with type_name = schema["$ref"].replace("#/components/schemas/", "") -%}
3-
<a href="#{{type_name.lower()}}" class="ref-link">{{type_name}}</a>
3+
<a href="#{{type_name.lower() | link}}" class="ref-link">{{type_name}}</a>
44
{%- endwith -%}
55
{%- endif -%}
66

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
{% if definition.type == "object" %}
2+
{%- with props = handler.get_properties(definition) -%}
3+
{% if props %}
24
<table>
35
<thead>
46
<tr>
@@ -7,17 +9,19 @@
79
</tr>
810
</thead>
911
<tbody>
10-
{%- for name, schema in handler.get_properties(definition) %}
12+
{%- for name, schema in props %}
1113
<tr>
1214
<td><code>{{name}}</code></td>
1315
<td>{% include "partial/schema-repr.html" %}</td>
1416
</tr>
1517
{%- endfor %}
1618
</tbody>
1719
</table>
20+
{%- endif %}
21+
{%- endwith -%}
1822
{%- else -%}
1923
{%- with schema = definition -%}
20-
<span>Type: </span>
24+
<span>{{texts.type}}: </span>
2125
{%- include "partial/schema-repr.html" -%}
2226
{%- endwith -%}
2327
{%- endif %}

0 commit comments

Comments
 (0)