Commit 8724ce06 authored by janis.streib's avatar janis.streib 🦉
Browse files

ADD: swagger: object definitions (#152)

parent 0f9a6d52
Pipeline #58927 passed with stages
in 4 minutes and 32 seconds
......@@ -171,10 +171,10 @@ def generateParamters(f):
props = {}
if len(old_params) > 0:
props['old'] = {
'description': 'Alte Attribute zur einduetigen Identifizierung des Objekts',
'type': 'object',
'properties': old_params,
}
'description': 'Alte Attribute zur einduetigen Identifizierung des Objekts',
'type': 'object',
'properties': old_params,
}
if len(new_params) > 0:
props['new'] = {
'description': 'Neue Angaben',
......@@ -191,8 +191,12 @@ def generateParamters(f):
}
}]
systems = sess.get(
"{scheme}://{base_host}{base_url}/".format(scheme=API_SCHEME, base_host=API_HOST, base_url=API_BASE_URL))
objects = sess.get(
"{scheme}://{base_host}{base_url}/wapi/object_type/list".format(scheme=API_SCHEME, base_host=API_HOST, base_url=API_BASE_URL)).json()[0]
swagger['tags'] = systems.json()[0]
swagger['securityDefinitions'] = {'api_key': {'type': 'apiKey', 'name': 'Authorization', 'in': 'header'}}
swagger['paths'] = {f"/{f['system']}/{f['object_type']}/{f['name']}":
......@@ -218,5 +222,19 @@ swagger['paths'] = {f"/{f['system']}/{f['object_type']}/{f['name']}":
}}}
for f in func_index
}
swagger['definitions'] = {o['name']:
{
'type': 'object',
'description': o['description'],
'properties': {
a: {
'type': d['dataType']['jsonName'],
'description': d['description']
}
for a, d in o['attributes'].items()}
}
for o in objects
}
with open(SWAGGER_TARGET_FILE, 'w') as f:
f.write(json.dumps(swagger))
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment