-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate OpenAPI Python modules (closes
#18). Rather than including a set of pre-generated API modules, include a build time script to automatically download and generate the modules.
- Loading branch information
1 parent
43778b0
commit 6944bea
Showing
29 changed files
with
136 additions
and
8,642 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
*.pyc | ||
*.pyo | ||
*.egg-info | ||
*.dist-info | ||
__pycache__ | ||
dist | ||
build | ||
src/rt_5gms_as/openapi_5g |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import os.path | ||
import logging | ||
from setuptools import build_meta as _orig | ||
import subprocess | ||
|
||
replace = ['build_sdist'] | ||
log = logging.getLogger(__name__) | ||
|
||
# Copy all exported variables from the original | ||
for name in _orig.__all__: | ||
if name not in replace: | ||
v = getattr(_orig, name) | ||
globals()[name] = v | ||
__all__ = _orig.__all__ | ||
|
||
def _check_openapi(): | ||
custom_build_dir = os.path.dirname(__file__) | ||
topdir = os.path.join(custom_build_dir,'..') | ||
srcdir = os.path.join(topdir,'src') | ||
rt_5gms_as_dir = os.path.join(srcdir, 'rt_5gms_as') | ||
openapi_dir = os.path.join(rt_5gms_as_dir, 'openapi_5g') | ||
if not os.path.isdir(openapi_dir): | ||
log.info('Generating OpenAPI Python classes...') | ||
result = subprocess.run([os.path.join(custom_build_dir,'generate_openapi')], stdin=None, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | ||
if result.returncode != 0: | ||
log.error("Failed: %s", result.stderr.decode('utf-8')) | ||
else: | ||
log.info('Done generating OpenAPI Python classes') | ||
|
||
def build_sdist(sdist_directory, config_settings=None): | ||
_check_openapi() | ||
return _orig.build_sdist(sdist_directory, config_settings) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/bin/sh | ||
# | ||
# 5G-MAG Reference Tools: 5GMS Application Server | ||
# =============================================== | ||
# | ||
# File: generate_openapi | ||
# License: 5G-MAG Public License (v1.0) | ||
# Author: David Waring | ||
# Copyright: (C) 2022 British Broadcasting Corporation | ||
# | ||
# For full license terms please see the LICENSE file distributed with this | ||
# program. If this file is missing then the license can be retrieved from | ||
# https://drive.google.com/file/d/1cinCiA778IErENZ3JN52VFW-1ffHpx7Z/view | ||
# | ||
# This will download the openapi-generator JAR, fetch the latest release 17 | ||
# OpenAPI YAML files for 5G and use them to generate python modules for parsing | ||
# the 5GMS ContentHostingConfiguration JSON from TS 26.512 (M1 interface). | ||
# | ||
|
||
scriptdir=`dirname "$0"` | ||
scriptdir=`cd "$scriptdir"; pwd` | ||
|
||
rt_5gms_as_dir=`cd "${scriptdir}/../src/rt_5gms_as"; pwd` | ||
|
||
find_java() { | ||
# Use the JAVA environment variable if set else look for "java" command | ||
if [ -n "$JAVA" ]; then | ||
echo $JAVA | ||
else | ||
which java | ||
fi | ||
} | ||
|
||
if [ ! -d "${rt_5gms_as_dir}/openapi_5g" ]; then | ||
mkdir -p "${rt_5gms_as_dir}/openapi_5g" | ||
java=`find_java` | ||
tmpdir=`mktemp -d --tmpdir openapi-generator.XXXXXXXX` | ||
trap "rm -rf '$tmpdir'" 0 1 2 3 4 5 6 7 8 10 11 12 13 14 | ||
( | ||
cd "$tmpdir" | ||
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/6.0.1/openapi-generator-cli-6.0.1.jar -O openapi-generator-cli.jar | ||
git clone -b REL-17 https://forge.3gpp.org/rep/all/5G_APIs.git | ||
mkdir 5g-api-python | ||
"$java" -jar openapi-generator-cli.jar generate -i 5G_APIs/TS26512_M1_ContentHostingProvisioning.yaml -g python --additional-properties packageName=rt_5gms_as.openapi_5g,projectName=openapi-5g -o 5g-api-python | ||
cp -rv 5g-api-python/rt_5gms_as/openapi_5g "$rt_5gms_as_dir/" | ||
) | ||
fi | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,32 @@ | ||
[build-system] | ||
requires = ["setuptools"] | ||
build-backend = "setuptools.build_meta" | ||
build-backend = "backend" | ||
backend-path = ["build_scripts"] | ||
|
||
[project] | ||
name = "rt-5gms-application-server" | ||
version = "0.0.1" | ||
dependencies = [ | ||
'urllib3 >= 1.25.3', | ||
'python-dateutil', | ||
'importlib-metadata; python_version >= 3.7', | ||
'python-dateutil' | ||
] | ||
scripts = { 5gms-application-server = "rt_5gms_as.app" } | ||
requires-python = ">=3.7" | ||
scripts = { 5gms-application-server = "rt_5gms_as.app:main" } | ||
authors = [ | ||
{ name = 'David Waring', email = '[email protected]' } | ||
] | ||
license = { file = "LICENSE" } | ||
readme = "README.md" | ||
|
||
[project.urls] | ||
"Homepage" = "https://5g-mag.com/" | ||
"Source" = "https://github.com/5g-mag/rt-5gms-application-server" | ||
|
||
[tool.setuptools.packages.find] | ||
where = ["src"] | ||
|
||
[tool.setuptools.package-data] | ||
"rt_5gms_as.proxies" = ["*.tmpl"] | ||
|
||
[tool.setuptools.data-files] | ||
'docs' = ['docs/*'] |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.