On 16/07/20 12:16, Miroslav.Capkovic wrote: > Hi, > > I have problems with generating rest api clients from > /syncope/rest/openapi.json as through swager as throuh openapi for syncope. > > > Both technologies has problem with the following: > > > - duplicate (version 2.1.7-SNAPSHOT) parmeter remediationKey or unsued > key (version 2.1.6) on service endpoint /remediations (can be repaired) > > - missing schema model PolicyTO , that leads to impossibility to > generate client (openapi) and leads to incorrectly generated classess > (swagger) (seems tha parent of AccountPolicyTO should be PolictyTO but > its is object) > > > A im not sure if the problem is really syncope related or it is related > to openapi/swagger tools. > > > Both i have used for generating python swagger_client. (seems be that > there is missing dependecy between AccounPolicyTO and PolicyTO but i'm > not sure ) > > path to reproduce with swagger - generates code but code is not valid and > ends with error message missing PolicyTO object in AccountPolicyTO object: > > -- snippet of generated python code -- > > ... > > class AccountPolicyTO(object): > ... > > code generates the error code: > > > File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked > File "<frozen importlib._bootstrap>", line 668, in _load_unlocked > File "<frozen importlib._bootstrap>", line 638, in _load_backward_compatible > File > "/opt/venv/lib/python3.7/site-packages/swagger_client-1.0.0-py3.7.egg/swagger_client/models/account_policy_to.py", > line 19, in <module> > File > "/opt/venv/lib/python3.7/site-packages/swagger_client-1.0.0-py3.7.egg/swagger_client/models/account_policy_to.py", > line 42, in AccountPolicyTO > *NameError: name 'PolicyTO' is not defined* > > > > path to reproduce with openapi : > > ./openapi-generator-cli generate -g python -i > http://idm:8080/syncope/rest/openapi.json -o out --skip-validate-sp > > generates error message(code is not generated) > > .... > > Exception in thread "main" java.lang.RuntimeException: *Could not process > model 'PolicyTO'.*Please make sure that your schema is correct! > at > org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:496) > at > org.openapitools.codegen.DefaultGenerator.generate(DefaultGenerator.java:1005) > at org.openapitools.codegen.cmd.Generate.execute(Generate.java:431) > at > org.openapitools.codegen.cmd.OpenApiGeneratorCommand.run(OpenApiGeneratorCommand.java:32) > at > org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:61) > Caused by: java.lang.RuntimeException: Stack overflow hit when looking for > PolicyTO an infinite loop starting and ending at PullPolicyTO was seen > at > org.openapitools.codegen.DefaultCodegen.getAllOfDescendants(DefaultCodegen.java:2670) > at > org.openapitools.codegen.DefaultCodegen.createDiscriminator(DefaultCodegen.java:2722) > at > org.openapitools.codegen.DefaultCodegen.fromModel(DefaultCodegen.java:2152) > at > org.openapitools.codegen.DefaultGenerator.processModels(DefaultGenerator.java:1289) > at > org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:491) > > > in swagger editor/openapi code gen generate python client for rest api > and test code
Hi Miro, thanks for reporting the issue about duplicated remediationKey I have just fixed that in https://github.com/apache/syncope/commit/66927e35e93e3823720c5bab23180e870b7da726 it should be ok now. Regarding PolicyTO and children (as AccountPolicyTO, PasswordPolicyTO, PullPolicyTO and PushPolicyTO) I think the real issue is that the related REST service is heavily using Java generics: see https://github.com/apache/syncope/blob/2_1_X/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/PolicyService.java and I am not sure how this could be better handled in OpenAPI. I have generated the Python client via http://editor.swagger.io/ and run python setup.py build that went out fine, but I don't know how to move forward to check if the client is actually working or not; can you provide some help? Regards. -- Francesco Chicchiriccò Tirasa - Open Source Excellence http://www.tirasa.net/ Member at The Apache Software Foundation Syncope, Cocoon, Olingo, CXF, OpenJPA, PonyMail http://home.apache.org/~ilgrosso/
