How to build MC API client libraries from swagger file

AC

It seems that MC APIs use swagger. 

I was able to locate the swagger.json config file at ``/MobiControl/api/swagger/v2/swagger.json`` however I'm struggling to compile the client libraries for Kotlin. 

I'm using: 

swagger-codegen generate -l kotlin-client -v -i swagger.json --api-package dev.antoniocalabrese.mobicontrol.api --model-package dev.antoniocalabrese.mobicontrol.data

Also tried:

openapi-generator generate -i ./swagger.json  -g kotlin

With the second command I get some errors with the config validation:

 org.openapitools.codegen.SpecValidationException: There were issues with the specification. The option can be disabled via validateSpec (Maven/Gradle) or --skip-validate-spec (CLI).
 | Error count: 3, Warning count: 297
Errors:
        -attribute paths.'/devices/{deviceId}/profiles/{profileId}/actions'(post).[action].x-enumType is unexpected
        -attribute paths.'/security/currentUser/eulaStatus'(put).[eulaStatus].x-enumType is unexpected
        -attribute paths.'/devicegroups/{path}/icon'(put).[newIcon].x-enumType is unexpected

The first command executes but then gradle fails to build the library. 

Has anyone ever successfully tried to do something similar? 

2 years ago
SOTI MobiControl
ANSWERS
RS
Rafael Schäfer
2 years ago

I don't know Kotlin but doing the API request thru http requests using different programming language (taking the information you found on the Mobicontrol API page) are going fine.

But be aware to read the entire page! You need to use a registered user for those API requests!

ZC
Zafer Cigdem
2 years ago

Hi Antonio,

I've done something similar earlier but by using Python or PowerShell. In case it may help, you may use Postman first to verify the API call that you are trying to use is working well. And then on the Postman there is "export to related Programming language" option feature, you may have a look at there for reference purpose and adapt it to your code. You can see where to find this feature from Postman on below screenshot. I hope it helps. 

Zafer

AC

Yeah, Im more in a situation where I need to use a lot of different APIs from different code bases and languages so I wanted to avoid the manual process. 

Swagger code gen should be able to jsut compile the APIs into a client library that you can call from the code ... I will try few more things and see how it goes 

Thanks!

M
MPMOD@SOTI
2 years ago

Hi Antonio,

Thank you for posting on SOTI Pulse! 

Did you get the chance to test using the API's as per the suggestion provided by Zafer?

I am looking forward to your response.

Kind regards,

Technical Support Specialist | SOTI | +1 905.624.9828 | SOTI.net lDiscussion Forum | Log a Case Online l Facebook l LinkedIn l Twitter