Skip to content

Commit 9597fe6

Browse files
committed
feat: add initial implementation and test
1 parent c0b9071 commit 9597fe6

File tree

869 files changed

+21655
-10910
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

869 files changed

+21655
-10910
lines changed
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI
2+
3+
on: push
4+
jobs:
5+
build:
6+
name: Build distribution 📦
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- uses: actions/checkout@v4
11+
- name: Set up Python
12+
uses: actions/setup-python@v4
13+
with:
14+
python-version: "3.x"
15+
- name: Install pypa/build
16+
run: >-
17+
python3 -m
18+
pip install
19+
build
20+
--user
21+
- name: Build a binary wheel and a source tarball
22+
run: python3 -m build
23+
- name: Store the distribution packages
24+
uses: actions/upload-artifact@v3
25+
with:
26+
name: python-package-distributions
27+
path: dist/
28+
publish-to-pypi:
29+
name: >-
30+
Publish Python 🐍 distribution 📦 to PyPI
31+
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
32+
needs:
33+
- build
34+
runs-on: ubuntu-latest
35+
environment:
36+
name: pypi
37+
url: https://pypi.org/p/asyncapi_python_parser_jonaslagoni
38+
permissions:
39+
id-token: write # IMPORTANT: mandatory for trusted publishing
40+
steps:
41+
- name: Download all the dists
42+
uses: actions/download-artifact@v3
43+
with:
44+
name: python-package-distributions
45+
path: dist/
46+
- name: Publish distribution 📦 to PyPI
47+
uses: pypa/gh-action-pypi-publish@release/v1
48+
github-release:
49+
name: >-
50+
Sign the Python 🐍 distribution 📦 with Sigstore
51+
and upload them to GitHub Release
52+
needs:
53+
- publish-to-pypi
54+
runs-on: ubuntu-latest
55+
56+
permissions:
57+
contents: write # IMPORTANT: mandatory for making GitHub Releases
58+
id-token: write # IMPORTANT: mandatory for sigstore
59+
60+
steps:
61+
- name: Download all the dists
62+
uses: actions/download-artifact@v3
63+
with:
64+
name: python-package-distributions
65+
path: dist/
66+
- name: Sign the dists with Sigstore
67+
uses: sigstore/gh-action-sigstore-python@v1.2.3
68+
with:
69+
inputs: >-
70+
./dist/*.tar.gz
71+
./dist/*.whl
72+
- name: Create GitHub Release
73+
env:
74+
GITHUB_TOKEN: ${{ github.token }}
75+
run: >-
76+
gh release create
77+
'${{ github.ref_name }}'
78+
--repo '${{ github.repository }}'
79+
--notes ""
80+
- name: Upload artifact signatures to GitHub Release
81+
env:
82+
GITHUB_TOKEN: ${{ github.token }}
83+
# Upload to GitHub Release using the `gh` CLI.
84+
# `dist/` contains the built packages, and the
85+
# sigstore-produced signatures and certificates.
86+
run: >-
87+
gh release upload
88+
'${{ github.ref_name }}' dist/**
89+
--repo '${{ github.repository }}'
90+
publish-to-testpypi:
91+
name: Publish Python 🐍 distribution 📦 to TestPyPI
92+
needs:
93+
- build
94+
runs-on: ubuntu-latest
95+
96+
environment:
97+
name: testpypi
98+
url: https://test.pypi.org/p/asyncapi_python_parser_jonaslagoni
99+
100+
permissions:
101+
id-token: write # IMPORTANT: mandatory for trusted publishing
102+
103+
steps:
104+
- name: Download all the dists
105+
uses: actions/download-artifact@v3
106+
with:
107+
name: python-package-distributions
108+
path: dist/
109+
- name: Publish distribution 📦 to TestPyPI
110+
uses: pypa/gh-action-pypi-publish@release/v1
111+
with:
112+
repository-url: https://test.pypi.org/legacy/

.vscode/settings.json

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
{
22
"python.analysis.extraPaths": [
3-
"./src/models/3_0_0"
4-
]
3+
"./src/models/3_0_0",
4+
"./src"
5+
],
6+
"python.testing.unittestArgs": [
7+
"-v",
8+
"-s",
9+
"./tests",
10+
"-p",
11+
"test_*.py"
12+
],
13+
"python.testing.pytestEnabled": false,
14+
"python.testing.unittestEnabled": true
515
}

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ clean:
1010
test:
1111
python -m unittest discover .
1212

13-
generate-models:
13+
generate:
1414
cd generator && npm i && npm run generate

generator/package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

generator/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "generator",
33
"version": "0.0.0",
44
"dependencies": {
5-
"@asyncapi/modelina": "4.0.0-next.19"
5+
"@asyncapi/modelina": "4.0.0-next.25"
66
},
77
"devDependencies": {
88
"typescript": "^5.3.3",

generator/src/generate-models.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ async function defaultGenerateModels(input: FileReadType, outputDir: string) {
2727
// fs.rmSync(outputDirForVersion, { recursive: true });
2828
// }
2929
const generator = new PythonFileGenerator({
30-
importsStyle: 'explicit',
30+
importsStyle: 'implicit',
3131
presets: [
3232
PYTHON_JSON_SERIALIZER_PRESET],
3333
});

pyproject.toml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
[build-system]
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
4+
5+
[project]
6+
name = "asyncapi_python_parser_jonaslagoni"
7+
version = "0.0.1"
8+
authors = [
9+
{ name="jonaslagoni", email="jonas-lt@live.dk" },
10+
]
11+
description = "An AsyncAPI python parser, that supports all versions"
12+
readme = "README.md"
13+
requires-python = ">=3.7"
14+
classifiers = [
15+
"Programming Language :: Python :: 3",
16+
"License :: OSI Approved :: Apache2.0",
17+
"Operating System :: OS Independent",
18+
]
19+
20+
[project.urls]
21+
Homepage = "https://github.com/jonaslagoni/asyncapi-python-parser"
22+
Issues = "https://github.com/jonaslagoni/asyncapi-python-parser/issues"
23+
24+
[tool.semantic_release]
25+
assets = []
26+
commit_message = "{version}\n\nAutomatically generated by python-semantic-release"
27+
commit_parser = "angular"
28+
logging_use_named_masks = false
29+
major_on_zero = true
30+
allow_zero_version = true
31+
tag_format = "v{version}"
32+
33+
[tool.semantic_release.branches.main]
34+
match = "(next|master)"
35+
prerelease_token = "rc"
36+
prerelease = false
37+
38+
[tool.semantic_release.changelog]
39+
template_dir = "templates"
40+
changelog_file = "CHANGELOG.md"
41+
exclude_commit_patterns = []
42+
43+
[tool.semantic_release.changelog.environment]
44+
block_start_string = "{%"
45+
block_end_string = "%}"
46+
variable_start_string = "{{"
47+
variable_end_string = "}}"
48+
comment_start_string = "{#"
49+
comment_end_string = "#}"
50+
trim_blocks = false
51+
lstrip_blocks = false
52+
newline_sequence = "\n"
53+
keep_trailing_newline = false
54+
extensions = []
55+
autoescape = true
56+
57+
[tool.semantic_release.commit_author]
58+
env = "GIT_COMMIT_AUTHOR"
59+
default = "semantic-release <semantic-release>"
60+
61+
[tool.semantic_release.commit_parser_options]
62+
allowed_tags = ["build", "chore", "ci", "docs", "feat", "fix", "refactor", "test"]
63+
minor_tags = ["feat"]
64+
patch_tags = ["fix"]
65+
default_bump_level = 0
66+
67+
[tool.semantic_release.remote]
68+
name = "origin"
69+
type = "github"
70+
ignore_token_for_push = false
71+
insecure = false
72+
73+
[tool.semantic_release.publish]
74+
dist_glob_patterns = ["dist/*"]
75+
upload_to_vcs_release = true
76+

requirements.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
pyyaml
2-
jsonschema
2+
jsonschema
3+
jsonpath-ng
4+
python-semantic-release

src/models/asyncapi_1_0_0/ApiKey.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,29 @@
1-
from .ApiKeyType import ApiKeyType
2-
from .ApiKeyIn import ApiKeyIn
1+
from __future__ import annotations
32
import json
43
from typing import Any, Dict
4+
from . import ApiKeyType
5+
from . import ApiKeyIn
56
class ApiKey:
67
def __init__(self, input: Dict):
7-
self._type: ApiKeyType = ApiKeyType(input['type'])
8-
self._reserved_in: ApiKeyIn = ApiKeyIn(input['reserved_in'])
9-
if hasattr(input, 'description'):
8+
self._type: ApiKeyType.ApiKeyType = ApiKeyType.ApiKeyType(input['type'])
9+
self._reserved_in: ApiKeyIn.ApiKeyIn = ApiKeyIn.ApiKeyIn(input['reserved_in'])
10+
if 'description' in input:
1011
self._description: str = input['description']
11-
if hasattr(input, 'additional_properties'):
12+
if 'additional_properties' in input:
1213
self._additional_properties: dict[str, Any] = input['additional_properties']
1314

1415
@property
15-
def type(self) -> ApiKeyType:
16+
def type(self) -> ApiKeyType.ApiKeyType:
1617
return self._type
1718
@type.setter
18-
def type(self, type: ApiKeyType):
19+
def type(self, type: ApiKeyType.ApiKeyType):
1920
self._type = type
2021

2122
@property
22-
def reserved_in(self) -> ApiKeyIn:
23+
def reserved_in(self) -> ApiKeyIn.ApiKeyIn:
2324
return self._reserved_in
2425
@reserved_in.setter
25-
def reserved_in(self, reserved_in: ApiKeyIn):
26+
def reserved_in(self, reserved_in: ApiKeyIn.ApiKeyIn):
2627
self._reserved_in = reserved_in
2728

2829
@property

src/models/asyncapi_1_0_0/ApiKeyHttpSecurityScheme.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
1-
from .ApiKeyHttpSecuritySchemeType import ApiKeyHttpSecuritySchemeType
2-
from .ApiKeyHttpSecuritySchemeIn import ApiKeyHttpSecuritySchemeIn
1+
from __future__ import annotations
32
import json
43
from typing import Any, Dict
4+
from . import ApiKeyHttpSecuritySchemeType
5+
from . import ApiKeyHttpSecuritySchemeIn
56
class ApiKeyHttpSecurityScheme:
67
def __init__(self, input: Dict):
7-
self._type: ApiKeyHttpSecuritySchemeType = ApiKeyHttpSecuritySchemeType(input['type'])
8+
self._type: ApiKeyHttpSecuritySchemeType.ApiKeyHttpSecuritySchemeType = ApiKeyHttpSecuritySchemeType.ApiKeyHttpSecuritySchemeType(input['type'])
89
self._name: str = input['name']
9-
self._reserved_in: ApiKeyHttpSecuritySchemeIn = ApiKeyHttpSecuritySchemeIn(input['reserved_in'])
10-
if hasattr(input, 'description'):
10+
self._reserved_in: ApiKeyHttpSecuritySchemeIn.ApiKeyHttpSecuritySchemeIn = ApiKeyHttpSecuritySchemeIn.ApiKeyHttpSecuritySchemeIn(input['reserved_in'])
11+
if 'description' in input:
1112
self._description: str = input['description']
12-
if hasattr(input, 'additional_properties'):
13+
if 'additional_properties' in input:
1314
self._additional_properties: dict[str, Any] = input['additional_properties']
1415

1516
@property
16-
def type(self) -> ApiKeyHttpSecuritySchemeType:
17+
def type(self) -> ApiKeyHttpSecuritySchemeType.ApiKeyHttpSecuritySchemeType:
1718
return self._type
1819
@type.setter
19-
def type(self, type: ApiKeyHttpSecuritySchemeType):
20+
def type(self, type: ApiKeyHttpSecuritySchemeType.ApiKeyHttpSecuritySchemeType):
2021
self._type = type
2122

2223
@property
@@ -27,10 +28,10 @@ def name(self, name: str):
2728
self._name = name
2829

2930
@property
30-
def reserved_in(self) -> ApiKeyHttpSecuritySchemeIn:
31+
def reserved_in(self) -> ApiKeyHttpSecuritySchemeIn.ApiKeyHttpSecuritySchemeIn:
3132
return self._reserved_in
3233
@reserved_in.setter
33-
def reserved_in(self, reserved_in: ApiKeyHttpSecuritySchemeIn):
34+
def reserved_in(self, reserved_in: ApiKeyHttpSecuritySchemeIn.ApiKeyHttpSecuritySchemeIn):
3435
self._reserved_in = reserved_in
3536

3637
@property

0 commit comments

Comments
 (0)