fix converter item, fix datetime handling, fix parsing of markdown description
This commit is contained in:
@ -59,7 +59,7 @@ namespace com.krohne.genericdatabaseapiservice.Services {
|
||||
|
||||
public string GetInfoStringByTag(string tag) {
|
||||
return String.Format(
|
||||
"Server={0};User ID={1};Password={2};Database={3}",
|
||||
"Server={0};User ID={1};Password={2};Database={3};Convert Zero Datetime=true",
|
||||
GetInfoByTag(tag).Host,
|
||||
GetInfoByTag(tag).User,
|
||||
GetInfoByTag(tag).Password,
|
||||
|
32
generate.py
32
generate.py
@ -68,20 +68,21 @@ apiDefinition["env"] = {
|
||||
"packagename": os.environ["PACKAGE_NAME"],
|
||||
"routeprefix": os.environ["ROUTE_PREFIX"]
|
||||
}
|
||||
statementFinder = re.compile('STATEMENTBEGIN (.*) STATEMENTEND')
|
||||
statementFinder = re.compile('STATEMENTBEGIN(\s+)(.+)(\s+)STATEMENTEND', flags=re.DOTALL)
|
||||
statementCleaner = re.compile('\s+')
|
||||
statementChecker = {
|
||||
'get': re.compile('^select', re.IGNORECASE),
|
||||
'put': re.compile('^update', re.IGNORECASE),
|
||||
'delete': re.compile('^delete', re.IGNORECASE),
|
||||
'post': re.compile('^insert', re.IGNORECASE)
|
||||
}
|
||||
databaseTagFinder = re.compile('DATABASETAGBEGIN (.*) DATABASETAGEND')
|
||||
databaseTagFinder = re.compile('DATABASETAGBEGIN(\s+)(\S+)(\s+)DATABASETAGEND', flags=re.DOTALL)
|
||||
|
||||
operations = []
|
||||
for path in apiDefinition['paths'].values():
|
||||
for (method, operation) in path.items():
|
||||
#print(f"{method=}")
|
||||
#print(f"{CsOperationNameConverter(operation['operationId'])=}")
|
||||
print(f"{method=}")
|
||||
print(f"{CsOperationNameConverter(operation['operationId'])=}")
|
||||
# if 200 in
|
||||
content = operation['responses'][200]['content']['application/json']['schema']
|
||||
if ('type' in content) and (content['type'] == 'array'):
|
||||
@ -90,20 +91,27 @@ for path in apiDefinition['paths'].values():
|
||||
else:
|
||||
isList = False
|
||||
resultType = OpenApiExtractRefType(content['$ref'])
|
||||
#print(f"{content=}")
|
||||
#print(f"{resultType=}")
|
||||
print(f"{content=}")
|
||||
print(f"{resultType=}")
|
||||
description = None
|
||||
statement = None
|
||||
if 'description' in operation:
|
||||
description = operation['description']
|
||||
print(f"{description=}")
|
||||
statementFinderResult = statementFinder.search(description)
|
||||
if statementFinderResult:
|
||||
statement = statementFinderResult.group(1)
|
||||
statement = statementCleaner.sub(' ', statementFinderResult.group(2))
|
||||
print(f"{statement=}")
|
||||
if not statementChecker[method].match(statement):
|
||||
raise Exception(f"Invalid statement {statement} for method {method}")
|
||||
else:
|
||||
print("no statement")
|
||||
databaseTagFinderResult = databaseTagFinder.search(description)
|
||||
if databaseTagFinderResult:
|
||||
databaseTag = databaseTagFinderResult.group(1)
|
||||
databaseTag = databaseTagFinderResult.group(2)
|
||||
print(f"{databaseTag=}")
|
||||
else:
|
||||
print("no databasetag")
|
||||
|
||||
bodyInputType = {}
|
||||
if 'requestBody' in operation:
|
||||
@ -132,15 +140,15 @@ for path in apiDefinition['paths'].values():
|
||||
'bodyInputType': bodyInputType,
|
||||
'paramInputTypes': paramInputTypes
|
||||
})
|
||||
#print(f"{operations=}")
|
||||
print(f"{operations=}")
|
||||
apiDefinition["operations"] = operations
|
||||
|
||||
types = {}
|
||||
for (typeName, typeDefinition) in apiDefinition['components']['schemas'].items():
|
||||
#print(f"{typeName=}")
|
||||
print(f"{typeName=}")
|
||||
typeProperties = []
|
||||
for itemName in typeDefinition['properties']:
|
||||
#print(f"{itemName=}")
|
||||
print(f"{itemName=}")
|
||||
typeProperties.append({
|
||||
'sqlName': itemName,
|
||||
'csName': itemName.capitalize()
|
||||
@ -150,7 +158,7 @@ for (typeName, typeDefinition) in apiDefinition['components']['schemas'].items()
|
||||
'csName': typeName.capitalize(),
|
||||
'properties': typeProperties
|
||||
}
|
||||
#print(f"{types=}")
|
||||
print(f"{types=}")
|
||||
apiDefinition['types'] = types
|
||||
|
||||
print(json.dumps(apiDefinition, indent=4))
|
||||
|
24
openapi.yaml
24
openapi.yaml
@ -4,11 +4,7 @@ info:
|
||||
title: Generic Database API Service
|
||||
version: "2.0.0"
|
||||
|
||||
|
||||
paths:
|
||||
# --------------------------------------------------------------------------------------------------
|
||||
# --- baseItem -------------------------------------------------------------------------------------
|
||||
# --------------------------------------------------------------------------------------------------
|
||||
/pdb/v2/baseItem/{articleNumber}:
|
||||
get:
|
||||
tags: [ "Regular" ]
|
||||
@ -46,10 +42,6 @@ paths:
|
||||
$ref: "#/components/responses/clientSideError"
|
||||
500:
|
||||
$ref: "#/components/responses/serverSideError"
|
||||
|
||||
# --------------------------------------------------------------------------------------------------
|
||||
# --- productionOrderItem --------------------------------------------------------------------------
|
||||
# --------------------------------------------------------------------------------------------------
|
||||
/pdb/v2/productionOrderItem/{productionOrder}:
|
||||
get:
|
||||
tags: [ "Regular" ]
|
||||
@ -93,10 +85,6 @@ paths:
|
||||
$ref: "#/components/responses/clientSideError"
|
||||
500:
|
||||
$ref: "#/components/responses/serverSideError"
|
||||
|
||||
# --------------------------------------------------------------------------------------------------
|
||||
# --- converterItem --------------------------------------------------------------------------------
|
||||
# --------------------------------------------------------------------------------------------------
|
||||
/pdb/v2/converterItem/{serialNumber}:
|
||||
get:
|
||||
tags: [ "Regular" ]
|
||||
@ -129,9 +117,9 @@ paths:
|
||||
,(CASE WHEN ISNULL(anonyme_cg_geraete.Artikelcode) THEN (CASE WHEN auftraege.C_Nummer = \"\" THEN NULL ELSE auftraege.C_Nummer END) ELSE anonyme_cg_geraete.C_Nummer END) AS cgNumber
|
||||
,(CASE WHEN ISNULL(ems.Seriennummer) THEN auftraege.IX ELSE ems.Equi_index END) AS bomIndex
|
||||
,(CASE WHEN ISNULL(ems.Seriennummer) THEN FALSE ELSE TRUE END) AS hasEmsUpdate
|
||||
,FALSE AS is_testConverter
|
||||
,FALSE AS isTestConverter
|
||||
,geraete_daten.montagedatum AS initialTestDate
|
||||
,(CASE WHEN geraete_daten.ergebnis_erstinbetriebnahme = \"PASS\" THEN TRUE ELSE FALSE END) AS intialTestResult
|
||||
,(CASE WHEN geraete_daten.ergebnis_erstinbetriebnahme = \"PASS\" THEN TRUE ELSE FALSE END) AS initialTestResult
|
||||
,geraete_daten.hv_test_datum AS hvTestDate
|
||||
,(CASE WHEN geraete_daten.hv_test_ergebnis = \"PASS\" THEN TRUE ELSE FALSE END) AS hvTestResult
|
||||
,geraete_daten.temp_test_datum AS temperatureTestDate
|
||||
@ -148,20 +136,20 @@ paths:
|
||||
STATEMENTEND
|
||||
```
|
||||
parameters:
|
||||
- name: productionOrder
|
||||
- name: serialNumber
|
||||
in: path
|
||||
required: true
|
||||
schema:
|
||||
type: integer
|
||||
responses:
|
||||
200:
|
||||
description: Here are your productionOrderItem items
|
||||
description: Here are your converterItem items
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/productionOrderItem"
|
||||
$ref: "#/components/schemas/converterItem"
|
||||
400:
|
||||
$ref: "#/components/responses/clientSideError"
|
||||
500:
|
||||
@ -301,7 +289,7 @@ components:
|
||||
hasEmsUpdate:
|
||||
type: boolean
|
||||
nullable: true
|
||||
testConverter:
|
||||
isTestConverter:
|
||||
type: boolean
|
||||
nullable: true
|
||||
initialTestDate:
|
||||
|
Reference in New Issue
Block a user