File tree Expand file tree Collapse file tree 2 files changed +77
-12
lines changed Expand file tree Collapse file tree 2 files changed +77
-12
lines changed Original file line number Diff line number Diff line change @@ -292,6 +292,63 @@ paths:
292292 description : Describes what went wrong
293293 type : string
294294 example : " Invalid HLA locus"
295+ /valid :
296+ get :
297+ tags :
298+ - Validation
299+ operationId : api.validate_controller_get
300+ summary : Validate GL String
301+ description : |
302+ Given a GL String report whether it is valid or not
303+ parameters :
304+ - name : gl_string
305+ in : query
306+ description : GL String
307+ schema :
308+ type : string
309+ example : " B*08:ASXJP+B*07:02"
310+ responses :
311+ 200 :
312+ description : Validation Result
313+ content :
314+ application/json :
315+ schema :
316+ type : object
317+ properties :
318+ valid :
319+ description : Is GL String valid
320+ type : boolean
321+ example : true
322+ 404 :
323+ description : GL String didn't validate
324+ content :
325+ application/json :
326+ schema :
327+ type : object
328+ properties :
329+ valid :
330+ description : Is GL String valid
331+ type : boolean
332+ example : false
333+ message :
334+ description : Describes what went wrong
335+ type : string
336+ example : " Provided GL String is invalid: HLA-A*01:BLAH"
337+ cause :
338+ description : Explanation of why the GL String is not valid
339+ type : string
340+ example : " HLA-A*01:BLAH is not a valid GL Allele"
341+ 400 :
342+ description : Invalid GL String Form
343+ content :
344+ application/json :
345+ schema :
346+ type : object
347+ properties :
348+ message :
349+ description : Describes what went wrong
350+ type : string
351+ example : " Invalid HLA locus"
295352 /blend :
296353 post :
297354 tags :
Original file line number Diff line number Diff line change @@ -17,18 +17,26 @@ def validate_controller():
1717 gl_string = request .json ["gl_string" ]
1818 except KeyError :
1919 return {"message" : "gl_string not provided" }, 404
20- # Validate
21- try :
22- ard .validate (gl_string )
23- return {"valid" : True }, 200
24- except InvalidAlleleError as e :
25- return {
26- "valid" : False ,
27- "message" : f"Provided GL String is invalid: { gl_string } " ,
28- "cause" : e .message ,
29- }, 404
30- except PyArdError as e :
31- return {"message" : e .message }, 400
20+ return validate_gl (gl_string )
21+
22+
23+ def validate_controller_get (gl_string : str ):
24+ return validate_gl (gl_string )
25+
26+
27+ def validate_gl (gl_string ):
28+ # Validate
29+ try :
30+ ard .validate (gl_string )
31+ return "Yes" , 200
32+ except InvalidAlleleError as e :
33+ return {
34+ "valid" : False ,
35+ "message" : f"Provided GL String is invalid: { gl_string } " ,
36+ "cause" : e .message ,
37+ }, 404
38+ except PyArdError as e :
39+ return {"message" : e .message }, 400
3240
3341
3442def redux_controller ():
You can’t perform that action at this time.
0 commit comments