Skip to content
Snippets Groups Projects
Unverified Commit fe7c940e authored by Andrea Franchini's avatar Andrea Franchini
Browse files

Add ?version query param to /modelcheck endpoint

parent ae577f8d
Branches
No related tags found
No related merge requests found
import copy import copy
import importlib.resources as ilres import importlib.resources as ilres
import sys
from typing import Optional, Tuple from typing import Optional, Tuple
from lxml import etree from lxml import etree
...@@ -90,7 +91,10 @@ def parse_doml_model(raw_model: bytes, doml_version: Optional[DOMLVersion]) -> T ...@@ -90,7 +91,10 @@ def parse_doml_model(raw_model: bytes, doml_version: Optional[DOMLVersion]) -> T
model, doml_version = get_model(raw_model, doml_version) model, doml_version = get_model(raw_model, doml_version)
else: # if user specifies DOML version, respect that choice! else: # if user specifies DOML version, respect that choice!
try:
model = parse_xmi_model(raw_model, doml_version) model = parse_xmi_model(raw_model, doml_version)
except:
raise Exception("Parsing of DOML failed. Perhaps you are using the wrong DOML version or IDE?")
print(f"Using DOML {doml_version.value}") print(f"Using DOML {doml_version.value}")
......
...@@ -15,17 +15,20 @@ def make_error(user_msg, debug_msg=None): ...@@ -15,17 +15,20 @@ def make_error(user_msg, debug_msg=None):
print(f"ERROR [{datetime.datetime.now()}]: {debug_msg}") print(f"ERROR [{datetime.datetime.now()}]: {debug_msg}")
return result return result
def post(body, version=None):
def post(body):
doml_xmi = body doml_xmi = body
try: try:
doml_version = None doml_version = None
try: try:
doml_version: str = os.environ["DOML_VERSION"] doml_version: str = os.environ["DOML_VERSION"]
doml_version = DOMLVersion.get(doml_version)
print("Setting DOML version from DOML_VERSION")
except: except:
pass pass
if version:
doml_version: str = version
if doml_version:
doml_version = DOMLVersion.get(doml_version)
print(f"Forcing DOML {doml_version.value}")
dmc = ModelChecker(doml_xmi, doml_version) dmc = ModelChecker(doml_xmi, doml_version)
user_req_store = None user_req_store = None
......
...@@ -3,12 +3,13 @@ info: ...@@ -3,12 +3,13 @@ info:
license: license:
name: Apache-2.0 name: Apache-2.0
title: PIACERE Model Checker title: PIACERE Model Checker
version: "1.0" version: "2.2.0"
paths: paths:
/modelcheck: /modelcheck:
post: post:
summary: Verify a DOML model
description: Send a DOML model in XMI format and a requirement to check. description: Send a DOML model in XMI format and a requirement to check.
The response says whether the requirement is satisfied by the model, The response says whether the requirements are satisfied by the model,
with a description of the issue if it is not. with a description of the issue if it is not.
operationId: mc_openapi.handlers.post operationId: mc_openapi.handlers.post
requestBody: requestBody:
...@@ -17,6 +18,16 @@ paths: ...@@ -17,6 +18,16 @@ paths:
schema: schema:
type: string type: string
required: true required: true
parameters:
- in: query
name: version
schema:
type: string
description: >
The DOML version you're currently using, written as e.g. `2.0` or `V2_0`.
If not specified, it will try to infer it by trying to parse it for each supported
DOML version, starting with the most recent.
required: false
responses: responses:
"200": "200":
content: content:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment